Skip to content

Commit 33bfe96

Browse files
committed
[FIX] sale_project : create on order when type updated to service
Steps : Install Sales, Project and Inventory. Create a Storable Product. Create a SO with this product, but do not confirm it. Change this product : > Type : Service > Sales > Service Tracking : Create a task in SO's project Confirm the SO. Issue : Neither a delivery or a task is created. Cause : Confirming the SO calls SO._timesheet_service_generation(), which filtered its SOLs based on is_service to 'create on order'. As this field is not updated when changing the type of the product, the SOL with the service is filtered out. Fix : Update SOL_.is_service when changing SOL.product_id.type. opw-2786655 closes odoo#87042 X-original-commit: a38f544 Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
1 parent 11483a7 commit 33bfe96

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

addons/sale_project/models/sale_order.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ class SaleOrderLine(models.Model):
122122
index=True, copy=False, help="Task generated by the sales order item")
123123
is_service = fields.Boolean("Is a Service", compute='_compute_is_service', store=True, compute_sudo=True, help="Sales Order item should generate a task and/or a project, depending on the product settings.")
124124

125-
@api.depends('product_id')
125+
@api.depends('product_id.type')
126126
def _compute_is_service(self):
127127
for so_line in self:
128128
so_line.is_service = so_line.product_id.type == 'service'
129129

130-
@api.depends('product_id')
130+
@api.depends('product_id.type')
131131
def _compute_product_updatable(self):
132132
for line in self:
133133
if line.product_id.type == 'service' and line.state == 'sale':

addons/sale_project/tests/test_sale_project.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,24 @@ def test_sale_order_with_project_task(self):
139139
# service_tracking 'project_only'
140140
self.assertFalse(so_line_order_only_project.task_id, "Task should not be created")
141141
self.assertTrue(so_line_order_only_project.project_id, "Sales order line should be linked to newly created project")
142+
143+
def test_sol_product_type_update(self):
144+
partner = self.env['res.partner'].create({'name': "Mur en brique"})
145+
sale_order = self.env['sale.order'].with_context(tracking_disable=True).create({
146+
'partner_id': partner.id,
147+
'partner_invoice_id': partner.id,
148+
'partner_shipping_id': partner.id,
149+
})
150+
self.product_order_service3.type = 'consu'
151+
sale_order_line = self.env['sale.order.line'].create({
152+
'order_id': sale_order.id,
153+
'name': self.product_order_service3.name,
154+
'product_id': self.product_order_service3.id,
155+
'product_uom_qty': 5,
156+
'product_uom': self.product_order_service3.uom_id.id,
157+
'price_unit': self.product_order_service3.list_price
158+
})
159+
self.assertFalse(sale_order_line.is_service, "As the product is consumable, the SOL should not be a service")
160+
161+
self.product_order_service3.type = 'service'
162+
self.assertTrue(sale_order_line.is_service, "As the product is a service, the SOL should be a service")

0 commit comments

Comments
 (0)