diff --git a/.tx/config b/.tx/config index b132de9a8f9..62c7357f296 100644 --- a/.tx/config +++ b/.tx/config @@ -942,11 +942,6 @@ file_filter = addons/website_sale_management/i18n/.po source_file = addons/website_sale_management/i18n/website_sale_management.pot source_lang = en -[odoo-12.website_sale_options] -file_filter = addons/website_sale_options/i18n/.po -source_file = addons/website_sale_options/i18n/website_sale_options.pot -source_lang = en - [odoo-12.website_sale_stock] file_filter = addons/website_sale_stock/i18n/.po source_file = addons/website_sale_stock/i18n/website_sale_stock.pot diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index 3ff3a18920d..bcfcef5ab4f 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -234,6 +234,7 @@ class MrpBomLine(models.Model): bom_id = fields.Many2one( 'mrp.bom', 'Parent BoM', index=True, ondelete='cascade', required=True) + parent_product_tmpl_id = fields.Many2one('product.template', 'Parent Product Template', related='bom_id.product_tmpl_id') attribute_value_ids = fields.Many2many( 'product.attribute.value', string='Apply on Variants', help="BOM Product Variants needed form apply this line.") @@ -294,6 +295,13 @@ class MrpBomLine(models.Model): if self.product_id: self.product_uom_id = self.product_id.uom_id.id + @api.onchange('parent_product_tmpl_id') + def onchange_parent_product(self): + return {'domain': {'attribute_value_ids': [ + ('id', 'in', self.parent_product_tmpl_id.mapped('attribute_line_ids.value_ids.id')), + ('attribute_id.create_variant', '!=', 'never') + ]}} + @api.model_create_multi def create(self, vals_list): for values in vals_list: diff --git a/addons/mrp/report/mrp_report_bom_structure.py b/addons/mrp/report/mrp_report_bom_structure.py index 5ffe4772dcd..0364ebe54be 100644 --- a/addons/mrp/report/mrp_report_bom_structure.py +++ b/addons/mrp/report/mrp_report_bom_structure.py @@ -24,6 +24,14 @@ class ReportBomStructure(models.AbstractModel): doc['report_type'] = 'pdf' doc['report_structure'] = data and data.get('report_type') or 'all' docs.append(doc) + if not candidates: + if data and data.get('childs'): + doc = self._get_pdf_line(bom_id, qty=int(data.get('quantity')), child_bom_ids=json.loads(data.get('childs'))) + else: + doc = self._get_pdf_line(bom_id, unfolded=True) + doc['report_type'] = 'pdf' + doc['report_structure'] = data and data.get('report_type') or 'all' + docs.append(doc) return { 'doc_ids': docids, 'doc_model': 'mrp.bom', @@ -95,6 +103,12 @@ class ReportBomStructure(models.AbstractModel): product = self.env['product.product'].browse(int(product_id)) else: product = bom.product_id or bom.product_tmpl_id.product_variant_id + if product: + attachments = self.env['mrp.document'].search(['|', '&', ('res_model', '=', 'product.product'), + ('res_id', '=', product.id), '&', ('res_model', '=', 'product.template'), ('res_id', '=', product.product_tmpl_id.id)]) + else: + product = bom.product_tmpl_id + attachments = self.env['mrp.document'].search([('res_model', '=', 'product.template'), ('res_id', '=', product.id)]) operations = self._get_operation_line(bom.routing_id, (bom_quantity / bom.product_qty), 0) lines = { 'bom': bom, @@ -108,8 +122,7 @@ class ReportBomStructure(models.AbstractModel): 'level': level or 0, 'operations': operations, 'operations_cost': sum([op['total'] for op in operations]), - 'attachments': self.env['mrp.document'].search(['|', '&', - ('res_model', '=', 'product.product'), ('res_id', '=', product.id), '&', ('res_model', '=', 'product.template'), ('res_id', '=', product.product_tmpl_id.id)]), + 'attachments': attachments, 'operations_time': sum([op['duration_expected'] for op in operations]) } components, total = self._get_bom_lines(bom, bom_quantity, product, line_id, level) diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index af7b63d25be..f4dcae65b5c 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -57,7 +57,7 @@ - + @@ -65,8 +65,9 @@