product模块中有3个关于产品的表单视图:
- 产品模板主视图
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.common.form</field>
<field name="model">product.template</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<form string="Product">
<field name="is_product_variant" invisible="1"/>
<field name='product_variant_count' invisible='1'/>
<sheet>
<field name="id" invisible="True"/>
<div class="oe_right oe_button_box" style="width: 300px;" name="buttons">
</div>
<div class="oe_left" style="width: 500px;">
<field name="image_medium" widget="image" class="oe_avatar oe_left"/>
<div class="oe_title" style="width: 390px;">
<label class="oe_edit_only" for="name" string="Product Name"/>
<h1><field name="name" class="oe_inline"/></h1>
</div>
<div class="oe_left" name="options" groups="base.group_user">
<div>
<field name="sale_ok"/>
<label for="sale_ok"/>
</div>
</div>
</div>
<notebook>
<page string="Information">
<group colspan="4">
<group>
<field name="type"/>
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="product.group_uom"/>
<field name="list_price"/>
</group>
<group>
<field name="active"/>
</group>
</group>
<group colspan="4">
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
<field name="description" placeholder="describe the product characteristics..."/>
</page>
<page string="Procurements" groups="base.group_user">
<group name="procurement">
<group name="general">
<field name="standard_price"/>
</group>
<group name="procurement_uom" groups="product.group_uom" string="Purchase">
<field name="uom_po_id"/>
</group>
</group>
<separator string="Suppliers"/>
<field name="seller_ids"/>
<separator string="Description for Suppliers"/>
<field name="description_purchase" placeholder="This note will be displayed on requests for quotation..."/>
</page>
<page string="Inventory">
<group name="inventory">
<group name="status" string="Status">
<field name="state"/>
<field name="product_manager"/>
</group>
<group name="weight" string="Weights" attrs="{'invisible':[('type','=','service')]}">
<field digits="(14, 3)" name="volume"/>
<field digits="(14, 3)" name="weight"/>
<field digits="(14, 3)" name="weight_net"/>
</group>
</group>
<group name="packaging" string="Packaging" attrs="{'invisible':[('type','=','service')]}" groups="product.group_stock_packaging" colspan="4">
<field name="packaging_ids" string="Configurations" context="{'tree_view_ref':'product.product_packaging_tree_view_product', 'form_view_ref': 'product.product_packaging_form_view_without_product'}"/>
</group>
</page>
<page string="Sales" attrs="{'invisible':[('sale_ok','=',False)]}" name="sales">
<group name="sale">
<group name="sale_condition" string="Sale Conditions" colspan="3">
<label for="warranty"/>
<div>
<field name="warranty" class="oe_inline"/> months
</div>
</group>
<group groups="product.group_uos" string="Unit of Measure">
<field name="uos_id"/>
<field name="uos_coeff"/>
<field name="mes_type"/>
</group>
</group>
<group name="website_and_pos" col="2">
</group>
<separator string="Description for Quotations"/>
<field name="description_sale" placeholder="note to be displayed on quotations..."/>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
- 产品模板表单视图,继承自1,在Odoo中打开一个产品(模板)会调用此视图:
<!-- view specific to product.template -->
<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="active" position="after">
<field name="ean13" attrs="{'invisible': [('product_variant_count', '>', 1)]}"/>
<field name="default_code" attrs="{'invisible': [('product_variant_count', '>', 1)]}"/>
</field>
<xpath expr="//page[@string='Sales']" position="after">
<page name="variants" string="Variants">
<div class="oe_right">
<button class="oe_inline oe_stat_button" string="Variant Prices" name="%(variants_template_action)d" type="action" icon="fa-strikethrough"/>
<button class="oe_inline oe_stat_button" name="%(product.product_variant_action)d" type="action" icon="fa-sitemap">
<field string="List of Variants" name="product_variant_count" widget="statinfo" />
</button>
</div>
<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>
<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>
</page>
</xpath>
</field>
</record>
- 产品规格(Product Variant)视图,继承自1。
<record id="product_normal_form_view" model="ir.ui.view">
<field name="name">product.product.form</field>
<field name="model">product.product</field>
<field name="mode">primary</field>
<field eval="7" name="priority"/>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<form position="attributes">
<attribute name="string">Product Variant</attribute>
</form>
<field name="active" position="after">
<field name="ean13"/>
<field name="default_code"/>
</field>
<field name="list_price" position="attributes">
<attribute name="name">lst_price</attribute>
</field>
<field name="name" position="replace">
<field name="name" attrs="{'invisible': [('id', '!=', False)]}"/>
<field name="product_tmpl_id" class="oe_inline" readonly="1" attrs="{'invisible': [('id', '=', False)], 'required': [('id', '!=', False)]}"/>
</field>
<xpath expr="//div[@class='oe_title']" position="inside">
<field name="attribute_value_ids" widget="many2many_tags"/>
</xpath>
</field>
</record>
stock模块中product.template相关继承表单视图,继承自
<record id="view_template_property_form" model="ir.ui.view">
<field name="name">product.template.stock.property.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<group name="sale_condition" position="inside">
<label for="sale_delay"/>
<div>
<field name="sale_delay" attrs="{'readonly':[('sale_ok','=',False)]}" class="oe_inline" style="vertical-align:baseline"/> days
</div>
</group>
<group name="status" position="before">
<group string="Stock and Expected Variations" attrs="{'invisible': [('type', '=', 'service')]}" groups="base.group_user">
<label for="qty_available"/>
<div>
<field name="qty_available" class="oe_inline"/>
<button name="%(action_view_change_product_quantity)d" string="⇒ Update"
type="action"
class="oe_link"/>
</div>
<label for="incoming_qty"/>
<div>
<field name="incoming_qty" class="oe_inline"/>
<button string="⇒ Request Procurement" name="%(stock.act_make_procurement)d" type="action" class="oe_link"/>
</div>
<field name="virtual_available"/>
</group>
</group>
<group name="status" position="after">
<group name="store" string="Storage Location" attrs="{'invisible':[('type','=','service')]}">
<field name="loc_rack"/>
<field name="loc_row"/>
<field name="loc_case"/>
</group>
</group>
<group name="status" position="before">
<group name="lot" groups="stock.group_production_lot" string="Lots" attrs="{'invisible':[('type','=','service')]}">
<field name="track_all" groups="stock.group_production_lot"/>
<field name="track_incoming" groups="stock.group_production_lot" attrs="{'invisible': [('track_all', '=', True)]}"/>
<field name="track_outgoing" groups="stock.group_production_lot" attrs="{'invisible': [('track_all', '=', True)]}"/>
</group>
</group>
<group name="weight" position="before">
<group name="store" groups="stock.group_locations" string="Counter-Part Locations Properties" attrs="{'invisible':[('type','=','service')]}">
<field name="property_stock_procurement" domain="[('usage','=','procurement')]"/>
<field name="property_stock_production" domain="[('usage','=','production')]"/>
<field name="property_stock_inventory" domain="[('usage','=','inventory')]"/>
</group>
</group>
<field name="product_manager" position="attributes">
<attribute name="context">{'default_groups_ref': ['base.group_user', 'base.group_sale_manager', 'stock.group_stock_manager']}</attribute>
</field>
<group name="procurement_uom" position="after" >
<group string="Supply Chain Information" attrs="{'invisible': [('type', '=', 'service')]}" groups="base.group_user">
<field name="route_ids" widget="many2many_checkboxes"/>
</group>
</group>
</field>
</record>