~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to consumption_calculation/consumption_calculation.py

[MERGE] Merge UF-1763

Show diffs side-by-side

added added

removed removed

Lines of Context:
749
749
    def change_qty(self, cr, uid, ids, qty, product_id, prodlot_id, location, uom, context=None):
750
750
        if context is None:
751
751
            context = {}
 
752
 
 
753
        res = {'value': {}}
 
754
 
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")}
754
 
        if uom:
755
 
            new_qty = self.pool.get('product.uom')._compute_qty(cr, uid, uom, qty, uom)
756
 
            if new_qty != qty:
757
 
                warn_msg = {
758
 
                    'title': _('Error'), 
759
 
                    'message': _("The Qty Consumed %s and rounding uom qty %s are not equal !")%(qty, new_qty)
760
 
                }
761
 
                return {'warning': warn_msg, 'value': {'consumed_qty': 0}}
 
757
        
 
758
        if qty:
 
759
            res = self.pool.get('product.uom')._change_round_up_qty(cr, uid, uom, qty, 'consumed_qty', result=res)
762
760
 
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}
767
 
        return {}
 
765
            res.setdefault('warning', {}).update(warn_msg)
 
766
        
 
767
        return res
768
768
 
769
769
    def change_prodlot(self, cr, uid, ids, product_id, prodlot_id, expiry_date, location_id, uom, remark=False, context=None):
770
770
        '''
793
793
 
794
794
        return res
795
795
   
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:
798
798
            context = {}
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)]
807
807
 
808
 
        return {'value': {'product_qty': qty_available}, 'domain': d}
 
808
        res = {'value': {'product_qty': qty_available}, 'domain': d}
 
809
 
 
810
        if product_qty:
 
811
            res = self.pool.get('product.uom')._change_round_up_qty(cr, uid, uom, product_qty, 'consumed_qty', result=res)
 
812
 
 
813
        return res
809
814
 
810
815
    def product_onchange(self, cr, uid, ids, product_id, location_id=False, uom=False, lot=False, context=None):
811
816
        '''