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:
- 客戶關係
- e-Commerce
- 會計
- 庫存
- PoS
- Project
- MRP
此問題已被標幟
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
相關帖文 | 回覆 | 瀏覽次數 | 活動 | |
---|---|---|---|---|
|
1
3月 15
|
16005 | ||
|
1
10月 23
|
2867 | ||
|
1
8月 23
|
2211 | ||
|
1
9月 20
|
4419 | ||
|
4
11月 19
|
2621 |
Have you tried to create a server action to add a record?