[FIX] industry_fsm: fix sale order issue when adding product without timesheet on tasks

The link between a sale_order and a task relied on a sale_line between the sale order and the tasks. This was working when allow timesheet and allow material were true, as we had a timesheet_product_id and the sale_line was created empty. But when we create a project with material but no timesheet, the sale line would crash.

Now the sale order and the sale line creation are split, and we write the sale order id on the tasks. This works because with the new ORM, we can write on a stored compute field, and if we take care of not overwriting it in the compute, it stays at what we wrote.

task-2047389		closes-5388
This commit is contained in:
MaxLarue
2019-09-18 12:05:19 +00:00
committed by Geoffroy Larue
parent 8ed94a11f4
commit 740d2f2617
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -147,7 +147,7 @@ class ProjectTask(models.Model):
help="Sales order item to which the task is linked. If an employee timesheets on a this task, "
"and if this employee is not in the 'Employee/Sales Order Item Mapping' of the project, the "
"timesheet entry will be linked to this sales order item.", copy=False)
sale_order_id = fields.Many2one('sale.order', 'Sales Order', compute='_compute_sale_order_id', compute_sudo=True, store=True, readonly=True, help="Sales order to which the task is linked.")
sale_order_id = fields.Many2one('sale.order', 'Sales Order', compute='_compute_sale_order_id', store=True, readonly=False, help="Sales order to which the task is linked.")
billable_type = fields.Selection([
('task_rate', 'At Task Rate'),
('employee_rate', 'At Employee Rate'),
@@ -50,8 +50,9 @@
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': ['|', ('partner_id', '=', False)]}" options='{"no_open": True}' readonly="1" context="{'create': False, 'edit': False, 'delete': False}"/>
<field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': ['|', ('partner_id', '=', False), '&amp;', ('sale_order_id', '!=', False), ('sale_line_id', '=', False)]}" options='{"no_open": True}' readonly="1" context="{'create': False, 'edit': False, 'delete': False}"/>
<field name="billable_type" invisible="1"/>
<field name="sale_order_id" invisible="1" />
</field>
</field>
</record>