Rajesh Prajapati (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-bug-953324-rpr into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #953324 in OpenERP Addons: "stock.move and stock.inventory.line no
_check_UOM"
https://bugs.launchpad.net/openobject-addons/+bug/953324
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-953324-rpr/+merge/123274
Hello
I added the onchange method for UOM to check the UOM in stock.move and
stock.inventory.line in stock
Thanks.
Rajesh
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-953324-rpr/+merge/123274
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-bug-953324-rpr.
=== modified file 'stock/stock.py'
--- stock/stock.py 2012-08-31 07:40:32 +0000
+++ stock/stock.py 2012-09-07 13:33:56 +0000
@@ -1654,6 +1654,18 @@
# used for colors in tree views:
'scrapped': fields.related('location_dest_id','scrap_location',type='boolean',relation='stock.location',string='Scrapped', readonly=True),
}
+
+ def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None):
+ res = {'value':{}}
+ if not product_uom or not product_id:
+ return res
+ product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
+ uom = self.pool.get('product.uom').browse(cr, uid, product_uom, context=context)
+ if uom.category_id.id != product.uom_id.category_id.id:
+ res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')}
+ res['value'].update({'product_uom': product.uom_id.id})
+ return res
+
def _check_location(self, cr, uid, ids, context=None):
for record in self.browse(cr, uid, ids, context=context):
if (record.state=='done') and (record.location_dest_id.usage == 'view' or record.location_id.usage == 'view'):
=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml 2012-09-03 13:45:03 +0000
+++ stock/stock_view.xml 2012-09-07 13:33:56 +0000
@@ -1221,7 +1221,7 @@
<field name="create_date" invisible="1" groups="base.group_no_one"/>
<field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
- <field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>
+ <field name="product_uom" string="Unit of Measure" on_change="onchange_uom(product_id, product_uom, context)" groups="product.group_uom"/>
<field name="product_uos" groups="product.group_uos"/>
<button name="%(stock.move_scrap)d"
string="Scrap Products" type="action"
@@ -1274,7 +1274,7 @@
<field name="product_qty"
on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"
class="oe_inline"/>
- <field name="product_uom" groups="product.group_uom" class="oe_inline"/>
+ <field name="product_uom" on_change="onchange_uom(product_id, product_uom, context)" groups="product.group_uom" class="oe_inline"/>
<button name="%(stock.move_scrap)d"
string="Scrap" type="action"
icon="gtk-convert" context="{'scrap': True}"
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp