bfm分配工厂:

1.销售页面:客户的值为业务平台,
2.没有原材料,事务回滚
3.去掉注释和没用到的代码
This commit is contained in:
jinling.yang
2023-02-01 18:27:29 +08:00
parent e2561bee34
commit e8d923df03
13 changed files with 84 additions and 52 deletions

View File

@@ -1,10 +1,6 @@
from odoo import models, fields, api
from odoo.exceptions import ValidationError
from odoo import models, fields
import logging
import base64
import os
# from OCC.Extend.DataExchange import read_step_file, write_stl_file
from odoo.modules import get_resource_path
class ResProductTemplate(models.Model):
@@ -12,6 +8,8 @@ class ResProductTemplate(models.Model):
# 模型的长,宽,高,体积,精度,材料
model_name = fields.Char('模型名称')
categ_type = fields.Selection(
[("成品", "成品"), ("胚料", "胚料"), ("原材料", "原材料")], string='产品的类别', related='categ_id.type', store=True)
model_long = fields.Float('模型长[mm]', digits=(16, 3))
model_width = fields.Float('模型宽[mm]', digits=(16, 3))
model_height = fields.Float('模型高[mm]', digits=(16, 3))
@@ -223,7 +221,7 @@ class ResMrpBom(models.Model):
'product_qty': 1,
'product_uom_id': 1
})
if bom_type == 'subcontract' and product_type != False:
if bom_type == 'subcontract' and product_type is not False:
subcontract = self.get_supplier(product.materials_type_id)
bom_id.subcontractor_id = subcontract.partner_id.id
return bom_id
@@ -233,15 +231,18 @@ class ResMrpBom(models.Model):
# 胚料所需原材料公式当前的胚料的体积立方米m³ *材料密度 * 1000 = 所需原材料重量KG公斤
def bom_create_line(self, embryo):
# 选取当前胚料原材料
bom_line = self.get_raw_bom(embryo)
vals = {
'bom_id': self.id,
'product_id': bom_line.id,
'product_tmpl_id': bom_line.product_tmpl_id.id,
'product_qty': bom_line.volume * bom_line.materials_type_id.density * 1000,
'product_uom_id': bom_line.uom_id.id
}
return self.env['mrp.bom.line'].create(vals)
raw_bom_line = self.get_raw_bom(embryo)
if raw_bom_line:
bom_line = self.env['mrp.bom.line'].create({
'bom_id': self.id,
'product_id': raw_bom_line.id,
'product_tmpl_id': raw_bom_line.product_tmpl_id.id,
'product_qty': round(embryo.volume / 1000000000 * raw_bom_line.materials_type_id.density, 2),
'product_uom_id': raw_bom_line.uom_id.id,
})
return bom_line
else:
return False
# 查询材料型号默认排第一的供应商
def get_supplier(self, materials_type):