← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~numerigraphe-team/ocb-addons/7.0-inventory-readonly-lines into lp:ocb-addons

 

Lionel Sausin - Numérigraphe has proposed merging lp:~numerigraphe-team/ocb-addons/7.0-inventory-readonly-lines into lp:ocb-addons.

Requested reviews:
  Holger Brunn (Therp) (hbrunn): code review
Related bugs:
  Bug #1290357 in OpenERP Community Backports (Addons): "Location and product should be read-only on imported inventory lines"
  https://bugs.launchpad.net/ocb-addons/+bug/1290357

For more details, see:
https://code.launchpad.net/~numerigraphe-team/ocb-addons/7.0-inventory-readonly-lines/+merge/210207

As usability improvement in inventories, we propose to make the fields "product", "location" and "serial nb" read-only as soon as an inventory line is recorded.
This keeps users from mistakenly keeping wrong products in stock.

Consider you filled the inventory with the wizard :
Product A: 15
Product B : 20
And physically you really have :
Product A: 15
Product C: 20
It's tempting to change just the product on the 2nd line but it's wrong: that would not remove product B from the stock.
You actually have to set the 2nd line to 0 and add a 3rd line to record the right data.

There is a proposal to merge this into the trunk too, but it's in standby until the new WMS code gets merged.
-- 
https://code.launchpad.net/~numerigraphe-team/ocb-addons/7.0-inventory-readonly-lines/+merge/210207
Your team OpenERP Community Backports Team is subscribed to branch lp:ocb-addons.
=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml	2013-12-10 16:05:05 +0000
+++ stock/stock_view.xml	2014-03-10 13:45:41 +0000
@@ -41,14 +41,15 @@
             <field name="model">stock.inventory.line</field>
             <field name="arch" type="xml">
                 <tree string="Stock Inventory Lines">
-                    <field name="product_id"/>
+                    <field name="product_id" attrs="{'readonly': [('id','!=',False)]}"/>
                     <field name="product_qty"/>
                     <field name="product_uom" groups="product.group_uom"/>
-                    <field name="prod_lot_id" groups="stock.group_production_lot"/>
+                    <field name="prod_lot_id" groups="stock.group_production_lot" attrs="{'readonly': [('id','!=',False)]}"/>
                     <button name="%(stock.action_view_stock_inventory_line_split)d"
                             string="Split inventory lines" groups="stock.group_inventory_valuation"
                             type="action" icon="gtk-justify-fill"/>
-                    <field name="location_id" groups="stock.group_locations"/>
+                    <field name="location_id" groups="stock.group_locations" attrs="{'readonly': [('id','!=',False)]}"/>
+                    <field name = "id" invisible="1"/>
                 </tree>
             </field>
         </record>
@@ -58,15 +59,20 @@
             <field name="arch" type="xml">
                 <form string="Stock Inventory Lines" version="7.0">
                     <group col="4">
-                        <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')]"/>
+                        <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')]"
+                            attrs="{'readonly': [('id','!=',False)]}" />
                         <field name="product_qty"/>
                         <field name="product_uom" groups="product.group_uom"/>
-                        <field name="prod_lot_id" groups="stock.group_production_lot"/>
-                        <field domain="[('usage','=','internal')]" name="location_id"/>
+                        <field name="prod_lot_id" groups="stock.group_production_lot" attrs="{'readonly': [('id','!=',False)]}"/>
+                        <field domain="[('usage','=','internal')]" name="location_id" attrs="{'readonly': [('id','!=';',False)]}"/>
                         <button name="%(stock.action_view_stock_inventory_line_split)d"
                             string="Split Inventory Line" groups="stock.group_inventory_valuation"
                             type="action" icon="gtk-justify-fill"/>
                     </group>
+                    <field name = "id" invisible="1"/>
                 </form>
             </field>
         </record>
@@ -129,21 +135,30 @@
                     <page string="General Information">
                         <field name="inventory_line_id">
                             <tree string="Products" editable="bottom">
-                                <field domain="[('usage','=','internal')]" name="location_id" groups="stock.group_locations"/>
-                                <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')]"/>
+                                <field domain="[('usage','=','internal')]" name="location_id" groups="stock.group_locations" attrs="{'readonly': [('id','&lt;&gt;',False)]}"/>
+                                <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')]"
+                                    attrs="{'readonly': [('id','&lt;&gt;',False)]}"/>
                                 <field name="product_qty"/>
                                 <field name="product_uom" groups="product.group_uom"/>
-                                <field name="prod_lot_id" groups="stock.group_production_lot"/>
+                                <field name="prod_lot_id" groups="stock.group_production_lot" attrs="{'readonly': [('id','&lt;&gt;',False)]}"/>
                                 <button name="%(stock.action_view_stock_inventory_line_split)d"
                                     string="Split inventory lines" groups="stock.group_inventory_valuation"
                                     type="action" icon="gtk-justify-fill" states="draft,confirm"/>
                                 <field name="state" invisible="True"/>
+                                <field name = "id" invisible="1"/>
                             </tree>
                             <form string="Products" version="7.0">
                                 <group>
                                     <group>
-                                        <field domain="[('usage','=','internal')]" name="location_id"/>
-                                        <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')]"/>
+                                        <field domain="[('usage','=','internal')]" name="location_id" attrs="{'readonly': [('id','&lt;&gt;',False)]}"/>
+                                        <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')]"
+                                            attrs="{'readonly': [('id','!=',False)]}"/>
                                     </group>
                                     <group>
                                         <label for="product_qty"/>
@@ -151,11 +166,12 @@
                                             <field name="product_qty" class="oe_inline"/>
                                             <field name="product_uom" class="oe_inline" groups="product.group_uom"/>
                                         </div>
-                                        <field name="prod_lot_id" groups="stock.group_production_lot"/>
+                                        <field name="prod_lot_id" groups="stock.group_production_lot" attrs="{'readonly': [('id','!=',False)]}"/>
                                         <button name="%(stock.action_view_stock_inventory_line_split)d"
                                         string="Split inventory lines" groups="stock.group_inventory_valuation"
                                         type="action" icon="gtk-justify-fill"/>
                                     </group>
+                                <field name = "id" invisible="1"/>
                                 </group>
                             </form>
                         </field>


Follow ups