From d482b55cc20d5d74b15624d64036b991a6e272d0 Mon Sep 17 00:00:00 2001 From: Yu Weng Date: Wed, 9 Oct 2024 14:13:26 +0200 Subject: [PATCH] [MIG] rental_product_pack: porting of missing changes after migration from v12 to v14 --- rental_product_pack/__manifest__.py | 35 ++++++++++++++++++- rental_product_pack/models/sale.py | 12 +------ rental_product_pack/models/stock.py | 26 ++++++++++++++ .../views/product_pack_line_view.xml | 13 ------- rental_product_pack/views/product_view.xml | 13 ++++++- 5 files changed, 73 insertions(+), 26 deletions(-) delete mode 100644 rental_product_pack/views/product_pack_line_view.xml diff --git a/rental_product_pack/__manifest__.py b/rental_product_pack/__manifest__.py index ff822a89..52e9f563 100644 --- a/rental_product_pack/__manifest__.py +++ b/rental_product_pack/__manifest__.py @@ -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": [ @@ -14,7 +48,6 @@ "data": [ "security/ir.model.access.csv", "views/product_view.xml", - "views/product_pack_line_view.xml", ], "demo": [], "qweb": [], diff --git a/rental_product_pack/models/sale.py b/rental_product_pack/models/sale.py index c616dda9..20cded9d 100644 --- a/rental_product_pack/models/sale.py +++ b/rental_product_pack/models/sale.py @@ -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 diff --git a/rental_product_pack/models/stock.py b/rental_product_pack/models/stock.py index 5943313e..49abd61d 100644 --- a/rental_product_pack/models/stock.py +++ b/rental_product_pack/models/stock.py @@ -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() diff --git a/rental_product_pack/views/product_pack_line_view.xml b/rental_product_pack/views/product_pack_line_view.xml deleted file mode 100644 index 195a1fcc..00000000 --- a/rental_product_pack/views/product_pack_line_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - product.pack.line.form - product.pack.line - - - - - - - - diff --git a/rental_product_pack/views/product_view.xml b/rental_product_pack/views/product_view.xml index a5e83dc4..671d91cf 100644 --- a/rental_product_pack/views/product_view.xml +++ b/rental_product_pack/views/product_view.xml @@ -59,8 +59,13 @@ - + + @@ -71,9 +76,15 @@ + + + {'default_parent_product_id': active_id} +