Skip to content

Commit

Permalink
[MIG] rental_product_pack: porting of missing changes after migration…
Browse files Browse the repository at this point in the history
… from v12 to v14
  • Loading branch information
yweng8111 committed Oct 9, 2024
1 parent 3f959b9 commit d482b55
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 26 deletions.
35 changes: 34 additions & 1 deletion rental_product_pack/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@
"version": "14.0.1.0.1",
"category": "Rental",
"summary": "Manage rentals with product packs",
"usage": """
Install the module.
No further configuration is needed.
Create at least one storable product that will be a component of a pack.
* Go to Rentals > Configuration > Settings.
* Please activate the checkbox for using 'Product Variants'.
* Go to Rentals > Products > Products.
* Create a new storable product.
Create a rentable pack product.
* Create a new storable product.
* Activate the checkbox 'Can be Rented' and 'Is Pack'.
* Go to page 'Pack'.
* Choose Pack Type (e.g. Non-detailled)
* Add the previously created storable products that are part of this pack.
* Go to page 'Sales & Purchase'.
* Create the rental service and configure its name and price.
Create a rental order:
* Go to Rentals > Customer > Rental Quotations.
* Create a new order and choose the type 'Rental Order'.
* Add the rental service of the rentable pack product as an order line.
* Set the quantity.
* Choose start and end date.
* Confirm the order.
* Check out the two deliveries, one for outgoing and one for incoming delivery.
* You can see all parts of the pack in both stock pickings.
Hint:
Refer to the usage information of the OCA module product_pack to learn how to
define product packs.
Please note, that this module does not include the behavior of the module sale_product_pack.
""",
"author": "elego Software Solutions GmbH, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/vertical-rental",
"depends": [
Expand All @@ -14,7 +48,6 @@
"data": [
"security/ir.model.access.csv",
"views/product_view.xml",
"views/product_pack_line_view.xml",
],
"demo": [],
"qweb": [],
Expand Down
12 changes: 1 addition & 11 deletions rental_product_pack/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ def action_confirm(self):
)
for picking in out_pickings:
for move in picking.move_ids_without_package:
if move.product_id and move.product_id.pack_ok:
for line in move.product_id.pack_line_ids:
qty = move.product_uom_qty * line.quantity
move.copy(
{
"product_id": line.product_id.id,
"product_uom_qty": qty,
"rental_pack_move_id": move.id,
"picking_id": move.picking_id.id,
}
)
move._create_pack_products()
out_pickings.action_confirm()
in_pickings.action_confirm()
return res
26 changes: 26 additions & 0 deletions rental_product_pack/models/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,29 @@ class StockMove(models.Model):
string="Rental Main Pack Move",
comodel_name="stock.move",
)

def _create_pack_products(self):
self.ensure_one()
if self.product_id and not self.product_id.pack_ok:
return
else:
for line in self.product_id.pack_line_ids:
qty = self.product_uom_qty * line.quantity
move = self.search(
[
("picking_id", "=", self.picking_id.id),
("product_id", "=", line.product_id.id),
]
)
if move and not line.product_id.pack_ok:
move.product_uom_qty += qty
else:
new_move = self.copy(
{
"product_id": line.product_id.id,
"product_uom_qty": qty,
"rental_pack_move_id": self.id,
"picking_id": self.picking_id.id,
}
)
new_move._create_pack_products()
13 changes: 0 additions & 13 deletions rental_product_pack/views/product_pack_line_view.xml

This file was deleted.

13 changes: 12 additions & 1 deletion rental_product_pack/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@
<group name="group_pack" position="after">
<group name="group_found_pack">
<group string="Found in packs" colspan="4">
<field name="used_in_pack_line_ids" nolabel="1">
<field
name="used_in_pack_line_ids"
nolabel="1"
context="{'default_parent_product_id': active_id}"
>
<tree editable="bottom">
<field name="product_id" />
<field name="parent_product_id" />
<field name="quantity" />
</tree>
Expand All @@ -71,9 +76,15 @@
<xpath expr="//field[@name='pack_line_ids']" position="inside">
<tree editable="bottom">
<field name="product_id" />
<field name="parent_product_id" />
<field name="quantity" />
</tree>
</xpath>
<xpath expr="//field[@name='pack_line_ids']" position="attributes">
<attribute
name="context"
>{'default_parent_product_id': active_id}</attribute>
</xpath>
</field>
</record>
</odoo>

0 comments on commit d482b55

Please sign in to comment.