From 4be9ab662cf7cb330721e3aeda8b8a367b3ba426 Mon Sep 17 00:00:00 2001 From: matiasperalta1 Date: Thu, 17 Nov 2022 11:18:26 -0300 Subject: [PATCH] [MIG] sale_exception: Migration to 16.0 --- sale_exception/__manifest__.py | 2 +- sale_exception/data/sale_exception_data.xml | 7 ++++--- sale_exception/models/sale.py | 11 ++++++----- sale_exception/tests/test_sale_exception.py | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sale_exception/__manifest__.py b/sale_exception/__manifest__.py index bf2b8fbcabf..293fee44d20 100644 --- a/sale_exception/__manifest__.py +++ b/sale_exception/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Sale Exception", "summary": "Custom exceptions on sale order", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "category": "Generic Modules/Sale", "author": "Akretion, " "Sodexis, " diff --git a/sale_exception/data/sale_exception_data.xml b/sale_exception/data/sale_exception_data.xml index 15992da6f92..671d93ee67c 100644 --- a/sale_exception/data/sale_exception_data.xml +++ b/sale_exception/data/sale_exception_data.xml @@ -26,8 +26,9 @@ Not Enough Virtual Stock 50 sale.order.line - failed=self.product_id and self.product_id.type == 'product' - and self.virtual_available_at_date < self.product_uom_qty + failed=self.product_id and self.product_id.type == 'product' and self.virtual_available_at_date < self.product_uom_qty @@ -43,7 +44,7 @@ The product has a warning in his form 40 sale.order.line - failed=self.product_id.sale_line_warn == "warning" + failed=self.sale_line_warn == "warning" diff --git a/sale_exception/models/sale.py b/sale_exception/models/sale.py index ae6f9a67fef..e68e08279bd 100644 --- a/sale_exception/models/sale.py +++ b/sale_exception/models/sale.py @@ -53,11 +53,12 @@ def _check_sale_check_exception(self, vals): if check_exceptions: self.sale_check_exception() - @api.model - def create(self, vals): - record = super().create(vals) - record._check_sale_check_exception(vals) - return record + @api.model_create_multi + def create(self, vals_list): + records = super().create(vals_list) + for record, vals in zip(records, vals_list): + record._check_sale_check_exception(vals) + return records def write(self, vals): result = super().write(vals) diff --git a/sale_exception/tests/test_sale_exception.py b/sale_exception/tests/test_sale_exception.py index 3fd33d1a950..a3f901a6e73 100644 --- a/sale_exception/tests/test_sale_exception.py +++ b/sale_exception/tests/test_sale_exception.py @@ -168,7 +168,7 @@ def test_exception_product_sale_warning(self): partner=self.env.ref("base.res_partner_1"), product=product ) sale_order.action_confirm() - product.sale_line_warn = "warning" + self.sale_line_warn = "warning" sale_order2 = sale_order.copy() sale_order2.detect_exceptions() self.assertTrue(sale_order2.exception_ids.filtered(lambda x: x == exception))