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
- Apskaita
- Atsarga
- PoS
- Project
- MRP
This question has been flagged
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
RegistracijaRelated Posts | Replies | Rodiniai | Veikla | |
---|---|---|---|---|
|
1
kov. 15
|
16007 | ||
|
1
spal. 23
|
2867 | ||
|
1
rugp. 23
|
2212 | ||
BOM in Sale Order lines
Solved
|
|
1
rugs. 20
|
4421 | |
|
4
lapkr. 19
|
2624 |
Have you tried to create a server action to add a record?