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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 3 15
|
16017 | ||
|
1
thg 10 23
|
2868 | ||
|
1
thg 8 23
|
2213 | ||
BOM in Sale Order lines
Đã xử lý
|
|
1
thg 9 20
|
4423 | |
|
4
thg 11 19
|
2624 |
Have you tried to create a server action to add a record?