in model sale.order.line the is function :
def product_id_change(self , cr ,uid ids ........):
well , what I've been trying to do is trigger this function in another method like :
@api.multi
def change2(self):
self.product_id_change(self.product2)
but its not working ! i got error : method take 6 arguments (6given ) so they told me that i should pass more arguments so i change i tried this :
self.product_id_change(
self.env.user.property_product_pricelist.id,
self.product_id.prod_replace.id,
qty=1,
qty_uos=1,
partner_id=self.order_id.partner_id.id,
date_order=self.order_id.date_order)
now i have no errors , and it execute the function but there is changes . it really need help here ! thnx
well in order to use product_id_change ! you dont need to pass all elements ,
def prod_change(self, cr, uid, ids, context=None): │
print "new traitement-----------------=======================" │
order_line = self.pool('sale.order.line') │
current_line = order_line.browse(cr, uid, │
ids[0], │
context=context) │
│
print current_line.id │
order_obj = self.pool.get('sale.order') │
order_id = order_obj.browse(cr, uid, │
current_line.order_id.id, │
context=context) │
print order_id │
order_lines = [] │
line_vals = self.product_id_change( │
cr, uid, 0, order_id.pricelist_id.id, │
current_line.product_id.prod_replace.id, │
partner_id=order_id.partner_id.id)['value'] │
│
line_vals.update( │
{'product_id': current_line.product_id.prod_replace.id}) │
print order_lines │
order_lines.append([1, ids[0], line_vals]) │
order_obj.write(cr, uid, │
order_id.id, │
{'order_line': order_lines}) │
│
return True
well , the dict return by :
product_id_change( │
cr, uid, 0, order_id.pricelist_id.id,
current_line.product_id.prod_replace.id,
partner_id=order_id.partner_id.id)['value']
we can use it to add new line or replace the same line use the correct id like in the code below :
order_lines.append([1, ids[0], line_vals])
order_obj.write(cr, uid,
order_id.id,
{'order_line': order_lines})
tds[0] gave us the current record id . thank you guys .