[FIX] sale_timesheet: change SO on project

The "Create Sales Order" button was not displayed again when the
original SO was deleted. Thus, it was not possible to link a new SO to
the project.

closes odoo/odoo#47397

Taskid: 2206862
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Kevin Baptiste
2020-03-18 14:09:01 +00:00
parent fd50ba9fb8
commit fad3ed7ce4
3 changed files with 8 additions and 2 deletions
+5
View File
@@ -97,6 +97,11 @@ class SaleOrder(models.Model):
}
return action
def write(self, values):
if 'state' in values and values['state'] == 'cancel':
self.project_id.sale_line_id = False
return super(SaleOrder, self).write(values)
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
+1
View File
@@ -53,6 +53,7 @@ class Project(models.Model):
@api.depends('billable_type', 'allow_billable', 'sale_order_id', 'partner_id')
def _compute_display_create_order(self):
for project in self:
project._compute_billable_type()
show = True
if not project.partner_id or project.billable_type != 'no' or project.allow_billable or project.sale_order_id:
show = False
@@ -14,8 +14,8 @@
<group>
<field name="display_create_order" invisible="1"/>
<field name="billable_type" invisible="1"/>
<field name="sale_order_id" attrs="{'invisible': [('billable_type', '=', 'no')]}"/>
<field name="sale_line_id" attrs="{'invisible': [('billable_type', '=', 'no')]}" context="{'create': False, 'edit': False, 'delete': False}"/>
<field name="sale_order_id" attrs="{'invisible': [('billable_type', '=', 'no')], 'readonly': [('sale_order_id', '!=', False)]}" context="{'default_partner_id': partner_id}"/>
<field name="sale_line_id" attrs="{'invisible': [('billable_type', '=', 'no')], 'readonly': [('sale_order_id', '=', False)]}" options="{'no_create': True, 'no_edit': True, 'delete': False}"/>
</group>
<field name="sale_line_employee_ids">
<tree editable="top">