Skip to content
Snippets Groups Projects
Commit 8b3c3c08 authored by Jérome Maes's avatar Jérome Maes
Browse files

[FIX] sale_timesheet: sub task should have the same so line than its parent

And the SO item is readonly for sub task, to avoid
invoice twice the timesheet of a sub task.
parent 94e4f782
No related branches found
No related tags found
No related merge requests found
......@@ -58,8 +58,19 @@ class ProjectTask(models.Model):
sale_line_id = fields.Many2one('sale.order.line', 'Sales Order Item', domain="[('is_service', '=', True), ('order_partner_id', '=', partner_id)]")
@api.model
def create(self, values):
# sub task has the same so line than their parent
if 'parent_id' in values:
values['sale_line_id'] = self.env['project.task'].browse(values['parent_id']).sudo().sale_line_id.id
return super(ProjectTask, self).create(values)
@api.multi
def write(self, values):
# sub task has the same so line than their parent
if 'parent_id' in values:
values['sale_line_id'] = self.env['project.task'].browse(values['parent_id']).sudo().sale_line_id.id
result = super(ProjectTask, self).write(values)
# reassign SO line on related timesheet lines
if 'sale_line_id' in values:
......
......@@ -29,7 +29,7 @@
string="Sales Order"/>
</xpath>
<field name="user_id" position="after">
<field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': [('partner_id', '=', False)]}" options='{"no_open": True, "no_create": True}' context="{'sale_show_order_product_name': True}"/>
<field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': [('partner_id', '=', False)], 'readonly': [('parent_id', '!=', False)]}" options='{"no_open": True, "no_create": True}' context="{'sale_show_order_product_name': True}"/>
</field>
</field>
</record>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment