Merge lp:~openerp-dev/openobject-addons/trunk-bug-953324-rpr into lp:openobject-addons

Proposed by Rajesh Prajapati (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-953324-rpr
Merge into: lp:openobject-addons
Diff against target: 102 lines (+30/-8)
2 files modified
stock/stock.py (+24/-2)
stock/stock_view.xml (+6/-6)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-953324-rpr
Reviewer Review Type Date Requested Status
Rajesh Prajapati (OpenERP) (community) Needs Resubmitting
Purnendu Singh (OpenERP) (community) Needs Fixing
Review via email: mp+123274@code.launchpad.net

Description of the change

Hello

       I added the onchange method for UOM to check the UOM in stock.move and stock.inventory.line in stock

Thanks.
Rajesh

To post a comment you must log in.
Revision history for this message
Purnendu Singh (OpenERP) (purnendu-singh) wrote :

Hello,

You should update 2 points in your mp:

1) Place the newly created onchange_uom method to proper place!!

2) Your forget to do the same thing for stock.inventory.line!!

to check go to warehouse-->inventory control-->physical inventory
 here create a new inventory and create lines. You can change the UOM of different categories!! So, please update the code as u did for stock.move

Thanks,
Purnendu Singh

review: Needs Fixing
7376. By Rajesh Prajapati (OpenERP)

[FIX] stock: method onchange_uom added for stock.inventory.line

7377. By Rajesh Prajapati (OpenERP)

[FIX] stock: method on_change_product_id improved to consider the proper UOM as per change

Revision history for this message
Rajesh Prajapati (OpenERP) (rpr-tinyerp) wrote :

Hello

      Added method for stock.inventory.line and improved onchange_product_id to consider proper UOM.

Thanks.
Rajesh

review: Needs Resubmitting
7378. By Rajesh Prajapati (OpenERP)

[FIX] stock: space removed

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Rajesh,

on_change_uom is not a better solution to do this, but there must be a check_uom constraint which will also useful for import time. Because if someone try to import inventory line with csv file then on_change will never raise.

So for this bug lp:~openerp-dev/openobject-addons/trunk-bug-953324-mma branch is correct.

Thank you!

7379. By Rajesh Prajapati (OpenERP)

[MERGE] merge with main addons

7380. By Rajesh Prajapati (OpenERP)

[MERGE] merge with main addons

7381. By Rajesh Prajapati (OpenERP)

[MERGE] merge with main addons

Unmerged revisions

7381. By Rajesh Prajapati (OpenERP)

[MERGE] merge with main addons

7380. By Rajesh Prajapati (OpenERP)

[MERGE] merge with main addons

7379. By Rajesh Prajapati (OpenERP)

[MERGE] merge with main addons

7378. By Rajesh Prajapati (OpenERP)

[FIX] stock: space removed

7377. By Rajesh Prajapati (OpenERP)

[FIX] stock: method on_change_product_id improved to consider the proper UOM as per change

7376. By Rajesh Prajapati (OpenERP)

[FIX] stock: method onchange_uom added for stock.inventory.line

7375. By Rajesh Prajapati (OpenERP)

[FIX] stock: onchange method added for no_check_UOM in stock.move and stock.inventory.line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'stock/stock.py'
--- stock/stock.py 2013-12-18 15:57:15 +0000
+++ stock/stock.py 2014-01-15 16:02:43 +0000
@@ -1683,6 +1683,17 @@
1683 'You try to assign a lot which is not from the same product.',1683 'You try to assign a lot which is not from the same product.',
1684 ['prodlot_id'])]1684 ['prodlot_id'])]
16851685
1686 def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None):
1687 res = {'value':{}}
1688 if not product_uom or not product_id:
1689 return res
1690 product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
1691 uom = self.pool.get('product.uom').browse(cr, uid, product_uom, context=context)
1692 if uom.category_id.id != product.uom_id.category_id.id:
1693 res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')}
1694 res['value'].update({'product_uom': product.uom_id.id})
1695 return res
1696
1686 def _default_location_destination(self, cr, uid, context=None):1697 def _default_location_destination(self, cr, uid, context=None):
1687 """ Gets default address of partner for destination location1698 """ Gets default address of partner for destination location
1688 @return: Address id or False1699 @return: Address id or False
@@ -2921,7 +2932,18 @@
2921 'location_id': _default_stock_location2932 'location_id': _default_stock_location
2922 }2933 }
29232934
2924 def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):2935 def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None):
2936 res = {'value':{}}
2937 if not product_uom or not product_id:
2938 return res
2939 product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
2940 uom = self.pool.get('product.uom').browse(cr, uid, product_uom, context=context)
2941 if uom.category_id.id != product.uom_id.category_id.id:
2942 res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')}
2943 res['value'].update({'product_uom': product.uom_id.id})
2944 return res
2945
2946 def on_change_product_id(self, cr, uid, ids, location_id, product, to_date=False):
2925 """ Changes UoM and name if product_id changes.2947 """ Changes UoM and name if product_id changes.
2926 @param location_id: Location id2948 @param location_id: Location id
2927 @param product: Changed product_id2949 @param product: Changed product_id
@@ -2931,7 +2953,7 @@
2931 if not product:2953 if not product:
2932 return {'value': {'product_qty': 0.0, 'product_uom': False, 'prod_lot_id': False}}2954 return {'value': {'product_qty': 0.0, 'product_uom': False, 'prod_lot_id': False}}
2933 obj_product = self.pool.get('product.product').browse(cr, uid, product)2955 obj_product = self.pool.get('product.product').browse(cr, uid, product)
2934 uom = uom or obj_product.uom_id.id2956 uom = obj_product.uom_id.id
2935 amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom, 'to_date': to_date, 'compute_child': False})[product]2957 amount = self.pool.get('stock.location')._product_get(cr, uid, location_id, [product], {'uom': uom, 'to_date': to_date, 'compute_child': False})[product]
2936 result = {'product_qty': amount, 'product_uom': uom, 'prod_lot_id': False}2958 result = {'product_qty': amount, 'product_uom': uom, 'prod_lot_id': False}
2937 return {'value': result}2959 return {'value': result}
29382960
=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml 2013-12-18 15:57:15 +0000
+++ stock/stock_view.xml 2014-01-15 16:02:43 +0000
@@ -58,7 +58,7 @@
58 <field name="arch" type="xml">58 <field name="arch" type="xml">
59 <form string="Stock Inventory Lines" version="7.0">59 <form string="Stock Inventory Lines" version="7.0">
60 <group col="4">60 <group col="4">
61 <field context="{'location':location_id, 'uom':product_uom, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom,parent.date)" domain="[('type','&lt;&gt;','service')]"/>61 <field context="{'location':location_id, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,parent.date)" domain="[('type','&lt;&gt;','service')]"/>
62 <field name="product_qty"/>62 <field name="product_qty"/>
63 <field name="product_uom" groups="product.group_uom"/>63 <field name="product_uom" groups="product.group_uom"/>
64 <field name="prod_lot_id" groups="stock.group_production_lot"/>64 <field name="prod_lot_id" groups="stock.group_production_lot"/>
@@ -130,9 +130,9 @@
130 <field name="inventory_line_id">130 <field name="inventory_line_id">
131 <tree string="Products" editable="bottom">131 <tree string="Products" editable="bottom">
132 <field domain="[('usage','=','internal')]" name="location_id" groups="stock.group_locations"/>132 <field domain="[('usage','=','internal')]" name="location_id" groups="stock.group_locations"/>
133 <field context="{'location':location_id, 'uom':product_uom, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom,parent.date)" domain="[('type','&lt;&gt;','service')]"/>133 <field context="{'location':location_id, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,parent.date)" domain="[('type','&lt;&gt;','service')]"/>
134 <field name="product_qty"/>134 <field name="product_qty"/>
135 <field name="product_uom" groups="product.group_uom"/>135 <field name="product_uom" string="Unit of Measure" on_change="onchange_uom(product_id, product_uom, context)" groups="product.group_uom"/>
136 <field name="prod_lot_id" groups="stock.group_production_lot"/>136 <field name="prod_lot_id" groups="stock.group_production_lot"/>
137 <button name="%(stock.action_view_stock_inventory_line_split)d"137 <button name="%(stock.action_view_stock_inventory_line_split)d"
138 string="Split inventory lines" groups="stock.group_inventory_valuation"138 string="Split inventory lines" groups="stock.group_inventory_valuation"
@@ -143,7 +143,7 @@
143 <group>143 <group>
144 <group>144 <group>
145 <field domain="[('usage','=','internal')]" name="location_id"/>145 <field domain="[('usage','=','internal')]" name="location_id"/>
146 <field context="{'location':location_id, 'uom':product_uom, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom,parent.date)" domain="[('type','&lt;&gt;','service')]"/>146 <field context="{'location':location_id, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,parent.date)" domain="[('type','&lt;&gt;','service')]"/>
147 </group>147 </group>
148 <group>148 <group>
149 <label for="product_qty"/>149 <label for="product_qty"/>
@@ -1138,7 +1138,7 @@
1138 <field name="create_date" invisible="1" groups="base.group_no_one"/>1138 <field name="create_date" invisible="1" groups="base.group_no_one"/>
1139 <field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>1139 <field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>
1140 <field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>1140 <field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
1141 <field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>1141 <field name="product_uom" string="Unit of Measure" on_change="onchange_uom(product_id, product_uom, context)" groups="product.group_uom"/>
1142 <field name="product_uos" groups="product.group_uos"/>1142 <field name="product_uos" groups="product.group_uos"/>
1143 <button name="%(stock.move_scrap)d"1143 <button name="%(stock.move_scrap)d"
1144 string="Scrap Products" type="action"1144 string="Scrap Products" type="action"
@@ -1234,7 +1234,7 @@
1234 <field name="product_qty"1234 <field name="product_qty"
1235 on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"1235 on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"
1236 class="oe_inline"/>1236 class="oe_inline"/>
1237 <field name="product_uom" groups="product.group_uom" class="oe_inline"/>1237 <field name="product_uom" on_change="onchange_uom(product_id, product_uom, context)" groups="product.group_uom" class="oe_inline"/>
1238 <button name="%(stock.move_scrap)d"1238 <button name="%(stock.move_scrap)d"
1239 string="Scrap" type="action"1239 string="Scrap" type="action"
1240 icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"1240 icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"

Subscribers

People subscribed via source and target branches

to all changes: