[FIX] website*sale: product_id_change qty is 0 by default
Thus, need to pass the actual quantity to product_id_change in order to set values correctly
This commit is contained in:
parent
be21986c8d
commit
eaa0f29094
|
@ -17,8 +17,8 @@ class sale_order(osv.Model):
|
|||
domain += [('event_ticket_id', '=', context.get("event_ticket_id"))]
|
||||
return self.pool.get('sale.order.line').search(cr, SUPERUSER_ID, domain, context=context)
|
||||
|
||||
def _website_product_id_change(self, cr, uid, ids, order_id, product_id, line_id=None, context=None):
|
||||
values = super(sale_order,self)._website_product_id_change(cr, uid, ids, order_id, product_id, line_id=line_id, context=None)
|
||||
def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, line_id=None, context=None):
|
||||
values = super(sale_order,self)._website_product_id_change(cr, uid, ids, order_id, product_id, qty=qty, line_id=line_id, context=None)
|
||||
|
||||
event_ticket_id = None
|
||||
if context.get("event_ticket_id"):
|
||||
|
|
|
@ -42,13 +42,14 @@ class sale_order(osv.Model):
|
|||
domain += [('id', '=', line_id)]
|
||||
return self.pool.get('sale.order.line').search(cr, SUPERUSER_ID, domain, context=context)
|
||||
|
||||
def _website_product_id_change(self, cr, uid, ids, order_id, product_id, line_id=None, context=None):
|
||||
def _website_product_id_change(self, cr, uid, ids, order_id, product_id, qty=0, line_id=None, context=None):
|
||||
so = self.pool.get('sale.order').browse(cr, uid, order_id, context=context)
|
||||
|
||||
values = self.pool.get('sale.order.line').product_id_change(cr, SUPERUSER_ID, [],
|
||||
pricelist=so.pricelist_id.id,
|
||||
product=product_id,
|
||||
partner_id=so.partner_id.id,
|
||||
qty=qty,
|
||||
context=context
|
||||
)['value']
|
||||
|
||||
|
@ -78,7 +79,7 @@ class sale_order(osv.Model):
|
|||
|
||||
# Create line if no line with product_id can be located
|
||||
if not line_id:
|
||||
values = self._website_product_id_change(cr, uid, ids, so.id, product_id, context=context)
|
||||
values = self._website_product_id_change(cr, uid, ids, so.id, product_id, qty=1, context=context)
|
||||
line_id = sol.create(cr, SUPERUSER_ID, values, context=context)
|
||||
if add_qty:
|
||||
add_qty -= 1
|
||||
|
@ -94,7 +95,7 @@ class sale_order(osv.Model):
|
|||
sol.unlink(cr, SUPERUSER_ID, [line_id], context=context)
|
||||
else:
|
||||
# update line
|
||||
values = self._website_product_id_change(cr, uid, ids, so.id, product_id, line_id, context=context)
|
||||
values = self._website_product_id_change(cr, uid, ids, so.id, product_id, qty=quantity, line_id=line_id, context=context)
|
||||
values['product_uom_qty'] = quantity
|
||||
sol.write(cr, SUPERUSER_ID, [line_id], values, context=context)
|
||||
|
||||
|
|
Loading…
Reference in New Issue