In Odoo 14.0+e (Enterprise Edition) I tried to set up a one2many field to connect the Product with the Manufacturing Order (MO) for that product. In MO there is a many2one field for Product but when I try to set up a one2many in Product for MO I cannot find it in Related fields. Any advice?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hi,
Make sure that you are adding the one2many in product.product model and not in product.template model. I have checked for the same in runbot and seems working fine for me.
This is what i did:
* open product variant form
* enable studio
* added a new one2many field
* in the relation field, using search more, search for model mrp.production, so that field from this model will listed
* select this and continue
Thanks
Hello sara,
I hope this message finds you well.
Please find code in comment.
Above code will give you one2many of MO in tab Manufacturing in product.product form view and its related fields as well.
I Hope this information proves helpful to you.
Feel free to contact us if you want us to customize this requirement for you.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Please find code here :-
To set up one2many of MO in product.product
Add py file as,
from odoo import fields, models,
class ProductProduct(models.Model):
_inherit = 'product.product'
mrp_ids = fields.One2many('mrp.production', 'product_id', string="Manufacture")
Add xml file as,
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="product_normal_form_view_inherit" model="ir.ui.view">
<field name="name">product.template.common.form.inherit</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//form/sheet/notebook" position="inside">
<page string="Manufacturing"
name="manufaturing_data">
<group>
<form>
<sheet>
<field name="mrp_ids"/>
<tree editable="bottom">
<field name="name"/>
</tree>
</sheet>
</form>
</group>
</page>
</xpath>
</field>
</record>
</data>
</odoo>
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Mar 23
|
2214 | ||
|
0
Dec 22
|
2857 | ||
|
0
Jun 21
|
2861 | ||
|
0
Jun 20
|
5331 | ||
One2many or many2one
Solved
|
|
1
Nov 19
|
2690 |