# Conflicts:
#	sf_dlm/data/product_data.xml
This commit is contained in:
jinling.yang
2022-12-12 16:56:04 +08:00
4 changed files with 127 additions and 123 deletions

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data noupdate="1">
<record id="product_template_sf" model="product.product">
<record id="product_template_sf" model="product.product">
<field name="name">CNC加工产品模板</field>
<!-- <field name="categ_id" ref="product.product_category_5"/>-->
<!-- <field name="categ_id" ref="product.product_category_5"/>-->
<field name="invoice_policy">delivery</field>
<field name="detailed_type">product</field>
<field name="purchase_ok">false</field>
@@ -53,7 +53,5 @@
<field name="company_id" ref="base.main_company"/>
<field name="active">False</field>
</record>
</data>
</odoo>

View File

@@ -29,6 +29,12 @@ class ResProductTemplate(models.Model):
materials_id = fields.Many2one('sf.production.materials', string='材料')
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
# volume = fields.Float(compute='_compute_volume', store=True)
single_manufacturing = fields.Boolean(string="单个制造")
# @api.depends('long', 'width', 'height')
# def _compute_volume(self):
# self.volume = self.long * self.width * self.height
single_manufacturing = fields.Boolean(string="单个制造")
@@ -60,6 +66,11 @@ class ResProductTemplate(models.Model):
'model_long': item['model_long'],
'model_width': item['model_width'],
'model_height': item['model_height'],
'length': item['long'],
'width': item['width'],
'height': item['height'],
'volume': item['long'] * item['width'] * item['height'],
'model_price': item['price'],
'length': item['model_long'],
'width': item['model_width'],
'height': item['model_height'],
@@ -161,6 +172,10 @@ class ResMrpBom(models.Model):
# 二、胚料的材料型号与生成产品的材料型号一致;
# 三、胚料的长宽高均要大于模型的长宽高;
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
def bom_create_Line(self, product):
logging.info('bom_create_Line:%s' % product)
embryo = self.env['product.product'].search(
[('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
# 创建新的胚料,根据胚料材料型号的获取方式(
# 自加工,外协,采购) 的配置, 选择不同的库存路线,一种材料型号配置一个路线相关的配置:
# 材料型号配置不同的获取方式: (自加工, 外协, 采购);
@@ -185,6 +200,8 @@ class ResMrpBom(models.Model):
limit=1,
order='volume desc'
)
logging.info('bom_create_Line1:%s' % product)
return self.env['mrp.bom.line'].create(vals)
if embryo:
rate_of_waste = ((embryo.volume - product.model_volume) % embryo.volume) * 100
if rate_of_waste <= 20: