You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.7 KiB
45 lines
1.7 KiB
""""Duplicate Product BOM"""
|
|
# -*- coding: utf-8 -*-
|
|
#############################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
#
|
|
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
|
|
# Author: Cybrosys Technologies (<https://www.cybrosys.com>)
|
|
#
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
#
|
|
#############################################################################
|
|
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
|
|
|