Skip to Content
Menu
This question has been flagged
2 Replies
4877 Views

i want to inherit the form view of the product.template model, here is my code 

<?xml version="1.0" encoding="utf-8"?> 
<odoo>
    <data>
    <record id="view_tech_template_inherit" model="ir.ui.view">
     <field name="name">product.template.form.inherit</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[@name='purchase']" position="replace">
<field name="field_one"/>
    </xpath>
    </field>
    </record> </data> </odoo>


i already called in the dependencies the product module, and i inherited the product.template model on my custom module, this way 

from odoo import api, fields, models


class tech_product(models.Model):
    _inherit = "product.template"
    
    field_one = fields.Char('conso')



what i am missing else ? 

Avatar
Discard

add the error message/log along with the question

Best Answer

Good Morning

Warning: adding or deleting attributes will delete and recreate existing variants and lead to the loss of their possible customizations.

Can someone please assist as i am totally lost. Added new attributes and i have this message pop up


Avatar
Discard
Best Answer

Check xpath location, if you want  field after another field change  into position="after"

Sample xpath to override product_template_only_form_view core module


<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>

<div name="button_box" position="inside">
<button name="%(product.product_variant_action)d" type="action"
icon="fa-sitemap" class="oe_stat_button"
attrs="{'invisible': [('product_variant_count', '&lt;=', 1)]}"
groups="product.group_product_variant">
<field string="Variants" name="product_variant_count" widget="statinfo" />
</button>
</div>

<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" context="{'show_attribute': False}">
<tree string="Variants" editable="bottom">
<field name="attribute_id" attrs="{'readonly': [('id', '!=', False)]}"/>
<field name="value_ids" widget="many2many_tags" options="{'no_create_edit': True}" context="{'default_attribute_id': attribute_id, 'show_attribute': False}"/>
</tree>
</field>
<p class="oe_grey oe_edit_only">
<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>
 
Avatar
Discard
Related Posts Replies Views Activity
1
Dec 19
1477
1
Dec 21
2633
1
Jun 21
1743
0
Nov 20
1556
1
Jul 20
1639