From 77b74b8fea829f4e23812ffa81408a1cbe8cfb26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20G=C3=B6ttsch?= Date: Tue, 4 Mar 2025 17:33:57 +0100 Subject: [PATCH] [imp] sale_order_batch: remove validity date --- sale_order_batch/README.rst | 1 + sale_order_batch/__manifest__.py | 2 +- sale_order_batch/models/sale_order.py | 15 +------- sale_order_batch/models/sale_order_batch.py | 34 ------------------- sale_order_batch/readme/HISTORY.rst | 3 +- .../static/description/index.html | 2 ++ .../views/sale_order_batch_views.xml | 2 -- 7 files changed, 7 insertions(+), 52 deletions(-) diff --git a/sale_order_batch/README.rst b/sale_order_batch/README.rst index 570e177..4c01e31 100644 --- a/sale_order_batch/README.rst +++ b/sale_order_batch/README.rst @@ -38,6 +38,7 @@ Changelog :1.0.0: Add Multi Company ability :1.0.1: rename product creation methode :1.1.0: Make validity_date persistent, add batches to SO views +:1.1.1: Remove validity date Bug Tracker =========== diff --git a/sale_order_batch/__manifest__.py b/sale_order_batch/__manifest__.py index bbf0abc..e1e2142 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.1.0", + "version": "16.0.1.1.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 9e76069..abeab6c 100644 --- a/sale_order_batch/models/sale_order.py +++ b/sale_order_batch/models/sale_order.py @@ -1,4 +1,4 @@ -from odoo import _, api, fields, models +from odoo import _, fields, models from odoo.exceptions import UserError @@ -42,20 +42,7 @@ class SaleOrder(models.Model): raise UserError(_(f"Sale Order belongs to a Batch: {', '.join(invalid_orders)}")) return super().action_confirm() - @api.model_create_multi - def create(self, vals_list): - for vals in vals_list: - if vals.get("batch_id"): - vals["validity_date"] = ( - self.env["sale.order.batch"].search([("id", "=", vals.get("batch_id"))]).validity_date - ) - return super().create(vals_list) - def write(self, vals): - if vals.get("batch_id"): - vals["validity_date"] = ( - self.env["sale.order.batch"].search([("id", "=", vals.get("batch_id"))]).validity_date - ) res = super().write(vals) if vals.get("batch_id"): self.order_line._update_batch_product() diff --git a/sale_order_batch/models/sale_order_batch.py b/sale_order_batch/models/sale_order_batch.py index ca2b302..22e509e 100644 --- a/sale_order_batch/models/sale_order_batch.py +++ b/sale_order_batch/models/sale_order_batch.py @@ -1,5 +1,3 @@ -from datetime import timedelta - from odoo import _, api, fields, models @@ -46,16 +44,6 @@ class SaleOrderBatch(models.Model): help="Creation date of order batch,\nConfirmation date of confirmed orders.", default=fields.Datetime.now, ) - validity_date = fields.Date( - string="Expiration", - compute="_compute_validity_date", - inverse="_inverse_validity_date", - store=True, - readonly=False, - copy=False, - precompute=True, - states=READONLY_FIELD_STATES, - ) sale_order_ids = fields.One2many("sale.order", "batch_id") sale_order_count = fields.Integer(compute="_compute_sale_order_count") sale_order_line_ids = fields.Many2many("sale.order.line", compute="_compute_sale_order_line_ids", store=True) @@ -66,28 +54,6 @@ class SaleOrderBatch(models.Model): product_count = fields.Integer(compute="_compute_product_count") partner_credit_warning = fields.Text(compute="_compute_partner_credit_warning") - @api.depends("company_id") - def _compute_validity_date(self): - enabled_feature = bool(self.env["ir.config_parameter"].sudo().get_param("sale.use_quotation_validity_days")) - if not enabled_feature: - self.validity_date = False - return - today = fields.Date.context_today(self) - for batch in self: - days = batch.company_id.quotation_validity_days - if days > 0: - batch.validity_date = today + timedelta(days) - else: - batch.validity_date = False - - def _inverse_validity_date(self): - """ - Set validity date on all Sale Orders - """ - for batch in self: - for order in batch.sale_order_ids: - order.validity_date = batch.validity_date - @api.depends("sale_order_ids.order_line") def _compute_sale_order_line_ids(self): for batch in self: diff --git a/sale_order_batch/readme/HISTORY.rst b/sale_order_batch/readme/HISTORY.rst index a906313..ba8435e 100644 --- a/sale_order_batch/readme/HISTORY.rst +++ b/sale_order_batch/readme/HISTORY.rst @@ -1,4 +1,5 @@ :0.0.1: Initial module. :1.0.0: Add Multi Company ability :1.0.1: rename product creation methode -:1.1.0: Make validity_date persistent, add batches to SO views \ No newline at end of file +:1.1.0: Make validity_date persistent, add batches to SO views +:1.1.1: Remove validity date diff --git a/sale_order_batch/static/description/index.html b/sale_order_batch/static/description/index.html index 59438f4..03f9c90 100644 --- a/sale_order_batch/static/description/index.html +++ b/sale_order_batch/static/description/index.html @@ -400,6 +400,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation 1.1.0:Make validity_date persistent, add batches to SO views +1.1.1:Remove validity date + diff --git a/sale_order_batch/views/sale_order_batch_views.xml b/sale_order_batch/views/sale_order_batch_views.xml index fc79bf2..7c4a930 100644 --- a/sale_order_batch/views/sale_order_batch_views.xml +++ b/sale_order_batch/views/sale_order_batch_views.xml @@ -7,7 +7,6 @@ - @@ -92,7 +91,6 @@ -