749
749
def change_qty(self, cr, uid, ids, qty, product_id, prodlot_id, location, uom, context=None):
750
750
if context is None:
752
755
stock_qty = self._get_qty(cr, uid, product_id, prodlot_id, location, uom)
753
756
warn_msg = {'title': _('Error'), 'message': _("The Qty Consumed is greater than the Indicative Stock")}
755
new_qty = self.pool.get('product.uom')._compute_qty(cr, uid, uom, qty, uom)
759
'message': _("The Qty Consumed %s and rounding uom qty %s are not equal !")%(qty, new_qty)
761
return {'warning': warn_msg, 'value': {'consumed_qty': 0}}
759
res = self.pool.get('product.uom')._change_round_up_qty(cr, uid, uom, qty, 'consumed_qty', result=res)
763
761
if prodlot_id and qty > stock_qty:
764
return {'warning': warn_msg, 'value': {'consumed_qty': 0}}
762
res.setdefault('warning', {}).update(warn_msg)
763
res.setdefault('value', {}).update({'consumed_qty': 0})
765
764
if qty > stock_qty:
766
return {'warning': warn_msg}
765
res.setdefault('warning', {}).update(warn_msg)
769
769
def change_prodlot(self, cr, uid, ids, product_id, prodlot_id, expiry_date, location_id, uom, remark=False, context=None):
796
def uom_onchange(self, cr, uid, ids, product_id, location_id=False, uom=False, lot=False, context=None):
796
def uom_onchange(self, cr, uid, ids, product_id, product_qty, location_id=False, uom=False, lot=False, context=None):
797
797
if context is None:
799
799
qty_available = 0
805
805
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
806
806
d['uom_id'] = [('category_id', '=', product.uom_id.category_id.id)]
808
return {'value': {'product_qty': qty_available}, 'domain': d}
808
res = {'value': {'product_qty': qty_available}, 'domain': d}
811
res = self.pool.get('product.uom')._change_round_up_qty(cr, uid, uom, product_qty, 'consumed_qty', result=res)
810
815
def product_onchange(self, cr, uid, ids, product_id, location_id=False, uom=False, lot=False, context=None):