修改胚料匹配规则
This commit is contained in:
@@ -30,8 +30,8 @@ class Sf_Bf_Connect(http.Controller):
|
|||||||
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
ret['order_number'], i)
|
ret['order_number'], i)
|
||||||
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||||
bom = request.env['mrp.bom'].sudo().bom_create(product)
|
bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(product)
|
||||||
bom.sudo().bom_create_Line(product)
|
bom.with_user(request.env.ref("base.user_admin")).bom_create_Line(product)
|
||||||
i += 1
|
i += 1
|
||||||
res['factory_order_no'] = order_id.name
|
res['factory_order_no'] = order_id.name
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class ResMrpBom(models.Model):
|
|||||||
|
|
||||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
|
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
|
||||||
def bom_create(self, product):
|
def bom_create(self, product):
|
||||||
bom_id = self.env['mrp.bom'].sudo().create({
|
bom_id = self.env['mrp.bom'].create({
|
||||||
'product_tmpl_id': product.product_tmpl_id.id,
|
'product_tmpl_id': product.product_tmpl_id.id,
|
||||||
'type': 'normal',
|
'type': 'normal',
|
||||||
'product_qty': 1,
|
'product_qty': 1,
|
||||||
@@ -68,16 +68,18 @@ class ResMrpBom(models.Model):
|
|||||||
# 三、胚料的长宽高均要大于模型的长宽高;
|
# 三、胚料的长宽高均要大于模型的长宽高;
|
||||||
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
||||||
def bom_create_Line(self, product):
|
def bom_create_Line(self, product):
|
||||||
embryo = self.env['product.template'].sudo().search(
|
embryo = self.env['product.product'].search(
|
||||||
[('categ_id.is_embryo', '=', True), ('embryo_materials_type_id', '=', product.model_materials_type_id.id),
|
[('categ_id.is_embryo', '=', True), ('embryo_materials_type_id', '=', product.model_materials_type_id.id),
|
||||||
('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width),
|
('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width),
|
||||||
('embryo_height', '>', product.model_height)],
|
('embryo_height', '>', product.model_height)
|
||||||
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
order="volume desc"
|
order='volume desc'
|
||||||
)
|
)
|
||||||
vals = {
|
vals = {
|
||||||
'bom_id': self.id,
|
'bom_id': self.id,
|
||||||
'product_id': embryo.id,
|
'product_id': embryo.id,
|
||||||
|
'product_tmpl_id': embryo.product_tmpl_id.id,
|
||||||
'product_qty': 1,
|
'product_qty': 1,
|
||||||
'product_uom_id': 1
|
'product_uom_id': 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user