修改胚料匹配规则

This commit is contained in:
jinling.yang
2022-10-19 11:16:35 +08:00
parent 5b75e5423a
commit c2bf0b09a9
2 changed files with 8 additions and 6 deletions

View File

@@ -54,7 +54,7 @@ class ResMrpBom(models.Model):
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
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,
'type': 'normal',
'product_qty': 1,
@@ -68,16 +68,18 @@ class ResMrpBom(models.Model):
# 三、胚料的长宽高均要大于模型的长宽高;
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
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),
('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width),
('embryo_height', '>', product.model_height)],
('embryo_height', '>', product.model_height)
],
limit=1,
order="volume desc"
order='volume desc'
)
vals = {
'bom_id': self.id,
'product_id': embryo.id,
'product_tmpl_id': embryo.product_tmpl_id.id,
'product_qty': 1,
'product_uom_id': 1
}