将数据初始化由产品辩题改为为模板
This commit is contained in:
@@ -30,11 +30,3 @@ class ProductTemplate(models.Model):
|
||||
self.is_manual_processing = product_template_id.is_manual_processing
|
||||
# 复制 seller_ids
|
||||
self.seller_ids = [(0, 0, {'partner_id': seller.partner_id.id, 'delay': 1.0}) for seller in product_template_id.seller_ids]
|
||||
|
||||
@api.model
|
||||
def update_related_fields(self):
|
||||
# 获取所有记录
|
||||
products = self.search([('categ_type', '=', False), ('active', '=', False)])
|
||||
for product in products:
|
||||
# 通过调用 write 方法来触发 related 字段的更新
|
||||
product.write({'categ_type': product.categ_id.type})
|
||||
@@ -56,7 +56,7 @@ class QuickEasyOrder(models.Model):
|
||||
'part_name': '',
|
||||
})
|
||||
company_id = self.env.ref('base.main_company').sudo()
|
||||
product_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_default').sudo()
|
||||
product_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_default').sudo().with_context(active_test=False).product_variant_id
|
||||
# user_id = request.env.ref('base.user_admin').sudo()
|
||||
order_id = self.env['sale.order'].sale_order_create(company_id, 'XXXXX', 'XXXXX', 'XXXXX',
|
||||
str(datetime.now()), '现结', '支付宝', state='draft')
|
||||
|
||||
@@ -31,18 +31,18 @@ class SaleOrder(models.Model):
|
||||
# 根据供货方式修改成品模板
|
||||
if line.supply_method == 'automation':
|
||||
bom_type = 'normal'
|
||||
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo()
|
||||
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id
|
||||
elif line.supply_method == 'outsourcing':
|
||||
bom_type = 'subcontract'
|
||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_outsourcing').sudo()
|
||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo()
|
||||
elif line.supply_method == 'purchase':
|
||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_purchase').sudo()
|
||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').sudo()
|
||||
elif line.supply_method == 'manual':
|
||||
bom_type = 'normal'
|
||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_manual_processing').sudo()
|
||||
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo()
|
||||
|
||||
# 复制成品模板上的属性
|
||||
line.product_id.product_tmpl_id.copy_template(product_template_id.product_tmpl_id)
|
||||
line.product_id.product_tmpl_id.copy_template(product_template_id)
|
||||
|
||||
order_id = self
|
||||
product = line.product_id
|
||||
@@ -66,10 +66,10 @@ class SaleOrder(models.Model):
|
||||
# 当成品上带有客供料选项时,生成坯料时选择“客供料”路线
|
||||
if line.is_incoming_material:
|
||||
# 将成品模板的内容复制到成品上
|
||||
customer_provided_embryo = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_raw_material_customer_provided').sudo()
|
||||
customer_provided_embryo = self.env.ref('jikimo_sale_multiple_supply_methods.product_tempalte_raw_material_customer_provided').sudo()
|
||||
# 创建坯料,客供料的批量不需要创建bom
|
||||
material_customer_provided_embryo = self.env['product.template'].sudo().no_bom_product_create(
|
||||
customer_provided_embryo,
|
||||
customer_provided_embryo.with_context(active_test=False).product_variant_id,
|
||||
item,
|
||||
order_id, 'material_customer_provided', 0, product)
|
||||
# 成品配置bom
|
||||
|
||||
Reference in New Issue
Block a user