如何在信息面板中添加国家/地区的选择字段

时间:2016-03-14 08:11:37

标签: odoo-8 odoo-website

如何在product.product_normal_form_view

的信息面板中为国家/地区添加选择字段

Screenshot : I need to add selection field for country in information panel of product.product_normal_form_view as shown in this image

2 个答案:

答案 0 :(得分:0)

这是解决方案。

<record id="product_normal_form_view_inherit" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml"> 
                <xpath expr="//form/sheet/notebook/page[@string='Information']/group/group/field[@name='list_price']" position="after">
                     <field name="country_id"/>
                </xpath>
            </field>
</record>

答案 1 :(得分:0)

继承product.template

您的xml文件应为:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="product_template_product_form_inherited" model="ir.ui.view">
            <field name="name">product.template.product.form.inherited</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="//page[@string='Information']/group/group" position="inside">
                        <field name='country_id'/>
                </xpath>
            </field>
        </record>
    </data>
</openerp>

python档案:

from openerp import models, fields


class product_template(models.Model):
    _inherit = 'product.template'

    country_id = fields.Many2one('res.country', 'Country')