[IMP] Make sure property_ids on sale order line are visible and able to work
authorJosse Colpaert <jco@odoo.com>
Wed, 3 Sep 2014 13:24:49 +0000 (15:24 +0200)
committerJosse Colpaert <jco@odoo.com>
Fri, 12 Sep 2014 11:49:41 +0000 (13:49 +0200)
addons/sale_mrp/sale_mrp.py
addons/sale_mrp/sale_mrp_view.xml
addons/sale_stock/sale_stock_view.xml

index 52f9f01..082323a 100644 (file)
@@ -90,3 +90,13 @@ class sale_order_line(osv.osv):
     _columns = {
         'property_ids': fields.many2many('mrp.property', 'sale_order_line_property_rel', 'order_id', 'property_id', 'Properties', readonly=True, states={'draft': [('readonly', False)]}),
     }
+    
+
+class stock_move(osv.osv):
+    _inherit = 'stock.move'
+    
+    def _prepare_procurement_from_move(self, cr, uid, move, context=None):
+        res = super(stock_move, self)._prepare_procurement_from_move(cr, uid, move, context=context)
+        if res and move.procurement_id and move.procurement_id.property_ids:
+            res['property_ids'] = [(6, 0, [x.id for x in move.procurement_id.property_ids])]
+        return res
index 3c2771f..71e0aad 100644 (file)
             </field>
         </record>
 
+        <record id="view_order_form_inherit_mrp" model="ir.ui.view">
+            <field name="name">sale.order.form.sale.stock.mrp</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="sale.view_order_form"/>
+            <field name="arch" type="xml">
+               <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='address_allotment_id']" position="after">
+                   <field name="property_ids" widget="many2many_tags"
+                        groups="sale.group_mrp_properties"/>
+               </xpath>
+            </field>
+        </record>
+
+
     </data>
 </openerp>
index 48e41f9..f3db201 100644 (file)
                            <field name="delay" class="oe_inline"/> days
                        </div>
                    </xpath>
-                   <!--<xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='address_allotment_id']" position="after">
-                       <field name="property_ids" widget="many2many_tags"
-                            groups="sale.group_mrp_properties"/>
-                   </xpath>-->
                    <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='tax_id']" position="before">
                        <field name="product_packaging" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True, context)" domain="[('product_tmpl_id','=',product_id)]" groups="product.group_stock_packaging"  />
                    </xpath>