胚料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

@@ -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