sale_order.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. import random
  3. from openerp import SUPERUSER_ID
  4. from openerp.osv import osv, orm, fields
  5. from openerp.addons.web.http import request
  6. class sale_order(osv.Model):
  7. _inherit = "sale.order"
  8. def _cart_update(self, cr, uid, ids, product_id=None, line_id=None, add_qty=0, set_qty=0, context=None, **kwargs):
  9. ret = super(sale_order,self)._cart_update(cr, uid, ids, product_id=product_id, line_id=line_id, add_qty=add_qty, set_qty=set_qty, context=context, **kwargs)
  10. return ret
  11. class website(orm.Model):
  12. _inherit = 'website'
  13. def added_to_cart_product_qty(self, cr, uid, ids, product_id=None, context=None):
  14. ret = {}
  15. quantity = 0.00
  16. sale_order_obj = self.pool['sale.order']
  17. sale_order_id = request.session.get('sale_order_id')
  18. if sale_order_id:
  19. for line in sale_order_obj.browse(cr, uid, sale_order_id, context=context).website_order_line:
  20. if product_id and product_id == line.product_id.product_tmpl_id.id:
  21. quantity+=line.product_uom_qty
  22. ret[line.product_id.id] = line.product_uom_qty
  23. return ret