I want to few custom field in mrp.bom table in order to calculate the real row material consumption starting from drawing dimensions. here is my .py code
from osv import osv, fields
class mrp_bom(osv.osv):
_inerhit = 'mrp.bom'
#_name = 'mrp.bom'
_columns = {
'Residuo_barra': fields.float(string='Residuo Barra', required=False),
'Sfrido': fields.float(string='Sfrido mm', required=False),
'L_barra': fields.float(string='lunghezza barra mm', required=False),
'L_pezzo_a_disegno': fields.float(string='L a disegno in mm', required=False),
'L_pezzo_calcolata': fields.float(string='Lunghezza calcolata', required=False),
}
_defaults = {
'Residuo_barra': 300.0,
'Sfrido': 4.0,
'L_barra': 3000.0,
}
def button_Calcola(self, cr, uid, ids, L_pezzo_a_disegno, Residuo_barra, Sfrido, L_barra, conext=None):
#calcola il consumo effettivo della barra
barra_utile = L_barra - Residuo_barra
numero_pezzi = int(barra_utile / (L_pezzo_a_disegno + Sfrido))
res = {
'L_pezzo_calcolata': (L_barra / numero_pezzi)
}
return {'value': res}
mrp_bom()
and here is the .xml
<record id="mrp_bom_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.tree</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_tree_view"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="L_pezzo_calcolata" />
</field>
</field>
</record>
<record id="mrp_bom_component_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.component.tree</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_component_tree_view"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="L_pezzo_calcolata" />
</field>
</field>
</record>
<record id="mrp_bom_form_view" model="ir.ui.view">
<field name="name">mrp.bom.form</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='bom_lines']/tree" position="inside" >
<field name="Residuo_barra" />
<field name="Sfrido" />
<field name="L_barra" />
<field name="L_pezzo_a_disegno" />
<field name="L_pezzo_calcolata" />
</xpath>
</field>
</record>
</data>
during the installation process I get :
ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
If I check into the module structure Setting\Database structure\models\mrp_bom the field have been added, But If I menage view in bom view the fields are not available!