From dae718ebe3d8d67ef8feaaa4a1c7693b7bc4a4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 9 Mar 2022 18:08:00 +0100 Subject: [PATCH] [IMP] mrp_attachment_mgmt: Show in the smart-button of the bom the attachments (ir.attachment) uploaded from bom and the attachments of the components. TT33396 --- mrp_attachment_mgmt/__manifest__.py | 1 - mrp_attachment_mgmt/models/mrp_bom.py | 13 ++-- .../src/js/mrp_documents_controller_mixin.js | 12 ---- mrp_attachment_mgmt/template/assets.xml | 15 ----- .../tests/test_mrp_attachment_mgmt.py | 63 ++++++++++++------- 5 files changed, 48 insertions(+), 56 deletions(-) delete mode 100644 mrp_attachment_mgmt/static/src/js/mrp_documents_controller_mixin.js delete mode 100644 mrp_attachment_mgmt/template/assets.xml diff --git a/mrp_attachment_mgmt/__manifest__.py b/mrp_attachment_mgmt/__manifest__.py index 501b50936..f78fcc35f 100644 --- a/mrp_attachment_mgmt/__manifest__.py +++ b/mrp_attachment_mgmt/__manifest__.py @@ -10,7 +10,6 @@ "depends": ["mrp"], "installable": True, "data": [ - "template/assets.xml", "views/mrp_bom_view.xml", "views/product_views.xml", "views/workorder_attachments_views.xml", diff --git a/mrp_attachment_mgmt/models/mrp_bom.py b/mrp_attachment_mgmt/models/mrp_bom.py index c8152352b..d4c2ccebc 100644 --- a/mrp_attachment_mgmt/models/mrp_bom.py +++ b/mrp_attachment_mgmt/models/mrp_bom.py @@ -8,16 +8,17 @@ class MrpBom(models.Model): def _action_see_bom_documents_products(self, products): domain = [ + # ("res_field", "=", False), "|", "&", - ("ir_attachment_id.res_model", "=", "product.product"), - ("ir_attachment_id.res_id", "in", products.ids), + ("res_model", "=", "product.product"), + ("res_id", "in", products.ids), "&", - ("ir_attachment_id.res_model", "=", "product.template"), - ("ir_attachment_id.res_id", "in", products.mapped("product_tmpl_id").ids), + ("res_model", "=", "product.template"), + ("res_id", "in", products.mapped("product_tmpl_id").ids), ] - res = self.env["mrp.bom.line"].action_see_attachments() - ctx = {"hide_upload": True, "edit": False, "delete": False} + res = self.env.ref("base.action_attachment").read()[0] + ctx = {"create": False, "edit": False} res.update({"domain": domain, "context": ctx}) return res diff --git a/mrp_attachment_mgmt/static/src/js/mrp_documents_controller_mixin.js b/mrp_attachment_mgmt/static/src/js/mrp_documents_controller_mixin.js deleted file mode 100644 index 22dad63c5..000000000 --- a/mrp_attachment_mgmt/static/src/js/mrp_documents_controller_mixin.js +++ /dev/null @@ -1,12 +0,0 @@ -odoo.define("mrp_attachment_mgmt.controllerMixin", function (require) { - "use strict"; - var MrpDocumentsKanbanController = require("mrp.MrpDocumentsKanbanController"); - MrpDocumentsKanbanController.include({ - renderButtons: function () { - const context = this.model.get(this.handle).getContext(); - if (!context.hide_upload) { - this._super(...arguments); - } - }, - }); -}); diff --git a/mrp_attachment_mgmt/template/assets.xml b/mrp_attachment_mgmt/template/assets.xml deleted file mode 100644 index 21d8c15ed..000000000 --- a/mrp_attachment_mgmt/template/assets.xml +++ /dev/null @@ -1,15 +0,0 @@ - - -