From 22f3e9123873aae76541013016b24aa7e38d9ea2 Mon Sep 17 00:00:00 2001 From: Majda EL MARIOULI Date: Thu, 13 Jun 2024 14:12:21 -0400 Subject: [PATCH] Revert "TA#60956 [CHG] Run Cron As Queue Job (#377)" This reverts commit 0e01a977d14b12e6f0ae27b2836a3647c52d3874. --- gitoo.yml | 6 -- sale_dynamic_price/__manifest__.py | 23 ++--- sale_dynamic_price/data/ir_cron.xml | 8 -- .../tests/test_dynamic_price.py | 11 +-- sale_rental/data/ir_cron.xml | 8 -- sale_rental/tests/common.py | 9 -- sale_warranty/__manifest__.py | 34 +++---- sale_warranty/data/ir_cron.xml | 8 -- .../tests/test_expired_warranties_cron.py | 71 ++++++--------- sale_warranty_lead_on_expiry/__manifest__.py | 20 ++--- sale_warranty_lead_on_expiry/data/ir_cron.xml | 3 - .../tests/test_lead_on_expiry_cron.py | 89 ++++++++----------- 12 files changed, 104 insertions(+), 186 deletions(-) diff --git a/gitoo.yml b/gitoo.yml index f99e482c..92d72423 100644 --- a/gitoo.yml +++ b/gitoo.yml @@ -116,12 +116,6 @@ includes: - date_range -- url: https://github.com/OCA/queue - branch: "14.0" - includes: - - queue_job - - queue_job_cron - - url: https://github.com/OCA/web branch: "14.0" includes: diff --git a/sale_dynamic_price/__manifest__.py b/sale_dynamic_price/__manifest__.py index 53d7aa9c..2b3198bf 100644 --- a/sale_dynamic_price/__manifest__.py +++ b/sale_dynamic_price/__manifest__.py @@ -3,19 +3,22 @@ { "name": "Sale Dynamic Price", - "version": "14.0.1.0.1", - "author": "Numigi", - "maintainer": "Numigi", - "website": "https://bit.ly/numigi-com", - "license": "LGPL-3", + 'version': '14.0.1.0.0', + 'author': 'Numigi', + 'maintainer': 'Numigi', + 'website': 'https://bit.ly/numigi-com', + 'license': 'LGPL-3', "category": "Sales", "summary": "Compute sale prices based on product cost", - "depends": ["base_view_inheritance_extension", "product", "queue_job_cron"], + "depends": [ + 'base_view_inheritance_extension', + 'product', + ], "data": [ - "views/product_template.xml", - "views/product_product.xml", - "views/product_template_attribute_value.xml", - "data/ir_cron.xml", + 'views/product_template.xml', + 'views/product_product.xml', + 'views/product_template_attribute_value.xml', + 'data/ir_cron.xml', ], "installable": True, } diff --git a/sale_dynamic_price/data/ir_cron.xml b/sale_dynamic_price/data/ir_cron.xml index 1f191045..4ce1bc89 100644 --- a/sale_dynamic_price/data/ir_cron.xml +++ b/sale_dynamic_price/data/ir_cron.xml @@ -1,11 +1,6 @@ - - product_product.ir_cron - - - Update dynamic sale prices on products @@ -14,9 +9,6 @@ 1 weeks - - - -1 diff --git a/sale_dynamic_price/tests/test_dynamic_price.py b/sale_dynamic_price/tests/test_dynamic_price.py index 4d723733..63e54bfe 100644 --- a/sale_dynamic_price/tests/test_dynamic_price.py +++ b/sale_dynamic_price/tests/test_dynamic_price.py @@ -11,15 +11,6 @@ class TestDynamicPrice(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() - - # Set queue job to no delay for testing - cls.env = cls.env( - context=dict( - cls.env.context, - test_queue_job_no_delay=True, - ) - ) - vals_list = { "name": "Product A", "type": "product", @@ -82,7 +73,7 @@ def test_compute_margin_amount(self, data_): ) @unpack def test_update_sale_price_from_cost( - self, cost, margin, rounding, surcharge, expected_price + self, cost, margin, rounding, surcharge, expected_price ): self.product.write( { diff --git a/sale_rental/data/ir_cron.xml b/sale_rental/data/ir_cron.xml index ec27ea6d..bd417585 100644 --- a/sale_rental/data/ir_cron.xml +++ b/sale_rental/data/ir_cron.xml @@ -1,20 +1,12 @@ - - sale_order_line.ir_cron - - - Update the delivered quantity on sale order lines of type rental service code model.update_rental_service_qty_delivered_cron() - - - 12 hours -1 diff --git a/sale_rental/tests/common.py b/sale_rental/tests/common.py index 9eb1b822..d48801bd 100644 --- a/sale_rental/tests/common.py +++ b/sale_rental/tests/common.py @@ -8,15 +8,6 @@ class RentalCase(KitCase): @classmethod def setUpClass(cls): super().setUpClass() - - # Set queue job to no delay for testing - cls.env = cls.env( - context=dict( - cls.env.context, - test_queue_job_no_delay=True, - ) - ) - cls.stock_user = cls.env.ref("base.user_demo") cls.stock_user.groups_id = cls.env.ref("stock.group_stock_user") diff --git a/sale_warranty/__manifest__.py b/sale_warranty/__manifest__.py index e37a09fe..97c30330 100644 --- a/sale_warranty/__manifest__.py +++ b/sale_warranty/__manifest__.py @@ -3,27 +3,27 @@ { "name": "Sales Warranty", - "version": "14.0.1.1.2", - "author": "Numigi", - "maintainer": "Numigi", - "website": "https://bit.ly/numigi-com", - "license": "LGPL-3", + 'version': '14.0.1.1.1', + 'author': 'Numigi', + 'maintainer': 'Numigi', + 'website': 'https://bit.ly/numigi-com', + 'license': 'LGPL-3', "category": "Sales", "summary": "Manage warranties on sales", - "depends": ["sale_stock", "queue_job_cron"], + "depends": ['sale_stock'], "data": [ - "security/groups.xml", - "security/rules.xml", - "security/ir.model.access.csv", - "views/menu.xml", - "views/config_settings.xml", - "views/warranty_type.xml", - "views/warranty.xml", - "views/product.xml", - "views/sale_order.xml", + 'security/groups.xml', + 'security/rules.xml', + 'security/ir.model.access.csv', + 'views/menu.xml', + 'views/config_settings.xml', + 'views/warranty_type.xml', + 'views/warranty.xml', + 'views/product.xml', + 'views/sale_order.xml', "views/stock_production_lot.xml", - "data/ir_cron.xml", - "data/ir_sequence.xml", + 'data/ir_cron.xml', + 'data/ir_sequence.xml', ], "installable": True, "application": True, diff --git a/sale_warranty/data/ir_cron.xml b/sale_warranty/data/ir_cron.xml index fe3b2c2c..6be8a9df 100644 --- a/sale_warranty/data/ir_cron.xml +++ b/sale_warranty/data/ir_cron.xml @@ -1,19 +1,11 @@ - - sale_warranty.ir_cron - - - Sale Warranties: update status of expired warranties 1 days - - - -1 code diff --git a/sale_warranty/tests/test_expired_warranties_cron.py b/sale_warranty/tests/test_expired_warranties_cron.py index 1122a32e..5cc7bbb0 100644 --- a/sale_warranty/tests/test_expired_warranties_cron.py +++ b/sale_warranty/tests/test_expired_warranties_cron.py @@ -10,52 +10,35 @@ class ExpiredWarrantiesCronCase(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() - - # Set queue job to no delay for testing - cls.env = cls.env( - context=dict( - cls.env.context, - test_queue_job_no_delay=True, - ) - ) - - cls.customer = cls.env["res.partner"].create( - { - "name": "My Customer", - } - ) - - cls.warranty_6_months = cls.env["sale.warranty.type"].create( - { - "name": "6 Months Parts", - "duration_in_months": 6, - "description": "Warranted 6 months on parts", - } - ) - - cls.product_a = cls.env["product.product"].create( - { - "name": "My Product", - "tracking": "serial", - "type": "product", - "warranty_type_ids": [(4, cls.warranty_6_months.id)], - } - ) + cls.customer = cls.env['res.partner'].create({ + 'name': 'My Customer', + }) + + cls.warranty_6_months = cls.env['sale.warranty.type'].create({ + 'name': '6 Months Parts', + 'duration_in_months': 6, + 'description': 'Warranted 6 months on parts' + }) + + cls.product_a = cls.env['product.product'].create({ + 'name': 'My Product', + 'tracking': 'serial', + 'type': 'product', + 'warranty_type_ids': [(4, cls.warranty_6_months.id)] + }) cls.today = datetime.now().date() - cls.warranty = cls.env["sale.warranty"].create( - { - "partner_id": cls.customer.id, - "product_id": cls.product_a.id, - "type_id": cls.warranty_6_months.id, - "state": "active", - "activation_date": cls.today - timedelta(90), - } - ) + cls.warranty = cls.env['sale.warranty'].create({ + 'partner_id': cls.customer.id, + 'product_id': cls.product_a.id, + 'type_id': cls.warranty_6_months.id, + 'state': 'active', + 'activation_date': cls.today - timedelta(90), + }) def run_cron(self): - self.env.ref("sale_warranty.expired_warranties_cron").method_direct_trigger() + self.env.ref('sale_warranty.expired_warranties_cron').method_direct_trigger() class TestExpiredWarrantiesCron(ExpiredWarrantiesCronCase): @@ -63,14 +46,14 @@ class TestExpiredWarrantiesCron(ExpiredWarrantiesCronCase): def test_if_expiration_date_after_today_then_warranty_active(self): self.warranty.expiry_date = self.today + timedelta(1) self.run_cron() - assert self.warranty.state == "active" + assert self.warranty.state == 'active' def test_if_expiration_date_is_today_then_warranty_active(self): self.warranty.expiry_date = self.today self.run_cron() - assert self.warranty.state == "active" + assert self.warranty.state == 'active' def test_if_expiration_date_before_today_then_warranty_expired(self): self.warranty.expiry_date = self.today - timedelta(1) self.run_cron() - assert self.warranty.state == "expired" + assert self.warranty.state == 'expired' diff --git a/sale_warranty_lead_on_expiry/__manifest__.py b/sale_warranty_lead_on_expiry/__manifest__.py index 7a5a245a..e0e55169 100644 --- a/sale_warranty_lead_on_expiry/__manifest__.py +++ b/sale_warranty_lead_on_expiry/__manifest__.py @@ -3,19 +3,19 @@ { "name": "Sales Warranty Lead On Expiry", - "version": "14.0.1.0.1", - "author": "Numigi", - "maintainer": "Numigi", - "website": "https://bit.ly/numigi-com", - "license": "LGPL-3", + 'version': '14.0.1.0.0', + 'author': 'Numigi', + 'maintainer': 'Numigi', + 'website': 'https://bit.ly/numigi-com', + 'license': 'LGPL-3', "category": "Sales", "summary": "Generate a lead when a sale warranty expires", - "depends": ["sale_warranty", "crm", "queue_job_cron"], + "depends": ['sale_warranty', 'crm'], "data": [ - "data/ir_cron.xml", - "views/config_settings.xml", - "views/warranty_to_lead_link_message.xml", - "views/warranty_type.xml", + 'data/ir_cron.xml', + 'views/config_settings.xml', + 'views/warranty_to_lead_link_message.xml', + 'views/warranty_type.xml', ], "installable": True, } diff --git a/sale_warranty_lead_on_expiry/data/ir_cron.xml b/sale_warranty_lead_on_expiry/data/ir_cron.xml index 279437b3..69f19367 100644 --- a/sale_warranty_lead_on_expiry/data/ir_cron.xml +++ b/sale_warranty_lead_on_expiry/data/ir_cron.xml @@ -6,9 +6,6 @@ 1 days - - - -1 code diff --git a/sale_warranty_lead_on_expiry/tests/test_lead_on_expiry_cron.py b/sale_warranty_lead_on_expiry/tests/test_lead_on_expiry_cron.py index 6033f6c0..6963f865 100644 --- a/sale_warranty_lead_on_expiry/tests/test_lead_on_expiry_cron.py +++ b/sale_warranty_lead_on_expiry/tests/test_lead_on_expiry_cron.py @@ -12,65 +12,50 @@ class LeadOnExpiryCronCase(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() + cls.env.user.company_id.warranty_delay_between_leads = LEAD_DELAY - # Set queue job to no delay for testing - cls.env = cls.env( - context=dict( - cls.env.context, - test_queue_job_no_delay=True, - ) - ) + cls.customer = cls.env['res.partner'].create({ + 'name': 'My Customer' + }) - cls.env.user.company_id.warranty_delay_between_leads = LEAD_DELAY + cls.team = cls.env['crm.team'].create({'name': 'Team A'}) + + cls.warranty_6_months = cls.env['sale.warranty.type'].create({ + 'name': '6 Months Parts', + 'duration_in_months': 6, + 'description': 'Warranted 6 months on parts', + 'automated_action': True, + 'sales_team_id': cls.team.id, + 'automated_action_delay': 0, + }) - cls.customer = cls.env["res.partner"].create({"name": "My Customer"}) - - cls.team = cls.env["crm.team"].create({"name": "Team A"}) - - cls.warranty_6_months = cls.env["sale.warranty.type"].create( - { - "name": "6 Months Parts", - "duration_in_months": 6, - "description": "Warranted 6 months on parts", - "automated_action": True, - "sales_team_id": cls.team.id, - "automated_action_delay": 0, - } - ) - - cls.product_a = cls.env["product.product"].create( - { - "name": "My Product", - "tracking": "serial", - "type": "product", - } - ) + cls.product_a = cls.env['product.product'].create({ + 'name': 'My Product', + 'tracking': 'serial', + 'type': 'product', + }) cls.warranty = cls._create_warranty() @classmethod def _find_lead(cls): - return cls.env["crm.lead"].search([("partner_id", "=", cls.customer.id)]) + return cls.env['crm.lead'].search([('partner_id', '=', cls.customer.id)]) @classmethod def _run_cron(cls): - cls.env.ref( - "sale_warranty_lead_on_expiry.lead_on_expiry_cron" - ).method_direct_trigger() + cls.env.ref('sale_warranty_lead_on_expiry.lead_on_expiry_cron').method_direct_trigger() @classmethod def _create_warranty(cls): today = datetime.now().date() - return cls.env["sale.warranty"].create( - { - "partner_id": cls.customer.id, - "product_id": cls.product_a.id, - "type_id": cls.warranty_6_months.id, - "state": "active", - "activation_date": today - timedelta(90), - "expiry_date": today - timedelta(30), - } - ) + return cls.env['sale.warranty'].create({ + 'partner_id': cls.customer.id, + 'product_id': cls.product_a.id, + 'type_id': cls.warranty_6_months.id, + 'state': 'active', + 'activation_date': today - timedelta(90), + 'expiry_date': today - timedelta(30), + }) class TestLeadOnExpiryCron(LeadOnExpiryCronCase): @@ -114,7 +99,7 @@ def test_if_days_to_trigger_reached__new_lead_created(self): def test_generated_lead_type_is_opportunity(self): self._run_cron() lead = self._find_lead() - assert lead.type == "opportunity" + assert lead.type == 'opportunity' class TestWarrantiesWithExtension(LeadOnExpiryCronCase): @@ -128,14 +113,12 @@ class TestWarrantiesWithExtension(LeadOnExpiryCronCase): def setUpClass(cls): super().setUpClass() today = datetime.now().date() - cls.warranty.write( - { - "activation_date": today - timedelta(150), - "expiry_date": today - timedelta(120), - "extension_start_date": today + timedelta(60), - "extension_expiry_date": today + timedelta(90), - } - ) + cls.warranty.write({ + 'activation_date': today - timedelta(150), + 'expiry_date': today - timedelta(120), + 'extension_start_date': today + timedelta(60), + 'extension_expiry_date': today + timedelta(90), + }) def test_if_days_to_trigger_not_reached__no_lead_created(self): self.warranty_6_months.automated_action_delay = 89