24 lines
961 B
Python
24 lines
961 B
Python
from odoo import models, fields
|
|
|
|
|
|
class ProductTemplate(models.Model):
|
|
_inherit = 'product.template'
|
|
|
|
purchase_request_id = fields.Many2one('purchase.request', string='采购申请')
|
|
|
|
def no_bom_product_create(self, product_id, item, order_id, route_type, i, finish_product):
|
|
""" 创建坯料时,复制采购申请 """
|
|
template_id = super(ProductTemplate, self).no_bom_product_create(product_id, item, order_id, route_type, i,
|
|
finish_product)
|
|
template_id.purchase_request = product_id.purchase_request
|
|
return template_id
|
|
|
|
|
|
class ProdcutProduct(models.Model):
|
|
_inherit = 'product.product'
|
|
|
|
def copy_template(self, product_template_id):
|
|
""" 复制成品模板时,复制采购申请 """
|
|
super(ProdcutProduct, self).copy_template(product_template_id)
|
|
self.purchase_request = product_template_id.purchase_request
|