diff --git a/sale_automatic_workflow/__manifest__.py b/sale_automatic_workflow/__manifest__.py index 2afbc5fdaa3..40180d2ad72 100644 --- a/sale_automatic_workflow/__manifest__.py +++ b/sale_automatic_workflow/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Sale Automatic Workflow", - "version": "16.0.1.0.2", + "version": "17.0.1.0.0", "category": "Sales Management", "license": "AGPL-3", "author": "Akretion, " diff --git a/sale_automatic_workflow/data/automatic_workflow_data.xml b/sale_automatic_workflow/data/automatic_workflow_data.xml index d016c54e6d0..efa171a447f 100644 --- a/sale_automatic_workflow/data/automatic_workflow_data.xml +++ b/sale_automatic_workflow/data/automatic_workflow_data.xml @@ -23,7 +23,7 @@ sale.order [('state','in',['sale','done']),('invoice_status','=','to invoice')] + >[('state','=','sale'),('invoice_status','=','to invoice')] diff --git a/sale_automatic_workflow/models/automatic_workflow_job.py b/sale_automatic_workflow/models/automatic_workflow_job.py index 216c81dd05e..d514a296358 100644 --- a/sale_automatic_workflow/models/automatic_workflow_job.py +++ b/sale_automatic_workflow/models/automatic_workflow_job.py @@ -131,18 +131,17 @@ def _validate_pickings(self, picking_filter): self._do_validate_picking(picking, picking_filter) def _do_sale_done(self, sale, domain_filter): - """Set a sales order to done, filter ensure no duplication""" + """Lock a sales order, filter ensure no duplication""" if not self.env["sale.order"].search_count( [("id", "=", sale.id)] + domain_filter ): return f"{sale.display_name} {sale} job bypassed" - sale.action_done() - return f"{sale.display_name} {sale} set done successfully" + sale.action_lock() + return f"{sale.display_name} {sale} locked successfully" @api.model def _sale_done(self, sale_done_filter): - sale_obj = self.env["sale.order"] - sales = sale_obj.search(sale_done_filter) + sales = self.env["sale.order"].search(sale_done_filter) _logger.debug("Sale Orders to done: %s", sales.ids) for sale in sales: with savepoint(self.env.cr): diff --git a/sale_automatic_workflow/models/stock_picking.py b/sale_automatic_workflow/models/stock_picking.py index e6a01f77017..bcbbccfe5db 100644 --- a/sale_automatic_workflow/models/stock_picking.py +++ b/sale_automatic_workflow/models/stock_picking.py @@ -19,18 +19,18 @@ def validate_picking(self): for picking in self: picking.action_assign() for move in picking.move_ids.filtered( - lambda m: m.state not in ["done", "cancel"] + lambda m: m.picked and m.state not in ["done", "cancel"] ): rounding = move.product_id.uom_id.rounding if ( float_compare( - move.quantity_done, + move.quantity, move.product_qty, precision_rounding=rounding, ) == -1 ): for move_line in move.move_line_ids: - move_line.qty_done = move_line.reserved_uom_qty + move_line.quantity = move_line.quantity_product_uom picking.with_context(skip_immediate=True, skip_sms=True).button_validate() return True diff --git a/sale_automatic_workflow/tests/test_multicompany.py b/sale_automatic_workflow/tests/test_multicompany.py index 1d51f8c147c..0b5e29d9679 100644 --- a/sale_automatic_workflow/tests/test_multicompany.py +++ b/sale_automatic_workflow/tests/test_multicompany.py @@ -1,20 +1,12 @@ # Copyright 2017 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from odoo.tests import tagged -from .common import TestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon @tagged("post_install", "-at_install") -class TestMultiCompany(TestCommon): - def setUp(self): - super().setUp() - - @classmethod - def create_company(cls, values): - return cls.env["res.company"].create(values) - +class TestMultiCompany(AccountTestInvoicingCommon): @classmethod def create_product(cls, values): values.update({"type": "consu", "invoice_policy": "order"}) @@ -22,7 +14,7 @@ def create_product(cls, values): return product_template.product_variant_id @classmethod - def setUpClass(cls): + def setUpClass(cls, chart_template_ref=None): super().setUpClass() cls.env = cls.env( context=dict( @@ -34,38 +26,37 @@ def setUpClass(cls): _job_force_sync=True, ) ) - coa = cls.env.user.company_id.chart_template_id - cls.company_fr = cls.create_company( + cls.company_fr = cls.setup_company_data( { "name": "French company", "currency_id": cls.env.ref("base.EUR").id, "country_id": cls.env.ref("base.fr").id, } - ) + )["company"] - cls.company_ch = cls.create_company( + cls.company_ch = cls.setup_company_data( { "name": "Swiss company", "currency_id": cls.env.ref("base.CHF").id, "country_id": cls.env.ref("base.ch").id, } - ) + )["company"] - cls.company_be = cls.create_company( + cls.company_be = cls.setup_company_data( { "name": "Belgian company", "currency_id": cls.env.ref("base.EUR").id, "country_id": cls.env.ref("base.be").id, } - ) + )["company"] - cls.company_fr_daughter = cls.create_company( + cls.company_fr_daughter = cls.setup_company_data( { "name": "French company daughter", "currency_id": cls.env.ref("base.EUR").id, "country_id": cls.env.ref("base.fr").id, } - ) + )["company"] cls.env.user.company_ids |= cls.company_fr cls.env.user.company_ids |= cls.company_ch @@ -73,7 +64,6 @@ def setUpClass(cls): cls.env.user.company_ids |= cls.company_fr_daughter cls.env.user.company_id = cls.company_fr.id - coa.try_loading(company=cls.env.user.company_id) cls.customer_fr = ( cls.env["res.partner"] .with_context(default_company_id=cls.company_fr.id) @@ -82,14 +72,13 @@ def setUpClass(cls): cls.product_fr = cls.create_product({"name": "Evian bottle", "list_price": 2.0}) cls.env.user.company_id = cls.company_ch.id - coa.try_loading(company=cls.env.user.company_id) + cls.customer_ch = cls.env["res.partner"].create({"name": "Customer CH"}) cls.product_ch = cls.create_product( {"name": "Henniez bottle", "list_price": 3.0} ) cls.env.user.company_id = cls.company_be.id - coa.try_loading(company=cls.env.user.company_id) cls.customer_be = cls.env["res.partner"].create({"name": "Customer BE"}) cls.product_be = ( cls.env["product.template"] @@ -105,7 +94,6 @@ def setUpClass(cls): ) cls.env.user.company_id = cls.company_fr_daughter.id - coa.try_loading(company=cls.env.user.company_id) cls.customer_fr_daughter = cls.env["res.partner"].create( {"name": "Customer FR Daughter"} ) diff --git a/sale_automatic_workflow/views/sale_workflow_process_view.xml b/sale_automatic_workflow/views/sale_workflow_process_view.xml index b4b9bb890ec..d77b5008c38 100644 --- a/sale_automatic_workflow/views/sale_workflow_process_view.xml +++ b/sale_automatic_workflow/views/sale_workflow_process_view.xml @@ -56,15 +56,17 @@