I am trying to create quotation based on order request, While select the order request number, those requested products has to append in order lines of quotation.
I tried the following code it works, It returned correct product id. but while display in one2many
field the product is different, I given print option before return it shows correct product.
def request_change(self, req_id):
print req_id
vals=[]
refunds = self.env['purchase.request.products'].search([('request_id', '=', req_id)])
for recs in refunds:
print recs.name.name
print recs.name.id
vals.append({'product_id':recs.id,'name':recs.name.name,'product_qty':1.000,'date_planned':datetime.now().strftime("%Y-%m-%d %H:%M:%S"),'price_unit':recs.name.list_price})
print vals
return {'value': {'order_line':vals }}
Correct format of One2many write:
(0,0, {}) or (0, False, {})
For example:
'order_line': [(0,0, {'product_id': 1, 'name': 'Test1'}).....]
Try with following code.
def request_change(self, req_id):
print req_id
vals=[]
refunds = self.env['purchase.request.products'].search([('request_id', '=', req_id)])
for recs in refunds:
vals.append([0,0, {'product_id':recs.id,'name':recs.name.name,'product_qty':1.000,'date_planned':datetime.now().strftime("%Y-%m-%d %H:%M:%S"),'price_unit':recs.name.list_price}])
return {'value': {'order_line':vals }}