diff --git a/sf_bf_connect/controllers/controllers.py b/sf_bf_connect/controllers/controllers.py
index 4923a398..4670470a 100644
--- a/sf_bf_connect/controllers/controllers.py
+++ b/sf_bf_connect/controllers/controllers.py
@@ -23,13 +23,11 @@ class Sf_Bf_Connect(http.Controller):
# ret = json.loads(datas)
# ret = json.loads(ret['result'])
product_id = request.env.ref('sf_dlm.product_template_sf').sudo()
- logging.info('product_id:%s' % product_id)
self_machining_id = request.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
outsource_id = request.env.ref('sf_dlm.product_embryo_sf_outsource').sudo()
purchase_id = request.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
company_id = request.env.ref('base.main_company').sudo()
user_id = request.env.ref('base.user_admin').sudo()
- logging.info('user_id:%s' % user_id)
bfm_process_order_list = json.loads(kw['bfm_process_order_list'])
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(
company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'],
diff --git a/sf_dlm/data/tt.xml b/sf_dlm/data/tt.xml
deleted file mode 100644
index 847e6a80..00000000
--- a/sf_dlm/data/tt.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
- CNC加工产品模板
-
- delivery
- product
- false
-
-
-
- False
-
-
-
- 胚料
- 胚料
-
-
-
- 自加工
-
- delivery
- product
- false
-
-
-
- False
-
-
-
- 外协
-
- delivery
- product
- false
-
-
-
- False
-
-
-
- 采购
-
- delivery
- product
- false
-
-
-
- False
-
-
-
\ No newline at end of file
diff --git a/sf_dlm/models/product_template.py b/sf_dlm/models/product_template.py
index 725cbeb6..8d271396 100644
--- a/sf_dlm/models/product_template.py
+++ b/sf_dlm/models/product_template.py
@@ -22,7 +22,8 @@ class ResProductTemplate(models.Model):
('0.03', '±0.03mm'),
('0.02', '±0.02mm'),
('0.01', '±0.01mm')], string='加工精度')
- model_type_id = fields.Many2one('sf.model.type', string='模型类型')
+ product_model_type_id = fields.Many2one('sf.model.type', string='产品模型类型')
+ embryo_model_type_id = fields.Many2one('sf.model.type', string='胚料模型类型')
model_processing_panel = fields.Char('模型加工面板')
model_surface_process_id = fields.Many2one('sf.production.process', string='表面工艺')
model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数')
@@ -36,6 +37,7 @@ class ResProductTemplate(models.Model):
single_manufacturing = fields.Boolean(string="单个制造")
upload_model_file = fields.Many2many('ir.attachment', 'upload_model_file_attachment_ref', string='上传模型文件')
model_code = fields.Char('模型编码')
+ is_bfm = fields.Boolean('业务平台是否自动创建', default=False)
def _get_volume_uom_id_from_ir_config_parameter(self):
product_length_in_feet_param = self.env['ir.config_parameter'].sudo().get_param('product.volume_in_cubic_feet')
@@ -73,14 +75,14 @@ class ResProductTemplate(models.Model):
model_type = self.env['sf.model.type'].search([], limit=1)
attachment = self.attachment_create(item['model_name'], item['model_data'])
vals = {
- 'name': '%s-%s' % (order_id.name, i),
+ 'name': '%s-%s-%s' % ('P', order_id.name, i),
'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': model_type.id,
+ 'product_model_type_id': model_type.id,
'model_processing_panel': 'R',
'model_machining_precision': item['model_machining_precision'],
'model_code': item['barcode'],
@@ -135,20 +137,22 @@ class ResProductTemplate(models.Model):
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 * %s' % (
- order_id.name, i, materials_id.name, materials_type_id.name,
- item['model_long'] + model_type.embryo_tolerance, item['model_width'] + model_type.embryo_tolerance,
- item['model_height'] + model_type.embryo_tolerance),
+ 'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
+ order_id.name, i, materials_id.name, materials_type_id.name,
+ item['model_long'] + model_type.embryo_tolerance,
+ item['model_width'] + model_type.embryo_tolerance,
+ item['model_height'] + model_type.embryo_tolerance),
'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'],
+ 'embryo_model_type_id': model_type.id,
'list_price': item['price'],
'materials_id': materials_id.id,
'materials_type_id': materials_type_id.id,
+ 'is_bfm': True,
# 'route_ids': self._get_routes(route_type),
# 'categ_id': self.env.ref('sf_dlm.product_category_embryo_sf').id,
# 'model_surface_process_id': self.env['sf.production.process'].search(
@@ -208,7 +212,6 @@ class ResMrpBom(models.Model):
'product_qty': 1,
'product_uom_id': 1
}
- logging.info('bom_create_line_has-vals:%s' % vals)
return self.env['mrp.bom.line'].create(vals)
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
@@ -223,7 +226,6 @@ class ResMrpBom(models.Model):
if bom_type == 'subcontract' and product_type != False:
subcontract = self.get_supplier(product.materials_type_id)
bom_id.subcontractor_id = subcontract.partner_id.id
- logging.info('bom_create-vals:%s' % bom_id)
return bom_id
# 胚料BOM组件:选取当前胚料原材料,
@@ -239,7 +241,6 @@ class ResMrpBom(models.Model):
'product_qty': bom_line.volume * bom_line.materials_type_id.density * 1000,
'product_uom_id': bom_line.uom_id.id
}
- logging.info('bom_create_line-vals1:%s' % vals)
return self.env['mrp.bom.line'].create(vals)
# 查询材料型号默认排第一的供应商
@@ -255,7 +256,7 @@ class ResMrpBom(models.Model):
embryo_has = self.env['product.product'].search(
[('categ_id.type', '=', '胚料'), ('materials_type_id', '=', product.materials_type_id.id),
('length', '>', product.length), ('width', '>', product.width),
- ('height', '>', product.height)
+ ('height', '>', product.height), ('is_bfm', '=', False)
],
limit=1,
order='volume desc'
diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml
index 3bd65c5d..d79dc323 100644
--- a/sf_dlm/views/product_template_view.xml
+++ b/sf_dlm/views/product_template_view.xml
@@ -12,7 +12,8 @@
-
+
+
@@ -53,7 +54,7 @@
-
+
@@ -123,5 +124,19 @@
+
+
+ product.template.search
+ product.template
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py
index bdc5fc78..7a15fd2f 100644
--- a/sf_manufacturing/models/model_type.py
+++ b/sf_manufacturing/models/model_type.py
@@ -6,13 +6,16 @@ class ModelType(models.Model):
_description = '模型类型'
name = fields.Char('名称')
- embryo_tolerance = fields.Boolean('胚料的容余量', default=False)
- routing_tmpl_ids = fields.One2many('sf.model.type.routing.sort', 'model_type_id', '工序模板')
+ embryo_tolerance = fields.Integer('胚料容余')
+ product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id',
+ '成品工序模板')
+ embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id',
+ '胚料工序模板')
-class ModelTypeRoutingSort(models.Model):
- _name = 'sf.model.type.routing.sort'
- _description = '工序排序'
+class ProductModelTypeRoutingSort(models.Model):
+ _name = 'sf.product.model.type.routing.sort'
+ _description = '成品工序排序'
sequence = fields.Integer('Sequence')
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
@@ -23,11 +26,34 @@ class ModelTypeRoutingSort(models.Model):
('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
- ('解除装夹', '解除装夹'),
+ ('解除装夹', '解除装夹'), ('切割', '切割')
], string="工序类型", related='route_workcenter_id.routing_type')
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
- model_type_id = fields.Many2one('sf.model.type')
+ product_model_type_id = fields.Many2one('sf.model.type')
_sql_constraints = [
- ('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
+ ('route_model_type_uniq', 'unique (route_workcenter_id,product_model_type_id)', '成品工序不能重复!')
+ ]
+
+
+class EmbryoModelTypeRoutingSort(models.Model):
+ _name = 'sf.embryo.model.type.routing.sort'
+ _description = '胚料工序排序'
+
+ sequence = fields.Integer('Sequence')
+ route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
+ is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
+ routing_type = fields.Selection([
+ ('获取CNC加工程序', '获取CNC加工程序'),
+ ('装夹', '装夹'),
+ ('前置三元定位检测', '前置三元定位检测'),
+ ('CNC加工', 'CNC加工'),
+ ('后置三元质量检测', '后置三元质量检测'),
+ ('解除装夹', '解除装夹'), ('切割', '切割')
+ ], string="工序类型", related='route_workcenter_id.routing_type')
+ workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
+ embryo_model_type_id = fields.Many2one('sf.model.type')
+
+ _sql_constraints = [
+ ('route_model_type_uniq', 'unique (route_workcenter_id,embryo_model_type_id)', '胚料工序不能重复!')
]
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index 5046e128..d84f633d 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
-from odoo import api, fields, models,_
+from odoo import api, fields, models, _
class resProduct(models.Model):
_inherit = 'product.template'
model_file = fields.Binary('模型文件')
+
class MrpProduction(models.Model):
_inherit = 'mrp.production'
_description = "制造订单"
@@ -102,25 +103,34 @@ class MrpProduction(models.Model):
'operation_id': operation.id,
'state': 'pending',
}]
- # 根据加工面板的面数及对应的工序模板生成工单
- i = 0
- processing_panel_len = len(production.product_id.model_processing_panel.split(','))
- for k in (production.product_id.model_processing_panel.split(',')):
- routingworkcenter = self.env['sf.model.type.routing.sort'].search(
- [('model_type_id', '=', production.product_id.model_type_id.id)],
+ if production.product_id.categ_id.type == '成品':
+ # 根据加工面板的面数及对应的工序模板生成工单
+ i = 0
+ processing_panel_len = len(production.product_id.model_processing_panel.split(','))
+ for k in (production.product_id.model_processing_panel.split(',')):
+ product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
+ [('product_model_type_id', '=', production.product_id.product_model_type_id.id)],
+ order='sequence asc'
+ )
+ i += 1
+ for route in product_routing_workcenter:
+ if i == 1 and route.routing_type == '获取CNC加工程序':
+ workorders_values.append(
+ self.env['mrp.workorder'].json_workorder_str('', production, route))
+ if route.is_repeat == True:
+ workorders_values.append(
+ self.env['mrp.workorder'].json_workorder_str(k, production, route))
+ if i == processing_panel_len and route.routing_type == '解除装夹':
+ workorders_values.append(
+ self.env['mrp.workorder'].json_workorder_str(k, production, route))
+ elif production.product_id.categ_id.type == '胚料':
+ embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
+ [('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)],
order='sequence asc'
)
- i += 1
- for route in routingworkcenter:
- if i == 1 and route.routing_type == '获取CNC加工程序':
- workorders_values.append(
- self.env['mrp.workorder'].json_workorder_str('', production, route))
- if route.is_repeat == True:
- workorders_values.append(
- self.env['mrp.workorder'].json_workorder_str(k, production, route))
- if i == processing_panel_len and route.routing_type == '解除装夹':
- workorders_values.append(
- self.env['mrp.workorder'].json_workorder_str(k, production, route))
+ for route in embryo_routing_workcenter:
+ workorders_values.append(
+ self.env['mrp.workorder'].json_workorder_str('', production, route))
production.workorder_ids = workorders_values
for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected()
@@ -181,7 +191,7 @@ class MrpProduction(models.Model):
'operation_id': operation.id,
'state': 'pending',
}]
- # 根据加工面板的面数及对应的工序模板生成工单
+ # 根据加工面板的面数及对应的成品工序模板生成工单
i = 0
production.product_id.model_processing_panel = k
processing_panel_len = len(k)
diff --git a/sf_manufacturing/models/mrp_routing_workcenter.py b/sf_manufacturing/models/mrp_routing_workcenter.py
index 23123d14..60ec21f6 100644
--- a/sf_manufacturing/models/mrp_routing_workcenter.py
+++ b/sf_manufacturing/models/mrp_routing_workcenter.py
@@ -11,6 +11,7 @@ class ResMrpRoutingWorkcenter(models.Model):
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
+ ('切割', '切割')
], string="工序类型")
is_repeat = fields.Boolean('重复', default=False)
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
@@ -38,26 +39,3 @@ class ResMrpRoutingWorkcenter(models.Model):
in %s group by workcenter_id
order by count(*),workcenter_id asc limit 1 """, [tuple(workcenter_ids)])
return self.env.cr.dictfetchall()[0].get('workcenter_id')
-
-
-# class ModelTypeRoutingSort(models.Model):
-# _name = 'sf.model.type.routing.sort'
-# _description = '工序排序'
-#
-# sequence = fields.Integer('Sequence')
-# route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
-# is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
-# routing_type = fields.Selection([
-# ('获取CNC加工程序', '获取CNC加工程序'),
-# ('装夹', '装夹'),
-# ('前置三元定位检测', '前置三元定位检测'),
-# ('CNC加工', 'CNC加工'),
-# ('后置三元质量检测', '后置三元质量检测'),
-# ('解除装夹', '解除装夹'),
-# ], string="工序类型", related='route_workcenter_id.routing_type')
-# workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
-# model_type_id = fields.Many2one('sf.model.type')
-#
-# _sql_constraints = [
-# ('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
-# ]
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 3d2e17e2..185b24ed 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -29,6 +29,7 @@ class ResMrpWorkOrder(models.Model):
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
+ ('切割', '切割')
], string="工序类型")
@api.onchange('users_ids')
@@ -89,7 +90,6 @@ class ResMrpWorkOrder(models.Model):
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工")
tray_code = fields.Char(string="托盘")
-
# 计算配料中心点和与x轴倾斜度方法
def getcenter(self):
try:
@@ -135,7 +135,6 @@ class ResMrpWorkOrder(models.Model):
except:
raise UserError("参数计算有误")
-
def json_workorder_str(self, k, production, route):
workorders_values_str = [0, '', {
'product_uom_id': production.product_uom_id.id,
@@ -171,7 +170,9 @@ class ResMrpWorkOrder(models.Model):
'target': 'new',
'domain': [('workorder_id', '=', self.id)]
}
+
tray_id = fields.Many2one('sf.tray', string="托盘信息")
+
# 扫码绑定托盘方法
def gettray(self):
@@ -230,7 +231,6 @@ class ResMrpWorkOrder(models.Model):
tray.unclamp()
self.tray_id = tray
-
# return {
# 'name': _('New Maintenance Request'),
# 'view_mode': 'form',
@@ -288,7 +288,6 @@ class ResMrpWorkOrder(models.Model):
else:
return True
-
# cnc程序获取
def fetchCNC(self):
try:
@@ -499,7 +498,6 @@ class CNCprocessing(models.Model):
download_state = ftp.download_file_tree(remotepath, serverdir)
return download_state
-
# 将nc文件存到attach的datas里
def write_file(self, nc_file_path, cnc):
if os.path.exists(nc_file_path):
diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv
index f2527022..f2bf5270 100644
--- a/sf_manufacturing/security/ir.model.access.csv
+++ b/sf_manufacturing/security/ir.model.access.csv
@@ -1,7 +1,8 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_cnc_processing,sf_cnc_processing,model_sf_cnc_processing,base.group_user,1,1,1,1
access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1
-access_sf_model_type_routing_sort,sf_model_type_routing_sort,model_sf_model_type_routing_sort,base.group_user,1,1,1,1
+access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,base.group_user,1,1,1,1
+access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,base.group_user,1,1,1,1
diff --git a/sf_manufacturing/views/model_type_view.xml b/sf_manufacturing/views/model_type_view.xml
index 58fd70be..e44f7311 100644
--- a/sf_manufacturing/views/model_type_view.xml
+++ b/sf_manufacturing/views/model_type_view.xml
@@ -31,10 +31,21 @@