Hi Experts,
While I thought I had nailed it by extending the field and view in product.template by writing a module, I could not figured out why the change was not reflected when making operation under the inventory module.
Version used: 10 CE
What I did - Wrote an custom addons module as below: model.py
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# -*- coding: utf-8 -*-
from odoo import fields, models, api, exceptions
class EditProductTemplate(models.Model):
_name = 'product.template'
_inherit = ['product.template']
# add new fields
car_brand = fields.Char('Brand',store=True,index=True,track_visibility="on_change")
car_color = fields.Char('Color',store=True)
luxury = fields.Boolean('Luxury Car?', default=False,help="Specify if the product is newfield003.")
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
And the related abstract from views.xml:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
<record id= "product_template_form_view_inherited" model= "ir.ui.view">
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="model">product.template</field>
<field name="arch" type= "xml">
<field name="barcode" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name ="type" position="after">
<field name="luxury"/>
</field>
<field name="categ_id" position="after">
<field name="car_brand" attrs="{'invisible': ['|',('type', '!=', 'product'),('luxury, '=', False)],'required': [('type', '=', 'product'),('luxury', '=', True)]}"/>
</field>
</field>
</record>
<record id= "view_template_property_form_inherited" model= "ir.ui.view">
<field name="inherit_id" ref="stock.view_template_property_form" />
<field name="model">product.template</field >
<field name="arch" type= "xml">
<group name="group_lots_and_weight">
<field name="car_color"/>
</group>
</field>
</record>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What I had observed:
1. Click on "products" menu item to either create or view ( under sales, inventory, manufacturing, etc)
2. Launch the products form > look under the "general information" tab.
- The barcode is hidden from the form (Great!)
- New boolean "luxury?" appeared below the "Product Type"
- select product type as "stockable" AND mark the "luxury".
- the "car_brand" field column appeared due to fulfilled conditions (above)! (so far so good ;)
Look under the "inventory" tab:
- yes, the "car_color" is added. (Great!)
But wait, what i also observed:
- if i click on "inventory > operations > all transfers > click create
- Then attempt to add a product: product >click "add an item" > dropdown then click "create and edit"
- a form popup --- No!! The barcode is still there, the "luxury" and "car_brand" were not.
( I attempted to figure out whether this is indeed a different form, but I could not resolve it because I was not able to use the debug "edit formview" in this case . I tried delete & recreated the db, installed modules at different orders, moved my fields under different sequence in the module.py and xml, etc)
- And by the way, the "car_color" is OK in the latter case. It worked.
Any help, please....
Thanks in advance!
Tom
But wait, what i also observed:
- if i click on "inventory > operations > all transfers > click create
Which apps did you use to find this menu?