Hello.
I want to add a custom field to my purchase order form (Product Weight) to store the weight of every product I purchase. I would like to show this field's value for every product purchased in Stock Move Tree.
I have created a custom field (Product Weight) to my Purchase Order Form and a related one (Stock Weight) to Stock Move Tree. I created two modules and when I create a new purchase order everything works fine, but when I view Stock Moves I see the related field but it's empty.
Any help is appreciated!
Here is the code.
Module: Product Weight
File: product_weight.py
*****************
from openerp.osv import fields, osv
class product_weight(osv.osv):
_inherit = "purchase.order.line"
_columns = {
'x_product_weight': fields.float('Product Weight')
}
product_weight()
*********************
File: product_weight.xml
*********************
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_weight_field" model="ir.ui.view">
<field name="name">order.line</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='pric$
<field name="x_product_weight" />
</xpath>
</field>
</record>
</data>
</openerp>
**********************
Module: Stock Weight
File: stock_weight.py
**********************
from openerp.osv import fields, osv
class stock_weight(osv.osv):
_inherit = "stock.move"
_columns = {
'x_stock_weight': fields.many2one('purchase.order.line','Stock Weight'),
}
stock_weight()
**********************
File: stock_weight.xml
**********************
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="stock_weight_field" model="ir.ui.view">
<field name="name">stock.move.tree</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="x_stock_weight" />
</xpath>
</field>
</record>
</data>
</openerp>
************************