【发布时间】:2018-04-11 15:56:41
【问题描述】:
product_template.xml
将自定义字段添加到产品模块的视图
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="product_template_only_form_view_inherit" 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_only_form_view " />
<field name="arch" type="xml">
<xpath expr="//field[@name='list_price']" position="after">
<field name="list_price"/>
</xpath>
</field>
</record>
</data>
</odoo>
模型文件python
product_template.py
-- 编码:utf-8 --
从 odoo 导入模型、字段、api
从 odoo.addons 导入 decimal_precision 作为 dp
从 odoo.exceptions 导入 ValidationError、RedirectWarning、except_orm
从 odoo.tools 导入 pycompat
类 ProductTemplate(models.Model):
_inherit = 'product.template'
_name = 'product.template'
_columns={
'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),
}
remise = fields.float('remise du fournisseur', size=10, required=True)
【问题讨论】:
-
请阅读guide on how to ask a question 并根据它格式化您的问题(标题中的问题是一种不好的做法)。如果可能,请提供clear and complete code example 和错误消息。