<?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>
来自odoo导入模型,字段,api
从odoo.addons导入decimal_precision作为dp
来自odoo.exceptions的导入ValidationError,RedirectWarning,except_orm
来自odoo.tools import pycompat
class ProductTemplate(models.Model):
_inherit =&#39; product.template&#39;
_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)
答案 0 :(得分:1)
你在list_price之后放置了相同的字段list_price,你应该用你想要的字段替换xpath中的字段。
<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="your_custom_field"/>
</xpath>
</field>
</record>
答案 1 :(得分:0)
enter <?xml version="1.0" encoding="utf-8"?>
<data>
<record id="product_template_tree_view" model="ir.ui.view">
<field name="name">product.template.product.tree</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<tree string="Product">
<field name="sequence" widget="handle"/>
<field name="default_code"/>
<field name="name"/>
<field name="list_price"/>
<field name="standard_price"/>
<field name="categ_id"/>
<field name="type"/>
<field name="uom_id" options="{'no_open': True, 'no_create': True}" groups="product.group_uom"/>
<field name="active" invisible="1"/>
</tree>
</field>
</record>
<record id="product_template_only_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="mode">primary</field>
<field name="priority" eval="8" />
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//form" position="attributes">
<attribute name="name">Product Template</attribute>
</xpath>
<field name="categ_id" position="after">
<field name="default_code" attrs="{'invisible': [('product_variant_count', '>', 1)]}"/>
<field name="barcode" attrs="{'invisible': [('product_variant_count', '>', 1)]}"/>
</field>
<button name="toggle_active" position="before">
<button name="%(product.product_variant_action)d" type="action"
icon="fa-sitemap" class="oe_stat_button"
attrs="{'invisible': [('product_variant_count', '<=', 1)]}"
groups="product.group_product_variant">
<field string="Variants" name="product_variant_count" widget="statinfo" />
</button>
</button>
<xpath expr="//page[@name='general_information']" position="after">
<page name="variants" string="Variants" groups="product.group_product_variant">
<field name="attribute_line_ids" widget="one2many_list" context="{'show_attribute': False}">
<tree string="Variants" editable="bottom">
<field name="attribute_id"/>
<field name="value_ids" widget="many2many_tags" options="{'no_create_edit': True}" domain="[('attribute_id', '=', attribute_id)]" context="{'default_attribute_id': attribute_id}"/>
</tree>
</field>
<p class="oe_grey">
<strong>Warning</strong>: adding or deleting attributes
will delete and recreate existing variants and lead
to the loss of their possible customizations.
</p>
</page>
</xpath>
</field>
</record>
<record id="product_template_kanban_view" model="ir.ui.view">
<field name="name">Product.template.product.kanban</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<kanban>
<field name="id"/>
<field name="image_small"/>
<field name="lst_price"/>
<field name="product_variant_count"/>
<field name="product_variant_ids"/>
<field name="currency_id"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<div class="o_kanban_image">
<img t-att-src="kanban_image('product.template', 'image_small', record.id.raw_value)"/>
</div>
<div class="oe_kanban_details">
<strong class="o_kanban_record_title">
<field name="name"/>
<small t-if="record.default_code.value">[<field name="default_code"/>]</small>
</strong>
<div t-if="record.product_variant_count.value > 1" groups="product.group_product_variant">
<strong>
<t t-esc="record.product_variant_count.value"/> Variants
</strong>
</div>
<div name="tags"/>
<ul>
<li>Price: <field name="lst_price" widget="monetary" options="{'currency_field': 'currency_id', 'field_digits': True}"></field></li>
</ul>
<div name="tags"/>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="product_template_action" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.template</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_type">form</field>
<field name="view_id" ref="product_template_kanban_view"/>
<field name="context">{"search_default_filter_to_sell":1}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to define a new product.
</p><p>
You must define a product for everything you sell, whether it's a physical product, a consumable or a service you offer to customers.
</p><p>
The product form contains information to simplify the sale process: price, notes in the quotation, accounting data, procurement methods, etc.
</p>
</field>
</record>
<!-- inherit the product form view -->
<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"/>
</xpath>
</field>
</record>
</data>
代码
答案 2 :(得分:0)
您可以在放置字段时输出显示错误的错误吗? 检查模块的 init .py文件。
答案 3 :(得分:0)
Le champ remise
n&#39; existe pas
Contexte de l&#39; erreur:
Vue product.template.common.form
[view_id:676,xml_id:mymodulee.view_product_form,型号:product.template,parent_id:328]
无&#34;解析文件时:/ c:/ program%20files%20(x86)/odoo%2011.0/server/odoo/addons/mymodulee/views/product_template_view.xml:123,附近
<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="remise" on_change="onchange_calculer(x_marge1,standard_price)"/>
</xpath>
</field>
</record>
答案 4 :(得分:0)
确认在文件夹中,模型有另一个init和正确输入包含该类的文件的init 试试吧,
class ProductTemplate(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)
P.d:_columns属性来自旧的api v7