Skip to content

Commit

Permalink
Merge branch '14.0' into TA#65030_14
Browse files Browse the repository at this point in the history
  • Loading branch information
lanto-razafindrabe committed May 24, 2024
2 parents e1d346a + 0e01a97 commit e61df64
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 58 deletions.
6 changes: 6 additions & 0 deletions gitoo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
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: 10 additions & 13 deletions sale_dynamic_price/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@

{
"name": "Sale Dynamic Price",
'version': '14.0.1.0.0',
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://bit.ly/numigi-com',
'license': 'LGPL-3',
"version": "14.0.1.0.1",
"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',
],
"depends": ["base_view_inheritance_extension", "product", "queue_job_cron"],
"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: 8 additions & 0 deletions sale_dynamic_price/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?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 @@ -9,6 +14,9 @@
<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: 10 additions & 1 deletion sale_dynamic_price/tests/test_dynamic_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ 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 @@ -73,7 +82,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: 8 additions & 0 deletions sale_rental/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<?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: 9 additions & 0 deletions sale_rental/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ 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.1',
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://bit.ly/numigi-com',
'license': 'LGPL-3',
"version": "14.0.1.1.2",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "LGPL-3",
"category": "Sales",
"summary": "Manage warranties on sales",
"depends": ['sale_stock'],
"depends": ["sale_stock", "queue_job_cron"],
"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: 8 additions & 0 deletions sale_warranty/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<?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: 44 additions & 27 deletions sale_warranty/tests/test_expired_warranties_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,67 @@ class ExpiredWarrantiesCronCase(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
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)]
})

# 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.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"
21 changes: 21 additions & 0 deletions sale_warranty_lead_on_expiry/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"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",
"category": "Sales",
"summary": "Generate a lead when a sale warranty expires",
"depends": ["sale_warranty", "crm", "queue_job_cron"],
"data": [
"data/ir_cron.xml",
"views/config_settings.xml",
"views/warranty_to_lead_link_message.xml",
"views/warranty_type.xml",
],
"installable": True,
}
18 changes: 18 additions & 0 deletions sale_warranty_lead_on_expiry/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo noupdate="1">

<record id="lead_on_expiry_cron" model="ir.cron">
<field name="name">Sale Warranties: generate leads from 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="sale_warranty.channel_sale_warranty_ir_cron"/>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
<field name="state">code</field>
<field name="code">model.lead_on_expiry_cron()</field>
</record>

</odoo>
Loading

0 comments on commit e61df64

Please sign in to comment.