Skip to content

Commit

Permalink
Revert "TA#60956 [CHG] Run Cron As Queue Job (#377)"
Browse files Browse the repository at this point in the history
This reverts commit 0e01a97.
  • Loading branch information
majouda authored Jun 13, 2024
1 parent c99523f commit 22f3e91
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 186 deletions.
6 changes: 0 additions & 6 deletions gitoo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 13 additions & 10 deletions sale_dynamic_price/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
8 changes: 0 additions & 8 deletions sale_dynamic_price/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo noupdate="1">

<record model="queue.job.channel" id="channel_product_product_ir_cron">
<field name="name">product_product.ir_cron</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>

<record id="sale_price_update_cron" model="ir.cron">
<field name="name">Update dynamic sale prices on products</field>
<field name="model_id" ref="product.model_product_product"/>
Expand All @@ -14,9 +9,6 @@
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">weeks</field>
<field name="run_as_queue_job" eval="True"/>
<field name="no_parallel_queue_job_run" eval="True"/>
<field name="channel_id" ref="channel_product_product_ir_cron"/>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
</record>
Expand Down
11 changes: 1 addition & 10 deletions sale_dynamic_price/tests/test_dynamic_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
{
Expand Down
8 changes: 0 additions & 8 deletions sale_rental/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo noupdate="1">

<record model="queue.job.channel" id="channel_sale_order_line_ir_cron">
<field name="name">sale_order_line.ir_cron</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>

<record id="rental_service_qty_delivered_update_cron" model="ir.cron">
<field name="name">Update the delivered quantity on sale order lines of type rental service</field>
<field name="model_id" ref="model_sale_order_line"/>
<field name="state">code</field>
<field name="code">model.update_rental_service_qty_delivered_cron()</field>
<field name="user_id" ref="base.user_root"/>
<field name="run_as_queue_job" eval="True"/>
<field name="no_parallel_queue_job_run" eval="True"/>
<field name="channel_id" ref="channel_sale_order_line_ir_cron"/>
<field name="interval_number">12</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
Expand Down
9 changes: 0 additions & 9 deletions sale_rental/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
34 changes: 17 additions & 17 deletions sale_warranty/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions sale_warranty/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo noupdate="1">

<record model="queue.job.channel" id="channel_sale_warranty_ir_cron">
<field name="name">sale_warranty.ir_cron</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>

<record id="expired_warranties_cron" model="ir.cron">
<field name="name">Sale Warranties: update status of expired warranties</field>
<field name="model_id" ref="model_sale_warranty"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="run_as_queue_job" eval="True"/>
<field name="no_parallel_queue_job_run" eval="True"/>
<field name="channel_id" ref="channel_sale_warranty_ir_cron"/>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
<field name="state">code</field>
Expand Down
71 changes: 27 additions & 44 deletions sale_warranty/tests/test_expired_warranties_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,50 @@ 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):

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'
20 changes: 10 additions & 10 deletions sale_warranty_lead_on_expiry/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
3 changes: 0 additions & 3 deletions sale_warranty_lead_on_expiry/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<field name="model_id" ref="model_sale_warranty"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="run_as_queue_job" eval="True"/>
<field name="no_parallel_queue_job_run" eval="True"/>
<field name="channel_id" ref="sale_warranty.channel_sale_warranty_ir_cron"/>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
<field name="state">code</field>
Expand Down
Loading

0 comments on commit 22f3e91

Please sign in to comment.