mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_attachment_mgmt: Add smart-button to production orders
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
"installable": True,
|
||||
"data": [
|
||||
"views/mrp_bom_view.xml",
|
||||
"views/mrp_production_views.xml",
|
||||
"views/product_views.xml",
|
||||
"views/workorder_attachments_views.xml",
|
||||
],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from . import mrp_bom
|
||||
from . import mrp_production
|
||||
from . import mrp_workorder
|
||||
from . import product
|
||||
|
||||
10
mrp_attachment_mgmt/models/mrp_production.py
Normal file
10
mrp_attachment_mgmt/models/mrp_production.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright 2023 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import models
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
def action_show_attachments(self):
|
||||
return self.product_id._action_show_attachments()
|
||||
@@ -33,3 +33,8 @@ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase):
|
||||
attachment = self._create_attachment(self.product)
|
||||
action = self.workorder.action_see_workorder_attachments()
|
||||
self.assertIn(attachment.id, self.attachment_model.search(action["domain"]).ids)
|
||||
|
||||
def test_mrp_production_attachments(self):
|
||||
attachment = self._create_attachment(self.product)
|
||||
action = self.mrp_production.action_show_attachments()
|
||||
self.assertIn(attachment.id, self.attachment_model.search(action["domain"]).ids)
|
||||
|
||||
30
mrp_attachment_mgmt/views/mrp_production_views.xml
Normal file
30
mrp_attachment_mgmt/views/mrp_production_views.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="mrp_production_form_view" model="ir.ui.view">
|
||||
<field name="name">mrp.production.form - Add attachments smart-button</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="///button[@name='action_see_move_scrap']" position="after">
|
||||
<button
|
||||
class="oe_stat_button"
|
||||
name="action_show_attachments"
|
||||
type="object"
|
||||
icon="fa-files-o"
|
||||
string="Attachments"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_show_production_attachments" model="ir.actions.server">
|
||||
<field name="name">Attachments</field>
|
||||
<field name="model_id" ref="mrp.model_mrp_production" />
|
||||
<field name="binding_model_id" ref="mrp.model_mrp_production" />
|
||||
<field name="binding_view_types">list</field>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
if records:
|
||||
action = records.action_show_attachments()
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user