[FIX] stock: fixed onchange in pack operation and uom quantity when using pack operation
bzr revid: qdp-launchpad@openerp.com-20131112161502-rwc86glwhbkrwcfl
This commit is contained in:
parent
c3c63b86ad
commit
d4cd737ee9
|
@ -968,6 +968,7 @@ class stock_picking(osv.osv):
|
||||||
"""
|
"""
|
||||||
quant_obj = self.pool.get("stock.quant")
|
quant_obj = self.pool.get("stock.quant")
|
||||||
pack_obj = self.pool.get("stock.quant.package")
|
pack_obj = self.pool.get("stock.quant.package")
|
||||||
|
uom_obj = self.pool.get('product.uom')
|
||||||
res = {} # Qty still to do from ops
|
res = {} # Qty still to do from ops
|
||||||
res2 = {} #what is left from moves
|
res2 = {} #what is left from moves
|
||||||
resneg= {} #Number of negative quants to create for move/op
|
resneg= {} #Number of negative quants to create for move/op
|
||||||
|
@ -992,7 +993,7 @@ class stock_picking(osv.osv):
|
||||||
if ops.product_id:
|
if ops.product_id:
|
||||||
# Match with moves
|
# Match with moves
|
||||||
move_ids = ops.product_id.id in products_moves and filter(lambda x: res2[x.id] > 0, products_moves[ops.product_id.id]) or []
|
move_ids = ops.product_id.id in products_moves and filter(lambda x: res2[x.id] > 0, products_moves[ops.product_id.id]) or []
|
||||||
qty_to_do = ops.product_qty
|
qty_to_do = uom_obj._compute_qty(cr, uid, ops.product_uom_id.id, ops.product_qty, to_uom_id=ops.product_id.uom_id.id)
|
||||||
while qty_to_do > 0 and move_ids:
|
while qty_to_do > 0 and move_ids:
|
||||||
move = move_ids.pop()
|
move = move_ids.pop()
|
||||||
if res2[move.id] > qty_to_do:
|
if res2[move.id] > qty_to_do:
|
||||||
|
@ -3147,13 +3148,18 @@ class stock_pack_operation(osv.osv):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def product_id_change(self, cr, uid, ids, product_id, product_uom_id, product_qty, context=None):
|
def product_id_change(self, cr, uid, ids, product_id, product_uom_id, product_qty, context=None):
|
||||||
|
res = self.on_change_tests(cr, uid, ids, product_id, product_uom_id, product_qty, context=context)
|
||||||
|
if product_id and not product_uom_id:
|
||||||
|
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
||||||
|
res['value']['product_uom_id'] = product.uom_id.id
|
||||||
|
return res
|
||||||
|
|
||||||
|
def on_change_tests(self, cr, uid, ids, product_id, product_uom_id, product_qty, context=None):
|
||||||
res = {'value': {}}
|
res = {'value': {}}
|
||||||
uom_obj = self.pool.get('product.uom')
|
uom_obj = self.pool.get('product.uom')
|
||||||
if product_id:
|
if product_id:
|
||||||
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
||||||
if not product_uom_id:
|
product_uom_id = product_uom_id or product.uom_id.id
|
||||||
product_uom_id = product.uom_id.id
|
|
||||||
res['value']['product_uom_id'] = product_uom_id
|
|
||||||
selected_uom = uom_obj.browse(cr, uid, product_uom_id, context=context)
|
selected_uom = uom_obj.browse(cr, uid, product_uom_id, context=context)
|
||||||
if selected_uom.category_id.id != product.uom_id.category_id.id:
|
if selected_uom.category_id.id != product.uom_id.category_id.id:
|
||||||
res['warning'] = {
|
res['warning'] = {
|
||||||
|
|
|
@ -794,11 +794,11 @@
|
||||||
<field name="pack_operation_ids" attrs="{'invisible': [('pack_operation_exist', '=', False)]}" context="{'default_owner_id': owner_id}">
|
<field name="pack_operation_ids" attrs="{'invisible': [('pack_operation_exist', '=', False)]}" context="{'default_owner_id': owner_id}">
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
<field name="product_id" on_change='product_id_change(product_id, product_uom_id, product_qty, context)'/>
|
<field name="product_id" on_change='product_id_change(product_id, product_uom_id, product_qty, context)'/>
|
||||||
<field name="product_uom_id" groups="product.group_uom" on_change='product_id_change(product_id, product_uom_id, product_qty, context)'/>
|
<field name="product_uom_id" groups="product.group_uom" on_change='on_change_tests(product_id, product_uom_id, product_qty, context)'/>
|
||||||
<field name="lot_id" domain="[('product_id','=?', product_id)]" context="{'product_id': product_id}" groups="stock.group_production_lot"/>
|
<field name="lot_id" domain="[('product_id','=?', product_id)]" context="{'product_id': product_id}" groups="stock.group_production_lot"/>
|
||||||
<field name="package_id" groups="stock.group_tracking_lot"/>
|
<field name="package_id" groups="stock.group_tracking_lot"/>
|
||||||
<field name="owner_id" groups="stock.group_tracking_owner"/>
|
<field name="owner_id" groups="stock.group_tracking_owner"/>
|
||||||
<field name="product_qty" attrs="{'required': [('product_id', '!=', False)]}" on_change='product_id_change(product_id, product_uom_id, product_qty, context)'/>
|
<field name="product_qty" attrs="{'required': [('product_id', '!=', False)]}" on_change='on_change_tests(product_id, product_uom_id, product_qty, context)'/>
|
||||||
<field name="result_package_id" groups="stock.group_tracking_lot"/>
|
<field name="result_package_id" groups="stock.group_tracking_lot"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
|
Loading…
Reference in New Issue