From ba65d0e259367e6cb420877e17adeeb0c1f1776c Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Tue, 15 Jan 2019 07:06:13 +0000 Subject: [PATCH] [FIX] mrp: show correct number of attachments on bom lines Display a BoM. On BoM lines, there is an attachment feature that creates a mrp.document, which is basically a container for an attachment. This commit fixes the view which displayed 'no attachment' when there were some and vice versa. It also fixes the computation of the number of attachment: the displayed view is on mrp.document, but the computation is done on ir.attachment. As a result if there are other unrelated attachments (such as digital files) they would be counted but not displayed. opw 1923441 closes odoo/odoo#30208 --- addons/mrp/models/mrp_bom.py | 2 +- addons/mrp/views/mrp_bom_views.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index a7c18ef1117..e5af5c3aeb3 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -261,7 +261,7 @@ class MrpBomLine(models.Model): @api.one @api.depends('product_id') def _compute_has_attachments(self): - nbr_attach = self.env['ir.attachment'].search_count([ + nbr_attach = self.env['mrp.document'].search_count([ '|', '&', ('res_model', '=', 'product.product'), ('res_id', '=', self.product_id.id), '&', ('res_model', '=', 'product.template'), ('res_id', '=', self.product_id.product_tmpl_id.id)]) diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index f4dcae65b5c..0ba855f2b65 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -62,8 +62,8 @@ -