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
- Buchhaltung
- Lager
- PoS
- Project
- MRP
Diese Frage wurde gekennzeichnet
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
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
RegistrierenVerknüpfte Beiträge | Antworten | Ansichten | Aktivität | |
---|---|---|---|---|
|
1
März 15
|
16039 | ||
|
1
Okt. 23
|
2872 | ||
|
1
Aug. 23
|
2217 | ||
BOM in Sale Order lines
Gelöst
|
|
1
Sept. 20
|
4428 | |
|
4
Nov. 19
|
2625 |
Have you tried to create a server action to add a record?