""""Duplicate Product BOM""" # -*- coding: utf-8 -*- ############################################################################# # # Cybrosys Technologies Pvt. Ltd. # # Copyright (C) 2023-TODAY Cybrosys Technologies() # Author: Cybrosys Technologies () # # You can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # (LGPL v3) along with this program. # If not, see . # ############################################################################# from odoo import models class ProductTemplate(models.Model): _inherit = 'product.template' def copy(self, default=None): result = super().copy(default) result.bom_count = self.bom_count for rec in self.bom_ids: value = self.env['mrp.bom'].create({ 'type': rec.type, 'product_tmpl_id': result.id, 'product_qty': rec.product_qty, 'code': rec.code, 'company_id': rec.company_id.id, }) value.bom_line_ids = [(0, 0, { 'product_id': line.product_id.id, 'product_qty': line.product_qty, 'attachments_count': line.attachments_count, }) for line in rec.bom_line_ids] return result