From 54fad5ff4c3b345af0489a5baec91cd77a6bc7c8 Mon Sep 17 00:00:00 2001 From: Rad0van Date: Thu, 8 Jun 2023 18:22:40 +0200 Subject: [PATCH] [MIG] product_contract: Migration to 16.0 --- product_contract/__manifest__.py | 2 +- product_contract/models/contract_line.py | 4 ++-- product_contract/models/product_template.py | 2 +- product_contract/models/sale_order_line.py | 16 +++++----------- product_contract/tests/test_product.py | 4 ++-- product_contract/tests/test_sale_order.py | 6 +++--- 6 files changed, 14 insertions(+), 20 deletions(-) diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index 2214c6b34a..9275ab61c5 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Recurring - Product Contract", - "version": "14.0.1.0.1", + "version": "16.0.1.0.0", "category": "Contract Management", "license": "AGPL-3", "author": "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py index 91c08480a0..318885af6b 100644 --- a/product_contract/models/contract_line.py +++ b/product_contract/models/contract_line.py @@ -17,8 +17,8 @@ class ContractLine(models.Model): copy=False, ) - def _prepare_invoice_line(self, move_form): - res = super(ContractLine, self)._prepare_invoice_line(move_form) + def _prepare_invoice_line(self): + res = super(ContractLine, self)._prepare_invoice_line() if self.sale_order_line_id and res: res["sale_line_ids"] = [(6, 0, [self.sale_order_line_id.id])] return res diff --git a/product_contract/models/product_template.py b/product_contract/models/product_template.py index 12bbeda64f..d55804b2e2 100644 --- a/product_contract/models/product_template.py +++ b/product_contract/models/product_template.py @@ -68,7 +68,7 @@ def write(self, vals): self.with_company(company).write( {"property_contract_template_id": False} ) - super().write(vals) + return super().write(vals) @api.constrains("is_contract", "type") def _check_contract_product_type(self): diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index 038dd6d6f8..6e6df1fc6f 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -43,8 +43,8 @@ class SaleOrderLine(models.Model): help="Specify if process date is 'from' or 'to' invoicing date", copy=False, ) - date_start = fields.Date(string="Date Start") - date_end = fields.Date(string="Date End") + date_start = fields.Date() + date_end = fields.Date() contract_line_id = fields.Many2one( comodel_name="contract.line", @@ -269,17 +269,11 @@ def invoice_line_create(self, invoice_id, qty): SaleOrderLine, self.filtered(lambda l: not l.contract_id) ).invoice_line_create(invoice_id, qty) - @api.depends( - "qty_invoiced", - "qty_delivered", - "product_uom_qty", - "order_id.state", - "product_id.is_contract", - ) - def _get_to_invoice_qty(self): + @api.depends("qty_invoiced", "qty_delivered", "product_uom_qty", "state") + def _compute_qty_to_invoice(self): """ sale line linked to contracts must not be invoiced from sale order """ - res = super()._get_to_invoice_qty() + res = super()._compute_qty_to_invoice() self.filtered("product_id.is_contract").update({"qty_to_invoice": 0.0}) return res diff --git a/product_contract/tests/test_product.py b/product_contract/tests/test_product.py index c5b2c9912c..d5f1c767a4 100644 --- a/product_contract/tests/test_product.py +++ b/product_contract/tests/test_product.py @@ -3,10 +3,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo.exceptions import ValidationError -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestProductTemplate(SavepointCase): +class TestProductTemplate(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/product_contract/tests/test_sale_order.py b/product_contract/tests/test_sale_order.py index 804863f990..7415876db6 100644 --- a/product_contract/tests/test_sale_order.py +++ b/product_contract/tests/test_sale_order.py @@ -6,10 +6,10 @@ from odoo.exceptions import UserError, ValidationError from odoo.fields import Date -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestSaleOrder(SavepointCase): +class TestSaleOrder(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -342,7 +342,7 @@ def test_check_contact_is_not_terminated_1(self): self.order_line1.contract_id = self.contract self.sale.action_confirm() self.contract.is_terminated = True - self.sale.action_cancel() + self.sale._action_cancel() with self.assertRaises(ValidationError): self.sale.action_draft() self.contract.is_terminated = False