Update project.py
This commit is contained in:
parent
566af84926
commit
05d3290bfd
|
|
@ -233,17 +233,24 @@ class Project(models.Model):
|
||||||
"""
|
"""
|
||||||
line_ids = []
|
line_ids = []
|
||||||
res = super(Project, self).write(vals)
|
res = super(Project, self).write(vals)
|
||||||
if self.type != 'internal' and vals.get('project_phase_ids') and self.invoice_method == 'per_stage':
|
for project in self:
|
||||||
phase_ids = self.invoice_ids.mapped('phase_id').ids
|
if project.type != 'internal' and vals.get('project_phase_ids') and project.invoice_method == 'per_stage':
|
||||||
for line in self.sudo().sale_order_id.order_line:
|
line_ids = []
|
||||||
line_ids.append(
|
phase_ids = project.invoice_ids.mapped('phase_id').ids
|
||||||
(0, 0,
|
for line in project.sudo().sale_order_id.order_line:
|
||||||
{'order_line_id': line.id, 'product_id': line.product_id.id, 'product_uom': line.product_uom.id,
|
line_ids.append((0, 0, {
|
||||||
'price_unit': line.price_unit, 'discount': line.discount, 'tax_id': [(6, 0, line.tax_id.ids)]}))
|
'order_line_id': line.id,
|
||||||
self.invoice_ids = [(0, 0,
|
'product_id': line.product_id.id,
|
||||||
{'name': phase.display_name, 'phase_id': phase.id, 'project_invline_ids': line_ids})
|
'product_uom': line.product_uom.id,
|
||||||
for phase in
|
'price_unit': line.price_unit,
|
||||||
self.project_phase_ids.filtered(lambda x: x.id not in phase_ids)]
|
'discount': line.discount,
|
||||||
|
'tax_id': [(6, 0, line.tax_id.ids)],
|
||||||
|
}))
|
||||||
|
project.invoice_ids = [(0, 0, {
|
||||||
|
'name': phase.display_name,
|
||||||
|
'phase_id': phase.id,
|
||||||
|
'project_invline_ids': line_ids,
|
||||||
|
}) for phase in project.project_phase_ids.filtered(lambda x: x.id not in phase_ids)]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue