How can I come up with different forms for different products in my Odoo setup. For Example In my inventory I have custom products e.g., product A, which should have fields X and Y, but I also have product B which doesn't have fields X and Y but has Z
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilità
- Magazzino
- PoS
- Project
- MRP
La domanda è stata contrassegnata
Hi,
Please refer to the code:
<record id="view_product_form_custom" model="ir.ui.view">
<field name="name">product.template.form.custom</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<!-- Field X visible only for Category A -->
<field name="x_field" position="attributes">
<attribute name="invisible">[('categ_id', '!=', ref('your_module.category_a'))]</attribute>
</field>
<!-- Field Y visible only for Category A -->
<field name="y_field" position="attributes">
<attribute name="invisible">[('categ_id', '!=', ref('your_module.category_a'))]</attribute>
</field>
<!-- Field Z visible only for Category B -->
<field name="z_field" position="attributes">
<attribute name="invisible">[('categ_id', '!=', ref('your_module.category_b'))]</attribute>
</field>
</field>
</record>
-invisible takes a domain-style condition.
-ref('your_module.category_a') refers to the external ID of the product category.
-This method works dynamically: when you change the category on the product form, fields appear/disappear accordingly.
-Works for both product templates and variants.
Hope it helps.
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
Registrati