In version 7.0 we cant create lines at the time of onchange,because we cant take the current form id,but 8.0 we can call it as self.id
@api.multi
def onchange_task_id(self, task_id):
result = {}
k =[]
if task_id:
obj = self.env['project.task'].browse(task_id)
for material in obj.lease_facilities_lines:
vals = {
'order_id':self.id,
'product_id':material.product_id.id,
'name':material.product_id.name,
'price_unit':material.unit_price * material.hours,
'product_uom_qty':material.qty,
'od_date_from':material.from_date,
'od_date_to':material.to_date,
'product_uom':material.product_id.uom_id and material.product_id.uom_id.id,
'state': 'draft',
'od_month':material.hours
}
k.append(vals)
No comments:
Post a Comment