[IMP] mrp_attachment_mgmt: Add smart-button to production orders

This commit is contained in:
Pedro M. Baeza
2023-03-27 13:17:25 +02:00
parent a23f1ed5b3
commit 42f59d377e
5 changed files with 47 additions and 0 deletions

View File

@@ -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",
],

View File

@@ -1,3 +1,4 @@
from . import mrp_bom
from . import mrp_production
from . import mrp_workorder
from . import product

View 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()

View File

@@ -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)

View 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>