hi i wanted to add the Add a note / Add a section in the mrp.production lines same as the sale.order Any help would be appreciated. Thanks!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi,
Please refer to the following links:
1. https://www.cybrosys.com/blog/how-to-add-a-section-and-note-for-a-custom-module-in-odoo-18
2. https://www.cybrosys.com/blog/how-to-add-a-section-and-note-for-a-custom-module-in-odoo-17
Hope it helps.
Hello Guhan Dhamodiraswamy,
Try the following code.
1. Inherit mrp.production and line model:
from odoo import models, fields
class MrpProductionLine(models.Model):
_inherit = 'mrp.production.line'
display_type = fields.Selection([
('line_section', "Section"),
('line_note', "Note"),
], default=False)
2. Inherit XML view and added the fields
<!-- views/mrp_production_view.xml -->
<odoo>
<record id="view_mrp_production_form_inherit_sections" model="ir.ui.view">
<field name="name">mrp.production.form.inherit.sections</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_raw_ids']" position="attributes">
<attribute name="context">{'default_display_type': False}</attribute>
</xpath>
<xpath expr="//field[@name='move_raw_ids']/tree" position="before">
<header>
<button name="add_section" string="Add a section" type="object" class="oe_highlight"/>
<button name="add_note" string="Add a note" type="object"/>
</header>
</xpath>
<xpath expr="//field[@name='move_raw_ids']/tree/field[@name='product_id']" position="before">
<field name="display_type" invisible="1"/>
</xpath>
<xpath expr="//field[@name='move_raw_ids']/tree" position="attributes">
<attribute name="decoration-muted">display_type != False</attribute>
</xpath>
</field>
</record>
</odoo>
3. Add add_section and add_note Methods in the mrp.production:
def add_section(self):
for order in self:
order.move_raw_ids += self.env['mrp.production.line'].new({
'display_type': 'line_section',
'name': 'New Section',
})
def add_note(self):
for order in self:
order.move_raw_ids += self.env['mrp.production.line'].new({
'display_type': 'line_note',
'name': 'New Note',
})
Hi,
Thanks for the reply.
i am using odoo18 and there is no model called mrp.production.line
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
1
mrt. 15
|
16297 | ||
|
1
okt. 23
|
3167 | ||
|
1
aug. 23
|
2652 | ||
BOM in Sale Order lines
Opgelost
|
|
1
sep. 20
|
4733 | |
|
4
nov. 19
|
2752 |
Have you tried to create a server action to add a record?