From eaa0f29094a1fe668fb989c36402ccea44543111 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 30 Sep 2014 17:20:28 +0200 Subject: [PATCH] [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 --- addons/website_event_sale/models/sale_order.py | 4 ++-- addons/website_sale/models/sale_order.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/website_event_sale/models/sale_order.py b/addons/website_event_sale/models/sale_order.py index 7351279eee0..450fcddf867 100644 --- a/addons/website_event_sale/models/sale_order.py +++ b/addons/website_event_sale/models/sale_order.py @@ -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"): diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 373db16bbc4..1f7e3f1be82 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -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)