i want to add onchange function in module manufacturing (mrp.production) in view.xml
<record model="ir.ui.view" id="partner_instructur_form_view">
<field name="name">mrp.production.form.instructur</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='location_dest_id']" position="after">
<field name="product_qty" on_change="onchange_hitung_kuota(product_qty, prod_qtys)"/>
<field name="prod_qtys" on_change="onchange_hitung_kuota(product_qty, prod_qtys)"/>
<field name="progres_persen" widget="progressbar"/>
</xpath>
</field>
</record>
in python
class ala_mrp_prod(osv.osv):
_inherit = 'mrp.production'
def onchange_hitung_kuota(self, cr, uid, ids, prod_qtys, product_qty):
kurangi = product_qty - prod_qtys
res = {
'value':{ 'progres_persen': (kurangi * 100) / product_qty}
}
return res
_columns = {
'prod_qtys':fields.integer('Jumlah Total'),
'progres_persen': fields.float('Progres'),
}
_defaults = {
'prod_qtys': 1,
}
ala_mrp_prod()
- why product quantity show 2?
- so if i input product_quantity 3 , jumlah total 5 progres 40%? please help