[MERGE] mrp: small usability fixes
- updated groups on some fields of bom - removed some icons in form view, to be coherent with other form views - BOM form view: updated onchange_product_id that now takes product_qty into account to compute uos and uos quantity. bzr revid: tde@openerp.com-20140211152116-niwt0pak4r0n8jst
This commit is contained in:
+18
-14
@@ -71,8 +71,6 @@ class mrp_workcenter(osv.osv):
|
||||
value = {'costs_hour': cost.standard_price}
|
||||
return {'value': value}
|
||||
|
||||
|
||||
|
||||
class mrp_routing(osv.osv):
|
||||
"""
|
||||
For specifying the routings of Work Centers.
|
||||
@@ -261,16 +259,20 @@ class mrp_bom(osv.osv):
|
||||
(_check_product, 'BoM line product should not be same as BoM product.', ['product_id']),
|
||||
]
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, name, context=None):
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, name, product_qty=0, context=None):
|
||||
""" Changes UoM and name if product_id changes.
|
||||
@param name: Name of the field
|
||||
@param product_id: Changed product_id
|
||||
@return: Dictionary of changed values
|
||||
"""
|
||||
res = {}
|
||||
if product_id:
|
||||
prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
||||
return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}}
|
||||
return {}
|
||||
res['value'] = {'name': prod.name, 'product_uom': prod.uom_id.id, 'product_uos_qty': 0, 'product_uos': False}
|
||||
if prod.uos_id.id:
|
||||
res['value']['product_uos_qty'] = product_qty * prod.uos_coeff
|
||||
res['value']['product_uos'] = prod.uos_id.id
|
||||
return res
|
||||
|
||||
def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None):
|
||||
res = {'value':{}}
|
||||
@@ -553,16 +555,19 @@ class mrp_production(osv.osv):
|
||||
return {'value': {'location_dest_id': src}}
|
||||
return {}
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product_id, context=None):
|
||||
def product_id_change(self, cr, uid, ids, product_id, product_qty=0, context=None):
|
||||
""" Finds UoM of changed product.
|
||||
@param product_id: Id of changed product.
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
result = {}
|
||||
if not product_id:
|
||||
return {'value': {
|
||||
'product_uom': False,
|
||||
'bom_id': False,
|
||||
'routing_id': False
|
||||
'routing_id': False,
|
||||
'product_uos_qty': 0,
|
||||
'product_uos': False
|
||||
}}
|
||||
bom_obj = self.pool.get('mrp.bom')
|
||||
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
|
||||
@@ -571,14 +576,13 @@ class mrp_production(osv.osv):
|
||||
if bom_id:
|
||||
bom_point = bom_obj.browse(cr, uid, bom_id, context=context)
|
||||
routing_id = bom_point.routing_id.id or False
|
||||
|
||||
product_uom_id = product.uom_id and product.uom_id.id or False
|
||||
result = {
|
||||
'product_uom': product_uom_id,
|
||||
'bom_id': bom_id,
|
||||
'routing_id': routing_id,
|
||||
}
|
||||
return {'value': result}
|
||||
product_uos_id = product.uos_id and product.uos_id.id or False
|
||||
result['value'] = {'product_uos_qty': 0, 'product_uos': False, 'product_uom': product_uom_id, 'bom_id': bom_id, 'routing_id': routing_id}
|
||||
if product.uos_id.id:
|
||||
result['value']['product_uos_qty'] = product_qty * product.uos_coeff
|
||||
result['value']['product_uos'] = product.uos_id.id
|
||||
return result
|
||||
|
||||
def bom_id_change(self, cr, uid, ids, bom_id, context=None):
|
||||
""" Finds routing for changed BoM.
|
||||
|
||||
@@ -347,10 +347,10 @@
|
||||
<form string="Bill of Material" version="7.0">
|
||||
<group>
|
||||
<group>
|
||||
<field name="product_id" on_change="onchange_product_id(product_id, name, context)" context="{'default_supply_method':'produce'}" class="oe_inline"/>
|
||||
<field name="product_id" on_change="onchange_product_id(product_id, name, product_qty, context)" context="{'default_supply_method':'produce'}" class="oe_inline"/>
|
||||
<label for="product_qty" string="Quantity"/>
|
||||
<div>
|
||||
<field name="product_qty" class="oe_inline"/>
|
||||
<field name="product_qty" class="oe_inline" on_change="onchange_product_id(product_id, name, product_qty, context)"/>
|
||||
<field name="product_uom" class="oe_inline" on_change="onchange_uom(product_id, product_uom)" groups="product.group_uom"/>
|
||||
</div>
|
||||
<label for="product_uos_qty" groups="product.group_uos"/>
|
||||
@@ -366,7 +366,7 @@
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
<field name="name" groups="base.group_no_one"/>
|
||||
<field name="name" groups="product.group_mrp_properties"/>
|
||||
<field name="code" string="Reference"/>
|
||||
<field name="type"/>
|
||||
<p colspan="2" class="oe_grey" attrs="{'invisible': [('type','=','normal')]}">
|
||||
@@ -646,15 +646,14 @@
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="product_id" on_change="product_id_change(product_id)" domain="[('bom_ids','!=',False),('bom_ids.bom_id','=',False)]" class="oe_inline" context='{"default_supply_method":"produce", "default_type": "product"}'/>
|
||||
<field name="product_id" on_change="product_id_change(product_id, product_qty)" domain="[('bom_ids','!=',False),('bom_ids.bom_id','=',False)]" class="oe_inline" context='{"default_supply_method":"produce", "default_type": "product"}'/>
|
||||
<label for="product_qty"/>
|
||||
<div>
|
||||
<field name="product_qty" class="oe_inline"/>
|
||||
<field name="product_qty" class="oe_inline" on_change="product_id_change(product_id, product_qty)"/>
|
||||
<field name="product_uom" groups="product.group_uom" class="oe_inline"/>
|
||||
<button type="action"
|
||||
icon="terp-accessories-archiver+"
|
||||
name="%(mrp.action_change_production_qty)d"
|
||||
string="(Update)" states="confirmed" class="oe_edit_only oe_link"/>
|
||||
string="Update" states="confirmed" class="oe_edit_only oe_link"/>
|
||||
</div>
|
||||
<label for="product_uos_qty" groups="product.group_uos"/>
|
||||
<div groups="product.group_uos">
|
||||
|
||||
Reference in New Issue
Block a user