胚料bug修复,销售订单明细行路线修复,编程单下发优化

This commit is contained in:
jinling.yang
2022-12-27 17:28:47 +08:00
parent c6b9953e40
commit 5fcb17d048
13 changed files with 158 additions and 112 deletions

View File

@@ -15,7 +15,7 @@
<field name="type">原材料</field>
</record>
<record id="product_template_sf" model="product.template">
<record id="product_template_sf" model="product.product">
<field name="name">CNC加工产品模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="product_category_finished_sf"/>
@@ -31,7 +31,7 @@
<field name="tracking">serial</field>
</record>
<record id="product_embryo_sf_self_machining" model="product.template">
<record id="product_embryo_sf_self_machining" model="product.product">
<field name="name">胚料自加工模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="product_category_embryo_sf"/>
@@ -48,7 +48,7 @@
<!-- <field name="active" eval="False"/>-->
</record>
<record id="product_embryo_sf_outsource" model="product.template">
<record id="product_embryo_sf_outsource" model="product.product">
<field name="name">胚料外协加工模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="product_category_embryo_sf"/>
@@ -63,7 +63,7 @@
<field name="tracking">serial</field>
<!-- <field name="active" eval="False"/>-->
</record>
<record id="product_embryo_sf_purchase" model="product.template">
<record id="product_embryo_sf_purchase" model="product.product">
<field name="name">胚料采购模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="product_category_embryo_sf"/>

View File

@@ -29,6 +29,7 @@ class ResProductTemplate(models.Model):
materials_id = fields.Many2one('sf.production.materials', string='材料')
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
single_manufacturing = fields.Boolean(string="单个制造")
model_id = fields.Many2one('ir.attachment', string='模型')
# 胚料的库存路线设置
# def _get_routes(self, route_type):
@@ -53,19 +54,24 @@ class ResProductTemplate(models.Model):
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
def product_create(self, product_id, item, order_id, order_number, i):
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
# copy_product_id.product_tmpl_id.active = True
copy_product_id.product_tmpl_id.active = True
model_type = self.env['sf.model.type'].search([], limit=1)
vals = {
'name': '%s-%s' % (order_id.name, i),
'model_long': item['model_long'],
'model_width': item['model_width'],
'model_height': item['model_height'],
'model_long': item['model_long'] + model_type.embryo_tolerance,
'model_width': item['model_width'] + model_type.embryo_tolerance,
'model_height': item['model_height'] + model_type.embryo_tolerance,
'model_volume': (item['model_long'] + model_type.embryo_tolerance) * (
item['model_width'] + model_type.embryo_tolerance) * (
item['model_height'] + model_type.embryo_tolerance),
'model_type_id': 1,
'model_machining_precision': item['model_machining_precision'],
'model_processing_panel': 'R,U',
# 'model_machining_precision': item['model_machining_precision'],
'model_processing_panel': 'A',
'model_machining_precision': '±0.10mm',
'length': item['model_long'],
'width': item['model_width'],
'height': item['model_height'],
'volume': (item['model_long'] * item['model_width'] * item['model_height']),
'volume': item['model_long'] * item['model_width'] * item['model_height'],
# 'model_price': item['price'],
# 'single_manufacturing': True,
'list_price': item['price'],
@@ -74,8 +80,8 @@ class ResProductTemplate(models.Model):
[('materials_no', '=', item['texture_code'])]).id,
'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]).id,
# 'model_surface_process_id': self.env['sf.production.process'].search(
# [('process_encode', '=', item['surface_process_code'])]).id,
'model_surface_process_id': self.env['sf.production.process'].search(
[('process_encode', '=', item['surface_process_code'])]).id,
# 'model_process_parameters_id': self.env['sf.processing.technology'].search(
# [('process_encode', '=', item['process_parameters_code'])]).id,
'model_remark': item['remark'],
@@ -85,27 +91,40 @@ class ResProductTemplate(models.Model):
# 'route_ids': self._get_routes('')
}
copy_product_id.sudo().write(vals)
# product_id.active = False
copy_product_id.model_id = self.attachment_create(item['model_name'], item['model_data'])
product_id.product_tmpl_id.active = False
return copy_product_id
def attachment_create(self, name, data):
attachment = self.env['ir.attachment'].create({
'datas': base64.b64encode(data),
'type': 'binary',
'description': '模型文件',
'name': name
})
return attachment
# 创建胚料
def no_bom_product_create(self, product_id, item, order_id, route_type):
no_bom_copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
# no_bom_copy_product_id.product_tmpl_id.active = True
no_bom_copy_product_id.product_tmpl_id.active = True
materials_id = self.env['sf.production.materials'].search(
[('materials_no', '=', item['texture_code'])])
materials_type_id = self.env['sf.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])])
model_type = self.env['sf.model.type'].search([], limit=1)
supplier = self.env['mrp.bom'].get_supplier(materials_type_id)
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
vals = {
'name': '%s %s %s %s * %s * %s' % (
order_id.name, materials_id.name, materials_type_id.name, item['model_long'], item['model_width'],
item['model_height']),
'length': item['model_long'],
'width': item['model_width'],
'height': item['model_height'],
'volume': item['model_long'] * item['model_width'] * item['model_height'],
'length': item['model_long'] + model_type.embryo_tolerance,
'width': item['model_width'] + model_type.embryo_tolerance,
'height': item['model_height'] + model_type.embryo_tolerance,
'volume': (item['model_long'] + model_type.embryo_tolerance) * (
item['model_width'] + model_type.embryo_tolerance) * (
item['model_height'] + model_type.embryo_tolerance),
# 'model_price': item['price'],
'list_price': item['price'],
'materials_id': materials_id.id,
@@ -131,7 +150,7 @@ class ResProductTemplate(models.Model):
logging.info('no_bom_copy_product_id-seller_ids-vals:%s' % no_bom_copy_product_id.seller_ids)
no_bom_copy_product_id.write(vals)
logging.info('no_bom_copy_product_id-vals:%s' % vals)
# product_id.active = False
product_id.product_tmpl_id.active = False
return no_bom_copy_product_id
# 根据模型类型默认给模型的长高宽加配置的长度;
@@ -140,11 +159,11 @@ class ResProductTemplate(models.Model):
if not self.model_type_id:
return
model_type = self.env['sf.model.type'].search(
[('id', '=', self.model_type_id.id), ('embryo_tolerance', '=', True)])
[('id', '=', self.model_type_id.id)])
if model_type:
self.model_long = self.model_long + 1
self.model_width = self.model_width + 1
self.model_height = self.model_width + 1
self.model_long = self.model_long + embryo_tolerance
self.model_width = self.model_width + embryo_tolerance
self.model_height = self.model_width + embryo_tolerance
else:
return

View File

@@ -101,8 +101,8 @@
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<field name="subcontractor_ids" position="replace">
<field name="subcontractor_id" widget="many2one_tags" readonly="1"
attrs="{'invisible':[('type', 'in', ['normal','phantom'])]}"/>
<field name="subcontractor_id"
attrs="{'invisible': [('type', '!=', 'subcontract')], 'required': [('type', '=', 'subcontract')]}"/>
</field>
</field>
</record>