添加表面工艺产品校验
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import requests
|
||||
from odoo import fields, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo import fields, models, _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -15,15 +16,15 @@ class StatusChange(models.Model):
|
||||
# 在原有方法执行前记录日志和执行其他操作
|
||||
logging.info('函数已经执行=============')
|
||||
server_product_none = []
|
||||
for order in self.order_lines:
|
||||
for order in self.order_line:
|
||||
for item in order.product_template_id.model_process_parameters_ids:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
[('server_product_process_parameters_id', '=', item.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
if not server_product:
|
||||
server_product_none.append(item.surface_technics_parameters_id.name)
|
||||
server_product_none.append(item.name)
|
||||
if server_product_none:
|
||||
raise UserError(_("请先至产品中创建表面工艺为%s的服务产品", ", ".join(server_product_none)))
|
||||
raise UserError(_("请先至产品中创建表面工艺参数为%s的服务产品", ", ".join(server_product_none)))
|
||||
|
||||
# if not server_product_none:
|
||||
# for st_item in order.product_template_id.model_process_parameters_ids:
|
||||
|
||||
@@ -272,6 +272,25 @@ class StockRule(models.Model):
|
||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||
for production_item in productions:
|
||||
if production_item.product_id.id in product_id_to_production_names:
|
||||
for st_item in production_item.product_id.model_process_parameters_ids:
|
||||
purchase_order = self.env['purchase.order'].search([('state','=','draft'),('origin','ilike',production_item.name)])
|
||||
for po in purchase_order.order_line:
|
||||
for pp in po.product_id.model_process_parameters_ids:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', pp.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': "同一个产品的制造订单数量",
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'origin': "同一个产品的制造订单名称",
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
|
||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||
if not production_item.programming_no:
|
||||
|
||||
Reference in New Issue
Block a user