来自odoo导入模型,字段,api
class product_template(models.Model):
_inherit = 'product.template'
remise = fields.float('remise du fournisseur', size=10, required=True)
marge = fields.float('marge', size=10, required=True)
total_reste = fields.float('Reste', size=10, required=True)
def onchange_calculer(val1, val2):
return {'value': {'list_price': val1 * (val2/100) + val1}}
}
<我的xml视图文件代码
<record id="view_product_form" model="ir.ui.view">
<field name="name">product.template.common.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='list_price']" position="after">
<field name="x_remise1"/>
<field name="x_marge1"/>
<field name="list_price"
on_change =“onchange_calculer(standard_price,x_marge1)”readonly =“True”/>
</xpath>
</field>
</record>
我不明白为什么它不起作用
3 回答
试试吧 .
其中val1和val2是product.template对象的字段,onchage_calculer将在检测到val1和val2字段值的任何更改时启动 . 对不起我的英语不好 .
P.D:fields.float('')sintax在v11中运行?
在视图中:
在班上
如果在模型中没有定义,为什么你在wiew上使用x_marge1和x_remise1?
别忘了: