Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1.     def add_product(self, cr, uid, order_id, product_id, qty, context=None):
  2.  
  3.         """Create a new order line the order"""
  4.  
  5.         line_obj = self.pool.get('pos.order.line')
  6.         values = self.read(cr, uid, order_id, ['partner_id', 'pricelist_id'])
  7.  
  8.         pricelist = values['pricelist_id'] and values['pricelist_id'][0]
  9.         product = values['partner_id'] and values['partner_id'][0]
  10.  
  11.         price = line_obj.price_by_product(cr, uid, [],
  12.                 pricelist, product_id, qty, product)
  13.  
  14.         order_line_id = line_obj.create(cr, uid, {
  15.             'order_id': order_id,
  16.             'product_id': product_id,
  17.             'qty': qty,
  18.             'price_unit': price,
  19.         })
  20.         wf_service = netsvc.LocalService("workflow")
  21.         wf_service.trg_write(uid, 'pos.order', order_id, cr)
  22.  
  23.         return order_line_id, price
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement