From 391a24903d9ee10eb799717981a2a27dd8cd580b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20G=C3=B6ttsch?= Date: Tue, 15 Oct 2024 08:39:48 +0200 Subject: [PATCH] [IMP] nfu_sale_order_batch_packaging: add regeneration of batch products --- nfu_sale_order_batch_packaging/README.rst | 1 + nfu_sale_order_batch_packaging/__manifest__.py | 2 +- nfu_sale_order_batch_packaging/models/__init__.py | 1 + .../models/sale_order_batch.py | 11 +++++++++++ nfu_sale_order_batch_packaging/readme/HISTORY.rst | 3 ++- .../static/description/index.html | 2 ++ .../views/sale_order_batch_views.xml | 10 ++++++++++ sale_order_batch/README.rst | 1 + sale_order_batch/__manifest__.py | 2 +- sale_order_batch/models/sale_order.py | 2 +- sale_order_batch/models/sale_order_line.py | 4 ++-- sale_order_batch/readme/HISTORY.rst | 3 ++- sale_order_batch/static/description/index.html | 2 ++ 13 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 nfu_sale_order_batch_packaging/models/sale_order_batch.py diff --git a/nfu_sale_order_batch_packaging/README.rst b/nfu_sale_order_batch_packaging/README.rst index 167f57f..198ce03 100644 --- a/nfu_sale_order_batch_packaging/README.rst +++ b/nfu_sale_order_batch_packaging/README.rst @@ -36,6 +36,7 @@ Changelog :0.0.1: Initial module. :1.0.0: rename to nfu_sale_order_batch_packaging :1.1.0: Live +:1.2.0: Add regeneration action for batch products Bug Tracker =========== diff --git a/nfu_sale_order_batch_packaging/__manifest__.py b/nfu_sale_order_batch_packaging/__manifest__.py index 0ecdd3d..d2f494d 100644 --- a/nfu_sale_order_batch_packaging/__manifest__.py +++ b/nfu_sale_order_batch_packaging/__manifest__.py @@ -4,7 +4,7 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "Sale", - "version": "16.0.1.1.0", + "version": "16.0.1.2.0", "depends": ["sale", "sale_order_batch"], "data": [ "views/sale_order_views.xml", diff --git a/nfu_sale_order_batch_packaging/models/__init__.py b/nfu_sale_order_batch_packaging/models/__init__.py index 7b39236..9f32727 100644 --- a/nfu_sale_order_batch_packaging/models/__init__.py +++ b/nfu_sale_order_batch_packaging/models/__init__.py @@ -1,2 +1,3 @@ +from . import sale_order_batch from . import sale_order_line from . import sale_order_batch_product diff --git a/nfu_sale_order_batch_packaging/models/sale_order_batch.py b/nfu_sale_order_batch_packaging/models/sale_order_batch.py new file mode 100644 index 0000000..d0dd492 --- /dev/null +++ b/nfu_sale_order_batch_packaging/models/sale_order_batch.py @@ -0,0 +1,11 @@ +from odoo import models + + +class SaleOrderBatch(models.Model): + _inherit = "sale.order.batch" + + def action_recompute_products(self): + for batch in self: + batch.product_ids.unlink() + for line in batch.sale_order_line_ids: + line._update_batch_product() diff --git a/nfu_sale_order_batch_packaging/readme/HISTORY.rst b/nfu_sale_order_batch_packaging/readme/HISTORY.rst index 918d67d..eaeee39 100644 --- a/nfu_sale_order_batch_packaging/readme/HISTORY.rst +++ b/nfu_sale_order_batch_packaging/readme/HISTORY.rst @@ -1,3 +1,4 @@ :0.0.1: Initial module. :1.0.0: rename to nfu_sale_order_batch_packaging -:1.1.0: Live \ No newline at end of file +:1.1.0: Live +:1.2.0: Add regeneration action for batch products \ No newline at end of file diff --git a/nfu_sale_order_batch_packaging/static/description/index.html b/nfu_sale_order_batch_packaging/static/description/index.html index ff7ebcd..bc06d57 100644 --- a/nfu_sale_order_batch_packaging/static/description/index.html +++ b/nfu_sale_order_batch_packaging/static/description/index.html @@ -397,6 +397,8 @@ and adds a packaging default to sale order batch.

1.1.0:Live +1.2.0:Add regeneration action for batch products + diff --git a/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml b/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml index ec519f8..09d11de 100644 --- a/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml +++ b/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml @@ -1,5 +1,15 @@ + + Regenerate Products + + + code + + for batch in records: + batch.action_recompute_products() + + sale.order.batch.form.product.min_max_qty sale.order.batch diff --git a/sale_order_batch/README.rst b/sale_order_batch/README.rst index 0a5db41..52941c0 100644 --- a/sale_order_batch/README.rst +++ b/sale_order_batch/README.rst @@ -36,6 +36,7 @@ Changelog :0.0.1: Initial module. :1.0.0: Add Multi Company ability +:1.0.1: rename product creation methode Bug Tracker =========== diff --git a/sale_order_batch/__manifest__.py b/sale_order_batch/__manifest__.py index 41e7380..2011e6a 100644 --- a/sale_order_batch/__manifest__.py +++ b/sale_order_batch/__manifest__.py @@ -4,7 +4,7 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "Sale", - "version": "16.0.1.0.0", + "version": "16.0.1.0.1", "depends": ["sale", "product"], "data": [ "data/ir_sequence_data.xml", diff --git a/sale_order_batch/models/sale_order.py b/sale_order_batch/models/sale_order.py index aef654c..8c3a378 100644 --- a/sale_order_batch/models/sale_order.py +++ b/sale_order_batch/models/sale_order.py @@ -52,5 +52,5 @@ class SaleOrder(models.Model): raise UserError(_(f"Sale Order not in State Draft or Sent: {', '.join(invalid_orders)}")) res = super().write(vals) if "batch_id" in vals: - self.order_line._update_batch_products() + self.order_line._update_batch_product() return res diff --git a/sale_order_batch/models/sale_order_line.py b/sale_order_batch/models/sale_order_line.py index 4c243dd..85ceb75 100644 --- a/sale_order_batch/models/sale_order_line.py +++ b/sale_order_batch/models/sale_order_line.py @@ -6,7 +6,7 @@ class SaleOrderLine(models.Model): batch_id = fields.Many2one(related="order_id.batch_id") - def _update_batch_products(self): + def _update_batch_product(self): for order_line in self: batch_id = order_line.order_id.batch_id if batch_id: @@ -19,5 +19,5 @@ class SaleOrderLine(models.Model): @api.model_create_multi def create(self, vals_list): res = super().create(vals_list) - res._update_batch_products() + res._update_batch_product() return res diff --git a/sale_order_batch/readme/HISTORY.rst b/sale_order_batch/readme/HISTORY.rst index 7322126..682f088 100644 --- a/sale_order_batch/readme/HISTORY.rst +++ b/sale_order_batch/readme/HISTORY.rst @@ -1,2 +1,3 @@ :0.0.1: Initial module. -:1.0.0: Add Multi Company ability \ No newline at end of file +:1.0.0: Add Multi Company ability +:1.0.1: rename product creation methode \ No newline at end of file diff --git a/sale_order_batch/static/description/index.html b/sale_order_batch/static/description/index.html index 6404dbf..2659f45 100644 --- a/sale_order_batch/static/description/index.html +++ b/sale_order_batch/static/description/index.html @@ -396,6 +396,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation 1.0.0:Add Multi Company ability +1.0.1:rename product creation methode +