Compare commits
48 Commits
master_sf_
...
release/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f005a29beb | ||
|
|
6a24776701 | ||
|
|
09d06980b5 | ||
|
|
8b492fc093 | ||
|
|
ba03790832 | ||
|
|
3148cd55b8 | ||
|
|
665ebaab9e | ||
|
|
40969adc2c | ||
|
|
95e89d8979 | ||
|
|
5b400b746e | ||
|
|
828b4b0f6b | ||
|
|
7d2c705c35 | ||
|
|
f3c2db7add | ||
|
|
0af6d7f4cd | ||
|
|
a82a54c464 | ||
|
|
d4253b21fe | ||
|
|
8356e898aa | ||
|
|
f67d08fc88 | ||
|
|
0a40409c6c | ||
|
|
927f74213e | ||
|
|
8b8570a901 | ||
|
|
ec30a07394 | ||
|
|
9110c81c73 | ||
|
|
5f4ecf8ff9 | ||
|
|
e453508f17 | ||
|
|
733b554942 | ||
|
|
eff2032762 | ||
|
|
16a00bdb10 | ||
|
|
de6014d1dd | ||
|
|
66b66a935f | ||
|
|
612906e01d | ||
|
|
21f94e5523 | ||
|
|
f8c1d75b63 | ||
|
|
fcba3b18b7 | ||
|
|
c6a509c6f4 | ||
|
|
67b48814f6 | ||
|
|
1f32aafc9b | ||
|
|
b390712308 | ||
|
|
c035ab8156 | ||
|
|
25dddb5b3b | ||
|
|
bc4dc82beb | ||
|
|
47305a2e61 | ||
|
|
9e58835082 | ||
|
|
63fa0e0c37 | ||
|
|
c6c9974326 | ||
|
|
d63c3b76bf | ||
|
|
3793d0a174 | ||
|
|
c1935e62b9 |
@@ -331,7 +331,7 @@ class ToolInventory(models.Model):
|
|||||||
work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料')
|
work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料')
|
||||||
life_span = fields.Float('寿命(min)')
|
life_span = fields.Float('寿命(min)')
|
||||||
|
|
||||||
tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组')
|
tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组', required=True)
|
||||||
|
|
||||||
active = fields.Boolean('已归档', default=True)
|
active = fields.Boolean('已归档', default=True)
|
||||||
|
|
||||||
|
|||||||
@@ -555,9 +555,9 @@
|
|||||||
<field name="model">sf.tool.inventory</field>
|
<field name="model">sf.tool.inventory</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="功能刀具清单" create="1" edit="1" delete="0" editable="bottom">
|
<tree string="功能刀具清单" create="1" edit="1" delete="0" editable="bottom">
|
||||||
<field name="name"/>
|
<field name="name" attrs="{'readonly': [('id', '!=', False)]}"/>
|
||||||
<field name="functional_cutting_tool_model_id"/>
|
<field name="functional_cutting_tool_model_id"/>
|
||||||
<field name="tool_groups_id"/>
|
<field name="tool_groups_id" required="1" attrs="{'readonly': [('id', '!=', False)]}"/>
|
||||||
<field name="work_material"/>
|
<field name="work_material"/>
|
||||||
<field name="life_span"/>
|
<field name="life_span"/>
|
||||||
<field name="prefix" optional="hide"/>
|
<field name="prefix" optional="hide"/>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ _logger = logging.getLogger(__name__)
|
|||||||
class JdEclp(models.Model):
|
class JdEclp(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|
||||||
senderNickName = fields.Char(string='寄件工厂简称', required=True, default='MW')
|
senderNickName = fields.Char(string='寄件工厂简称', required=True, default='XT')
|
||||||
|
|
||||||
# receiverName = fields.Char(string='收件人姓名')
|
# receiverName = fields.Char(string='收件人姓名')
|
||||||
# receiverMobile = fields.Char(string='收件人电话')
|
# receiverMobile = fields.Char(string='收件人电话')
|
||||||
|
|||||||
@@ -5,39 +5,46 @@
|
|||||||
<field name="model">mrp.workorder</field>
|
<field name="model">mrp.workorder</field>
|
||||||
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
|
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//header" position="inside">
|
<!-- <xpath expr="//header" position="inside">-->
|
||||||
<button string="程序下载" name="cnc_file_download" type="object" class="oe_highlight" attrs='{"invisible": ["|",
|
<!-- <button string="程序下载" name="cnc_file_download" type="object" class="oe_highlight" attrs='{"invisible": ["|",-->
|
||||||
("user_permissions","=",False),("routing_type","!=","CNC加工")]}'/>
|
<!-- ("user_permissions","=",False),("routing_type","!=","CNC加工")]}'/>-->
|
||||||
</xpath>
|
<!-- </xpath>-->
|
||||||
<xpath expr="//page//field[@name='cnc_ids']" position="before">
|
<xpath expr="//page//field[@name='cnc_ids']" position="before">
|
||||||
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<field name="compensation_value_x"/>
|
||||||
<field name="compensation_value_x"/>
|
<field name="compensation_value_y"/>
|
||||||
<field name="compensation_value_y"/>
|
|
||||||
</group>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<field name="button_compensation_state" attrs='{"invisible": ["|",
|
|
||||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
|
||||||
<button string="一键补偿" name="compensation" type="object" confirm="是否确认下发补偿"
|
|
||||||
class="btn-primary" attrs='{"invisible": ["|",
|
|
||||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
|
||||||
<span> </span>
|
|
||||||
<button string="一键下发" name="up_all" type="object" style="text-align: right;" confirm="是否确认一键下发"
|
|
||||||
class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
|
|
||||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
|
||||||
<span> </span>
|
|
||||||
<button string="合并下发" id="action_up_select" name="%(sf_machine_connect.action_up_select)d"
|
|
||||||
type="action" class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
|
|
||||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
|
||||||
<span> </span>
|
|
||||||
<button string="一键合并下发" name="up_merge_all" type="object" style="text-align: right;" confirm="是否确认一键合并下发"
|
|
||||||
class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
|
|
||||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</group>
|
</group>
|
||||||
</xpath>
|
<div>
|
||||||
|
<div>
|
||||||
|
<field name="button_compensation_state" attrs='{"invisible": ["|",
|
||||||
|
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
||||||
|
<!-- <span> </span>-->
|
||||||
|
<button name="button_send_program_again" type="object" string="重新下发NC程序"
|
||||||
|
class="btn-primary"
|
||||||
|
confirm="是否确认重新下发NC程序?"
|
||||||
|
groups="sf_base.group_sf_order_user,sf_base.group_sf_equipment_user"
|
||||||
|
attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','in',['done', 'cancel',
|
||||||
|
'progress']),('processing_drawing','=',False),('is_send_program_again','=',True)]}"/>
|
||||||
|
<!-- <button string="一键补偿" name="compensation" type="object" confirm="是否确认下发补偿"-->
|
||||||
|
<!-- class="btn-primary" attrs='{"invisible": ["|",-->
|
||||||
|
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||||
|
<!-- <span> </span>-->
|
||||||
|
<!-- <button string="一键下发" name="up_all" type="object" style="text-align: right;" confirm="是否确认一键下发"-->
|
||||||
|
<!-- class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",-->
|
||||||
|
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||||
|
<!-- <span> </span>-->
|
||||||
|
<!-- <button string="合并下发" id="action_up_select" name="%(sf_machine_connect.action_up_select)d"-->
|
||||||
|
<!-- type="action" class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",-->
|
||||||
|
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||||
|
<!-- <span> </span>-->
|
||||||
|
<!-- <button string="一键合并下发" name="up_merge_all" type="object" style="text-align: right;" confirm="是否确认一键合并下发"-->
|
||||||
|
<!-- class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",-->
|
||||||
|
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
<tree>
|
<tree>
|
||||||
<field name="sequence_number"/>
|
<field name="sequence_number"/>
|
||||||
<field name="program_name"/>
|
<field name="program_name"/>
|
||||||
<field name="cnc_id" string="文件"/>
|
|
||||||
<field name="functional_tool_type_id"/>
|
<field name="functional_tool_type_id"/>
|
||||||
<field name="cutting_tool_name"/>
|
<field name="cutting_tool_name"/>
|
||||||
<field name="cutting_tool_no"/>
|
<field name="cutting_tool_no"/>
|
||||||
|
|||||||
@@ -460,25 +460,27 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
if f'RfidCode{i}' in ret:
|
if f'RfidCode{i}' in ret:
|
||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
logging.info('RfidCode:%s' % rfid_code)
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
if rfid_code is not None:
|
||||||
('rfid_code', '=', rfid_code),
|
domain = [
|
||||||
('routing_type', '=', 'CNC加工')
|
('rfid_code', '=', rfid_code),
|
||||||
]
|
('routing_type', '=', 'CNC加工')
|
||||||
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
]
|
||||||
if workorder:
|
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||||
for order in workorder:
|
if workorder:
|
||||||
if order.production_id.production_line_state == '待上产线':
|
for order in workorder:
|
||||||
logging.info(
|
if order.production_id.production_line_state == '待上产线':
|
||||||
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
logging.info(
|
||||||
order.production_id.write({'production_line_state': '已上产线'})
|
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
|
order.production_id.write({'production_line_state': '已上产线'})
|
||||||
('rfid_code', '=', rfid_code), ('type', '=', '上产线'),
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
('production_id', '=', order.production_id.id)])
|
[
|
||||||
if workpiece_delivery.status == '待下发':
|
('rfid_code', '=', rfid_code), ('type', '=', '上产线'),
|
||||||
workpiece_delivery.write({'is_manual_work': True})
|
('production_id', '=', order.production_id.id)])
|
||||||
else:
|
if workpiece_delivery.status == '待下发':
|
||||||
res = {'Succeed': False, 'ErrorCode': 204,
|
workpiece_delivery.write({'is_manual_work': True})
|
||||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 204,
|
||||||
|
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
||||||
else:
|
else:
|
||||||
@@ -515,24 +517,26 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
if f'RfidCode{i}' in ret:
|
if f'RfidCode{i}' in ret:
|
||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
logging.info('RfidCode:%s' % rfid_code)
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
if rfid_code is not None:
|
||||||
('rfid_code', '=', rfid_code),
|
domain = [
|
||||||
('routing_type', '=', 'CNC加工')
|
('rfid_code', '=', rfid_code),
|
||||||
]
|
('routing_type', '=', 'CNC加工')
|
||||||
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
]
|
||||||
if workorder:
|
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||||
for order in workorder:
|
if workorder:
|
||||||
if order.production_id.production_line_state == '已上产线':
|
for order in workorder:
|
||||||
logging.info(
|
if order.production_id.production_line_state == '已上产线':
|
||||||
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
logging.info(
|
||||||
order.production_id.write({'production_line_state': '已下产线'})
|
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
|
order.production_id.write({'production_line_state': '已下产线'})
|
||||||
('rfid_code', '=', rfid_code), ('type', '=', '下产线'),
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
('production_id', '=', order.production_id.id)])
|
[
|
||||||
delivery_Arr.append(workpiece_delivery.id)
|
('rfid_code', '=', rfid_code), ('type', '=', '下产线'),
|
||||||
else:
|
('production_id', '=', order.production_id.id)])
|
||||||
res = {'Succeed': False, 'ErrorCode': 204,
|
delivery_Arr.append(workpiece_delivery.id)
|
||||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
else:
|
||||||
|
res = {'Succeed': False, 'ErrorCode': 204,
|
||||||
|
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||||
if delivery_Arr:
|
if delivery_Arr:
|
||||||
logging.info('delivery_Arr:%s' % delivery_Arr)
|
logging.info('delivery_Arr:%s' % delivery_Arr)
|
||||||
delivery_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
|
delivery_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ class MrpProduction(models.Model):
|
|||||||
# 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制;
|
# 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制;
|
||||||
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
|
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
|
||||||
|
|
||||||
def _create_workorder3(self):
|
def _create_workorder3(self, item):
|
||||||
# 根据product_id对self进行分组
|
# 根据product_id对self进行分组
|
||||||
grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)}
|
grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)}
|
||||||
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
||||||
@@ -328,19 +328,6 @@ class MrpProduction(models.Model):
|
|||||||
'state': 'pending',
|
'state': 'pending',
|
||||||
}]
|
}]
|
||||||
if production.product_id.categ_id.type == '成品':
|
if production.product_id.categ_id.type == '成品':
|
||||||
if production.product_id.id in product_id_to_production_names:
|
|
||||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
|
||||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
|
||||||
if not production.programming_no:
|
|
||||||
production_programming = self.search(
|
|
||||||
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
|
|
||||||
limit=1, order='id asc')
|
|
||||||
if not production_programming.programming_no:
|
|
||||||
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]))
|
|
||||||
else:
|
|
||||||
production.write({'programming_no': production_programming.programming_no,
|
|
||||||
'programming_state': '编程中'})
|
|
||||||
|
|
||||||
# # 根据加工面板的面数及对应的工序模板生成工单
|
# # 根据加工面板的面数及对应的工序模板生成工单
|
||||||
i = 0
|
i = 0
|
||||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||||
@@ -353,10 +340,10 @@ class MrpProduction(models.Model):
|
|||||||
for route in product_routing_workcenter:
|
for route in product_routing_workcenter:
|
||||||
if route.is_repeat is True:
|
if route.is_repeat is True:
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(k, production, route))
|
self.env['mrp.workorder'].json_workorder_str(k, production, route, item))
|
||||||
if i == processing_panel_len and route.routing_type == '解除装夹':
|
# if i == processing_panel_len and route.routing_type == '解除装夹':
|
||||||
workorders_values.append(
|
# workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(k, production, route))
|
# self.env['mrp.workorder'].json_workorder_str(k, production, route))
|
||||||
# 表面工艺工序
|
# 表面工艺工序
|
||||||
# 获取表面工艺id
|
# 获取表面工艺id
|
||||||
if production.product_id.model_process_parameters_ids:
|
if production.product_id.model_process_parameters_ids:
|
||||||
@@ -404,6 +391,52 @@ class MrpProduction(models.Model):
|
|||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||||
production.workorder_ids = workorders_values
|
production.workorder_ids = workorders_values
|
||||||
|
# for production_item in productions:
|
||||||
|
process_parameter_workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id),
|
||||||
|
('is_subcontract', '=', True)])
|
||||||
|
if process_parameter_workorder:
|
||||||
|
is_pick = False
|
||||||
|
consecutive_workorders = []
|
||||||
|
m = 0
|
||||||
|
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
||||||
|
for i in range(len(sorted_workorders) - 1):
|
||||||
|
if m == 0:
|
||||||
|
is_pick = False
|
||||||
|
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
||||||
|
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
||||||
|
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
||||||
|
if sorted_workorders[i] not in consecutive_workorders:
|
||||||
|
consecutive_workorders.append(sorted_workorders[i])
|
||||||
|
consecutive_workorders.append(sorted_workorders[i + 1])
|
||||||
|
m += 1
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||||
|
production_item)
|
||||||
|
if sorted_workorders[i] in consecutive_workorders:
|
||||||
|
is_pick = True
|
||||||
|
consecutive_workorders = []
|
||||||
|
m = 0
|
||||||
|
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
||||||
|
if is_pick is False:
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
||||||
|
production_item)
|
||||||
|
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||||
|
production_item)
|
||||||
|
if sorted_workorders[i] in consecutive_workorders:
|
||||||
|
is_pick = True
|
||||||
|
consecutive_workorders = []
|
||||||
|
m = 0
|
||||||
|
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
|
||||||
|
if is_pick is False and m == 0:
|
||||||
|
if len(sorted_workorders) == 1:
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
|
||||||
|
else:
|
||||||
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
|
||||||
for workorder in production.workorder_ids:
|
for workorder in production.workorder_ids:
|
||||||
workorder.duration_expected = workorder._get_duration_expected()
|
workorder.duration_expected = workorder._get_duration_expected()
|
||||||
|
|
||||||
@@ -498,46 +531,63 @@ class MrpProduction(models.Model):
|
|||||||
def _reset_work_order_sequence(self):
|
def _reset_work_order_sequence(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
sequence_list = {}
|
sequence_list = {}
|
||||||
|
# 产品模型类型
|
||||||
model_type_id = rec.product_id.product_model_type_id
|
model_type_id = rec.product_id.product_model_type_id
|
||||||
|
# 产品加工面板
|
||||||
|
model_processing_panel = rec.product_id.model_processing_panel
|
||||||
if model_type_id:
|
if model_type_id:
|
||||||
tmpl_num = 1
|
if model_processing_panel:
|
||||||
# 成品工序
|
tmpl_num = 1
|
||||||
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
|
panel_list = model_processing_panel.split(',')
|
||||||
if product_routing_tmpl_ids:
|
for panel in panel_list:
|
||||||
for tmpl_id in product_routing_tmpl_ids:
|
panel_sequence_list = {}
|
||||||
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
# 成品工序
|
||||||
tmpl_num += 1
|
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
|
||||||
# 表面工艺工序
|
if product_routing_tmpl_ids:
|
||||||
# 模型类型的表面工艺工序模版
|
for tmpl_id in product_routing_tmpl_ids:
|
||||||
surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids
|
panel_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||||
# 产品选择的表面工艺
|
tmpl_num += 1
|
||||||
model_process_parameters_ids = rec.product_id.model_process_parameters_ids
|
sequence_list.update({panel: panel_sequence_list})
|
||||||
process_dict = {}
|
# 表面工艺工序
|
||||||
if model_process_parameters_ids:
|
# 模型类型的表面工艺工序模版
|
||||||
for process_parameters_id in model_process_parameters_ids:
|
surface_tmpl_ids = model_type_id.surface_technics_routing_tmpl_ids
|
||||||
process_id = process_parameters_id.process_id
|
# 产品选择的表面工艺
|
||||||
for surface_tmpl_id in surface_tmpl_ids:
|
model_process_parameters_ids = rec.product_id.model_process_parameters_ids
|
||||||
if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id:
|
process_dict = {}
|
||||||
surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name
|
if model_process_parameters_ids:
|
||||||
process_dict.update({int(process_id.category_id.code): '%s-%s' % (
|
for process_parameters_id in model_process_parameters_ids:
|
||||||
surface_tmpl_name, process_parameters_id.name)})
|
process_id = process_parameters_id.process_id
|
||||||
process_list = sorted(process_dict.keys())
|
for surface_tmpl_id in surface_tmpl_ids:
|
||||||
for process_num in process_list:
|
if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id:
|
||||||
sequence_list.update({process_dict.get(process_num): tmpl_num})
|
surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name
|
||||||
tmpl_num += 1
|
process_dict.update({int(process_id.category_id.code): '%s-%s' % (
|
||||||
# 坯料工序
|
surface_tmpl_name, process_parameters_id.name)})
|
||||||
tmpl_num = 1
|
process_list = sorted(process_dict.keys())
|
||||||
embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids
|
for process_num in process_list:
|
||||||
if embryo_routing_tmpl_ids:
|
sequence_list.update({process_dict.get(process_num): tmpl_num})
|
||||||
for tmpl_id in embryo_routing_tmpl_ids:
|
|
||||||
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
|
||||||
tmpl_num += 1
|
tmpl_num += 1
|
||||||
|
# 坯料工序
|
||||||
|
tmpl_num = 1
|
||||||
|
embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids
|
||||||
|
if embryo_routing_tmpl_ids:
|
||||||
|
for tmpl_id in embryo_routing_tmpl_ids:
|
||||||
|
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||||
|
tmpl_num += 1
|
||||||
|
else:
|
||||||
|
raise ValidationError('该产品【加工面板】为空!')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValidationError('该产品没有选择【模版类型】!')
|
raise ValidationError('该产品没有选择【模版类型】!')
|
||||||
|
|
||||||
for work in rec.workorder_ids:
|
for work in rec.workorder_ids:
|
||||||
if sequence_list.get(work.name):
|
if sequence_list.get(work.name):
|
||||||
work.sequence = sequence_list[work.name]
|
work.sequence = sequence_list[work.name]
|
||||||
|
elif sequence_list.get(work.processing_panel):
|
||||||
|
processing_panel = sequence_list.get(work.processing_panel)
|
||||||
|
if processing_panel.get(work.name):
|
||||||
|
work.sequence = processing_panel[work.name]
|
||||||
|
else:
|
||||||
|
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||||
else:
|
else:
|
||||||
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||||
# if work.name == '获取CNC加工程序':
|
# if work.name == '获取CNC加工程序':
|
||||||
@@ -546,8 +596,8 @@ class MrpProduction(models.Model):
|
|||||||
# work.button_finish()
|
# work.button_finish()
|
||||||
|
|
||||||
# 创建工单并进行排序
|
# 创建工单并进行排序
|
||||||
def _create_workorder(self):
|
def _create_workorder(self, item):
|
||||||
self._create_workorder3()
|
self._create_workorder3(item)
|
||||||
self._reset_work_order_sequence()
|
self._reset_work_order_sequence()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import re
|
import re
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
@@ -207,6 +207,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
|
[("programming", "编程"), ("clamping", "返工"), ("cutter", "刀具"), ("operate computer", "操机"),
|
||||||
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
|
("technology", "工艺"), ("customer redrawing", "客户改图"), ("other", "其他"), ], string="原因", tracking=True)
|
||||||
detailed_reason = fields.Text('详细原因')
|
detailed_reason = fields.Text('详细原因')
|
||||||
|
is_send_program_again = fields.Boolean(string='是否重新下发NC程序', default=False)
|
||||||
|
|
||||||
@api.onchange('rfid_code')
|
@api.onchange('rfid_code')
|
||||||
def _onchange(self):
|
def _onchange(self):
|
||||||
@@ -473,7 +474,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
raise UserError(_("该工单暂未完成,无法进行工件配送"))
|
raise UserError(_("该工单暂未完成,无法进行工件配送"))
|
||||||
|
|
||||||
# 拼接工单对象属性值
|
# 拼接工单对象属性值
|
||||||
def json_workorder_str(self, k, production, route):
|
def json_workorder_str(self, k, production, route, item):
|
||||||
# 计算预计时长duration_expected
|
# 计算预计时长duration_expected
|
||||||
if route.routing_type == '切割':
|
if route.routing_type == '切割':
|
||||||
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
@@ -506,7 +507,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'processing_panel': k,
|
'processing_panel': k,
|
||||||
'quality_point_ids': route.route_workcenter_id.quality_point_ids,
|
'quality_point_ids': route.route_workcenter_id.quality_point_ids,
|
||||||
'routing_type': route.routing_type,
|
'routing_type': route.routing_type,
|
||||||
'work_state': '待发起',
|
# 'work_state': '待发起',
|
||||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
||||||
route.routing_type,
|
route.routing_type,
|
||||||
production.product_id),
|
production.product_id),
|
||||||
@@ -515,6 +516,10 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'date_planned_finished': datetime.now() + timedelta(days=1),
|
'date_planned_finished': datetime.now() + timedelta(days=1),
|
||||||
'duration_expected': duration_expected,
|
'duration_expected': duration_expected,
|
||||||
'duration': 0,
|
'duration': 0,
|
||||||
|
'cnc_ids': False if route.routing_type != 'CNC加工' else self.env['sf.cnc.processing']._json_cnc_processing(
|
||||||
|
k, item),
|
||||||
|
'cmm_ids': False if route.routing_type != 'CNC加工' else self.env['sf.cmm.program']._json_cmm_program(k,
|
||||||
|
item),
|
||||||
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
|
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
|
||||||
production)
|
production)
|
||||||
}]
|
}]
|
||||||
@@ -1073,6 +1078,33 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
workorder.detection_report = base64.b64encode(open(report_file_path, 'rb').read())
|
workorder.detection_report = base64.b64encode(open(report_file_path, 'rb').read())
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# 重新下发nc程序
|
||||||
|
def button_send_program_again(self):
|
||||||
|
try:
|
||||||
|
res = {'programming_no': self.production_id.programming_no}
|
||||||
|
configsettings = self.env['res.config.settings'].get_values()
|
||||||
|
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||||
|
url = '/api/intelligent_programming/reset_state_again'
|
||||||
|
config_url = configsettings['sf_url'] + url
|
||||||
|
r = requests.post(config_url, json=res, data=None, headers=config_header)
|
||||||
|
r = r.json()
|
||||||
|
result = json.loads(r['result'])
|
||||||
|
if result['status'] == 1:
|
||||||
|
productions = self.env['mrp.production'].search(
|
||||||
|
[('programming_no', '=', self.production_id.programming_no), ('programming_state', '=', '已编程')])
|
||||||
|
if productions:
|
||||||
|
workorder = productions.workorder_ids.filtered(
|
||||||
|
lambda ap: ap.routing_type in ['装夹预调', 'CNC加工'] and ap.state not in ['done', 'cancel',
|
||||||
|
'progress'])
|
||||||
|
if workorder:
|
||||||
|
workorder.write({'is_send_program_again': True})
|
||||||
|
productions.write({'work_state': '编程中', 'programming_state': '编程中'})
|
||||||
|
else:
|
||||||
|
raise UserError(result['message'])
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('button_send_program_again error:%s' % e)
|
||||||
|
raise UserError("重新下发nc程序失败,请联系管理员")
|
||||||
|
|
||||||
|
|
||||||
class CNCprocessing(models.Model):
|
class CNCprocessing(models.Model):
|
||||||
_name = 'sf.cnc.processing'
|
_name = 'sf.cnc.processing'
|
||||||
@@ -1098,6 +1130,7 @@ class CNCprocessing(models.Model):
|
|||||||
production_id = fields.Many2one('mrp.production', string="制造订单")
|
production_id = fields.Many2one('mrp.production', string="制造订单")
|
||||||
button_state = fields.Boolean(string='是否已经下发')
|
button_state = fields.Boolean(string='是否已经下发')
|
||||||
program_path = fields.Char('程序文件路径')
|
program_path = fields.Char('程序文件路径')
|
||||||
|
program_create_date = fields.Datetime('程序创建日期')
|
||||||
|
|
||||||
# mrs下发编程单创建CNC加工
|
# mrs下发编程单创建CNC加工
|
||||||
def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp):
|
def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp):
|
||||||
@@ -1130,24 +1163,27 @@ class CNCprocessing(models.Model):
|
|||||||
cnc_workorder.write({'programming_state': '已编程', 'work_state': '已编程'})
|
cnc_workorder.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
return cnc_processing
|
return cnc_processing
|
||||||
|
|
||||||
def _json_cnc_processing(self, obj):
|
def _json_cnc_processing(self, panel, ret):
|
||||||
cnc_processing_str = (0, 0, {
|
cnc_processing = []
|
||||||
'sequence_number': obj['sequence_number'],
|
for item in ret['programming_list']:
|
||||||
'program_name': obj['program_name'],
|
if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') == -1:
|
||||||
'cutting_tool_name': obj['cutting_tool_name'],
|
cnc_processing.append((0, 0, {
|
||||||
'cutting_tool_no': obj['cutting_tool_no'],
|
'sequence_number': item['sequence_number'],
|
||||||
'processing_type': obj['processing_type'],
|
'program_name': item['program_name'],
|
||||||
'margin_x_y': obj['margin_x_y'],
|
'cutting_tool_name': item['cutting_tool_name'],
|
||||||
'margin_z': obj['margin_z'],
|
'cutting_tool_no': item['cutting_tool_no'],
|
||||||
'depth_of_processing_z': obj['depth_of_processing_z'],
|
'processing_type': item['processing_type'],
|
||||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
'margin_x_y': item['margin_x_y'],
|
||||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
'margin_z': item['margin_z'],
|
||||||
'estimated_processing_time': obj['estimated_processing_time'],
|
'depth_of_processing_z': item['depth_of_processing_z'],
|
||||||
'program_path': obj['program_path'],
|
'cutting_tool_extension_length': item['cutting_tool_extension_length'],
|
||||||
'cnc_id': obj['cnc_id'].id,
|
'cutting_tool_handle_type': item['cutting_tool_handle_type'],
|
||||||
'remark': obj['remark']
|
'estimated_processing_time': item['estimated_processing_time'],
|
||||||
})
|
'program_path': item['ftp_path'],
|
||||||
return cnc_processing_str
|
'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'),
|
||||||
|
'remark': item['remark']
|
||||||
|
}))
|
||||||
|
return cnc_processing
|
||||||
|
|
||||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
||||||
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
||||||
@@ -1177,14 +1213,14 @@ class CNCprocessing(models.Model):
|
|||||||
})
|
})
|
||||||
return attachment
|
return attachment
|
||||||
|
|
||||||
# 将FTP的nc文件下载到临时目录
|
# 将FTP的多面的程序单文件下载到临时目录
|
||||||
def download_file_tmp(self, production_no, processing_panel):
|
def download_file_tmp(self, production_no, processing_panel):
|
||||||
remotepath = os.path.join('/NC', production_no, 'return', processing_panel)
|
remotepath = os.path.join('/NC', production_no, 'return', processing_panel)
|
||||||
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
||||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
|
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
|
||||||
ftp_resconfig['ftp_password'])
|
ftp_resconfig['ftp_password'])
|
||||||
download_state = ftp.download_file_tree(remotepath, serverdir)
|
download_state = ftp.download_program_file(remotepath, serverdir)
|
||||||
logging.info('download_state:%s' % download_state)
|
logging.info('download_state:%s' % download_state)
|
||||||
return download_state
|
return download_state
|
||||||
|
|
||||||
@@ -1589,80 +1625,22 @@ class CMMprogram(models.Model):
|
|||||||
_name = 'sf.cmm.program'
|
_name = 'sf.cmm.program'
|
||||||
_description = "CMM程序"
|
_description = "CMM程序"
|
||||||
|
|
||||||
cmm_id = fields.Many2one('ir.attachment')
|
|
||||||
sequence_number = fields.Integer('序号')
|
sequence_number = fields.Integer('序号')
|
||||||
program_name = fields.Char('程序名')
|
program_name = fields.Char('程序名')
|
||||||
cutting_tool_name = fields.Char('刀具名称')
|
|
||||||
cutting_tool_no = fields.Char('刀号')
|
|
||||||
processing_type = fields.Char('加工类型')
|
|
||||||
margin_x_y = fields.Char('余量_X/Y')
|
|
||||||
margin_z = fields.Char('余量_Z')
|
|
||||||
depth_of_processing_z = fields.Char('加工深度(Z)')
|
|
||||||
cutting_tool_extension_length = fields.Char('刀具伸出长度')
|
|
||||||
cutting_tool_handle_type = fields.Char('刀柄型号')
|
|
||||||
estimated_processing_time = fields.Char('预计加工时间')
|
|
||||||
remark = fields.Text('备注')
|
remark = fields.Text('备注')
|
||||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||||
production_id = fields.Many2one('mrp.production', string="制造订单")
|
production_id = fields.Many2one('mrp.production', string="制造订单")
|
||||||
program_path = fields.Char('程序文件路径')
|
program_path = fields.Char('程序文件路径')
|
||||||
|
program_create_date = fields.Datetime('程序创建日期')
|
||||||
|
|
||||||
def cmm_program_create(self, ret, program_path, program_path_tmp):
|
def _json_cmm_program(self, panel, ret):
|
||||||
cmm_program = None
|
cmm_program = []
|
||||||
for obj in ret['programming_list']:
|
for item in ret['programming_list']:
|
||||||
workorder = self.env['mrp.workorder'].search(
|
if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') != -1:
|
||||||
[('production_id.name', '=', ret['production_order_no'].split(',')[0]),
|
cmm_program.append((0, 0, {
|
||||||
('processing_panel', '=', obj['processing_panel']),
|
'sequence_number': 1,
|
||||||
('routing_type', '=', 'CNC加工')])
|
'program_name': item['program_name'],
|
||||||
if obj['program_name'] in program_path:
|
'program_path': item['ftp_path'],
|
||||||
logging.info('obj:%s' % obj['program_name'])
|
'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'),
|
||||||
cmm_program = self.sudo().create({
|
}))
|
||||||
'workorder_id': workorder.id,
|
|
||||||
'sequence_number': obj['sequence_number'],
|
|
||||||
'program_name': obj['program_name'],
|
|
||||||
'cutting_tool_name': obj['cutting_tool_name'],
|
|
||||||
'cutting_tool_no': obj['cutting_tool_no'],
|
|
||||||
'processing_type': obj['processing_type'],
|
|
||||||
'margin_x_y': obj['margin_x_y'],
|
|
||||||
'margin_z': obj['margin_z'],
|
|
||||||
'depth_of_processing_z': obj['depth_of_processing_z'],
|
|
||||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
|
||||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
|
||||||
'estimated_processing_time': obj['estimated_processing_time'],
|
|
||||||
'remark': obj['remark'],
|
|
||||||
'program_path': program_path.replace('/tmp', '')
|
|
||||||
})
|
|
||||||
cmm_program.get_cmm_program_file(program_path_tmp, cmm_program, program_path)
|
|
||||||
return cmm_program
|
return cmm_program
|
||||||
|
|
||||||
# 根据程序名和加工面匹配到ftp里对应的cmm程序名
|
|
||||||
def get_cmm_program_file(self, serverdir, cmm_program, program_path):
|
|
||||||
logging.info('cmm-serverdir:%s' % serverdir)
|
|
||||||
for root, dirs, files in os.walk(serverdir):
|
|
||||||
for f in files:
|
|
||||||
if f in program_path:
|
|
||||||
cmm_program_file_path = os.path.join(serverdir, root, f)
|
|
||||||
self.write_file_cmm(cmm_program_file_path, cmm_program)
|
|
||||||
|
|
||||||
# 创建附件(nc文件)
|
|
||||||
def attachment_create(self, name, data):
|
|
||||||
attachment = self.env['ir.attachment'].create({
|
|
||||||
'datas': base64.b64encode(data),
|
|
||||||
'type': 'binary',
|
|
||||||
'public': True,
|
|
||||||
'description': '程序文件',
|
|
||||||
'name': name
|
|
||||||
})
|
|
||||||
return attachment
|
|
||||||
|
|
||||||
# 将cmm文件存到attach的datas里
|
|
||||||
def write_file_cmm(self, cmm_file_path, cnc):
|
|
||||||
cmm_file_name = cmm_file_path.split('/')
|
|
||||||
logging.info('cmm_file_name:%s' % cmm_file_name[-1])
|
|
||||||
if os.path.exists(cmm_file_path):
|
|
||||||
with open(cmm_file_path, 'rb') as file:
|
|
||||||
data_bytes = file.read()
|
|
||||||
attachment = self.attachment_create(cnc.program_name + cmm_file_name[-1], data_bytes)
|
|
||||||
cnc.write({'cmm_id': attachment.id})
|
|
||||||
file.close()
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import base64
|
import base64
|
||||||
import qrcode
|
import qrcode
|
||||||
|
from itertools import groupby
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
import logging
|
import logging
|
||||||
import io
|
import io
|
||||||
@@ -205,61 +206,37 @@ class StockRule(models.Model):
|
|||||||
|
|
||||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
'''
|
|
||||||
创建工单
|
|
||||||
'''
|
|
||||||
productions._create_workorder()
|
|
||||||
|
|
||||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||||
(
|
(
|
||||||
p.move_dest_ids.procure_method != 'make_to_order' and not
|
p.move_dest_ids.procure_method != 'make_to_order' and not
|
||||||
p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
||||||
|
'''
|
||||||
|
创建工单
|
||||||
|
'''
|
||||||
|
# productions._create_workorder()
|
||||||
|
#
|
||||||
|
grouped_product_ids = {k: list(g) for k, g in groupby(productions, key=lambda x: x.product_id.id)}
|
||||||
|
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
||||||
|
product_id_to_production_names = {}
|
||||||
|
# 对于每个product_id,获取其所有生产订单的名称
|
||||||
|
for product_id, productions in grouped_product_ids.items():
|
||||||
|
# 为同一个product_id创建一个生产订单名称列表
|
||||||
|
product_id_to_production_names[product_id] = [production.name for production in productions]
|
||||||
for production_item in productions:
|
for production_item in productions:
|
||||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
if production_item.product_id.id in product_id_to_production_names:
|
||||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production_item.id),
|
# # 同一个产品多个制造订单对应一个编程单和模型库
|
||||||
('is_subcontract', '=', True)])
|
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||||
if process_parameter_workorder:
|
if not production_item.programming_no:
|
||||||
is_pick = False
|
production_programming = self.env['mrp.production'].search(
|
||||||
consecutive_workorders = []
|
[('product_id.id', '=', production_item.product_id.id),
|
||||||
m = 0
|
('origin', '=', production_item.origin)],
|
||||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
limit=1, order='id asc')
|
||||||
for i in range(len(sorted_workorders) - 1):
|
if not production_programming.programming_no:
|
||||||
if m == 0:
|
production_item.fetchCNC(
|
||||||
is_pick = False
|
', '.join(product_id_to_production_names[production_item.product_id.id]))
|
||||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
|
||||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
|
||||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
|
||||||
if sorted_workorders[i] not in consecutive_workorders:
|
|
||||||
consecutive_workorders.append(sorted_workorders[i])
|
|
||||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
|
||||||
m += 1
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
production_item.write({'programming_no': production_programming.programming_no,
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
'programming_state': '编程中'})
|
||||||
production_item)
|
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
|
||||||
is_pick = True
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
|
||||||
if is_pick is False:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
|
||||||
production_item)
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
|
||||||
production_item)
|
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
|
||||||
is_pick = True
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production_item)
|
|
||||||
if is_pick is False and m == 0:
|
|
||||||
if len(sorted_workorders) == 1:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
|
|
||||||
else:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production_item)
|
|
||||||
|
|
||||||
for production in productions:
|
for production in productions:
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_sf_cnc_processing_group_sf_mrp_user,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_user,1,0,0,0
|
access_sf_cnc_processing_group_sf_mrp_user,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
access_sf_cnc_processing_manager,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_cnc_processing_manager,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||||
access_sf_cmm_program_group_sf_mrp_user_group_sf_mrp_user,sf_cmm_program_group_sf_mrp_user,model_sf_cmm_program,sf_base.group_sf_mrp_user,1,0,0,0
|
access_sf_cmm_program_group_sf_mrp_user,sf_cmm_program_group_sf_mrp_user,model_sf_cmm_program,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
access_sf_cmm_program_group_sf_mrp_manager,sf_cmm_program_group_sf_mrp_manager,model_sf_cmm_program,sf_base.group_sf_mrp_manager,1,0,0,0
|
access_sf_cmm_program_group_sf_mrp_manager,sf_cmm_program_group_sf_mrp_manager,model_sf_cmm_program,sf_base.group_sf_mrp_manager,1,0,0,0
|
||||||
|
access_sf_cmm_program_admin,sf_cmm_program_admin,model_sf_cmm_program,base.group_system,1,1,1,1
|
||||||
access_sf_model_type_group_sf_mrp_user,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_user,1,0,0,0
|
access_sf_model_type_group_sf_mrp_user,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_user,1,0,0,0
|
||||||
access_sf_model_type_admin,sf_model_type_admin,model_sf_model_type,base.group_system,1,1,1,0
|
access_sf_model_type_admin,sf_model_type_admin,model_sf_model_type,base.group_system,1,1,1,0
|
||||||
access_sf_model_type_manager,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_manager,1,1,1,0
|
access_sf_model_type_manager,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||||
|
|||||||
|
@@ -62,16 +62,17 @@
|
|||||||
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='state']" position="attributes">
|
<xpath expr="//field[@name='state']" position="attributes">
|
||||||
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
|
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
|
||||||
<!-- </attribute> -->
|
<!-- </attribute> -->
|
||||||
<attribute name="statusbar_visible">progress,pending_cam,pending_processing,pending_era_cam,completed,done
|
<attribute name="statusbar_visible">
|
||||||
|
progress,pending_cam,pending_processing,pending_era_cam,completed,done
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//sheet//group//group[2]//label" position="before">
|
<xpath expr="//sheet//group//group[2]//label" position="before">
|
||||||
<!-- <field name="process_state"/> -->
|
<!-- <field name="process_state"/> -->
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<!-- <field name="process_state"/> -->
|
<!-- <field name="process_state"/> -->
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//group//group//div[3]" position="after">
|
<xpath expr="//sheet//group//group//div[3]" position="after">
|
||||||
@@ -281,7 +282,7 @@
|
|||||||
<field name="routing_type" invisible="True"/>
|
<field name="routing_type" invisible="True"/>
|
||||||
<button name="button_start" type="object" string="开始" class="btn-success"
|
<button name="button_start" type="object" string="开始" class="btn-success"
|
||||||
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False), ('routing_type', '=', 'CNC加工')]}"
|
attrs="{'invisible': ['|', '|', '|','|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False), ('routing_type', '=', 'CNC加工')]}"
|
||||||
groups="sf_base.group_sf_mrp_user"/>
|
groups="sf_base.group_sf_mrp_user" confirm="是否确认开始?"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//tree//button[@name='button_pending']" position="replace">
|
<xpath expr="//tree//button[@name='button_pending']" position="replace">
|
||||||
<button name="button_pending" type="object" string="Pause" class="btn-warning"
|
<button name="button_pending" type="object" string="Pause" class="btn-warning"
|
||||||
@@ -291,7 +292,8 @@
|
|||||||
<xpath expr="//tree//button[@name='button_finish']" position="replace">
|
<xpath expr="//tree//button[@name='button_finish']" position="replace">
|
||||||
<button name="button_finish" type="object" string="Done" class="btn-success"
|
<button name="button_finish" type="object" string="Done" class="btn-success"
|
||||||
attrs="{'invisible': ['|', '|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
|
attrs="{'invisible': ['|', '|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
|
||||||
groups="sf_base.group_sf_mrp_user"/>
|
groups="sf_base.group_sf_mrp_user"
|
||||||
|
confirm="是否确认完成?"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
|
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
|
||||||
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block"
|
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block"
|
||||||
@@ -309,10 +311,10 @@
|
|||||||
<button name="action_open_wizard" type="object" icon="fa-external-link" class="oe_edit_only"
|
<button name="action_open_wizard" type="object" icon="fa-external-link" class="oe_edit_only"
|
||||||
title="Open Work Order"
|
title="Open Work Order"
|
||||||
context="{'default_workcenter_id': workcenter_id}" groups="sf_base.group_sf_mrp_user"/>
|
context="{'default_workcenter_id': workcenter_id}" groups="sf_base.group_sf_mrp_user"/>
|
||||||
<!-- ======= -->
|
<!-- ======= -->
|
||||||
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
|
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
|
||||||
<!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}" -->
|
<!-- attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}" -->
|
||||||
<!-- groups="sf_base.group_sf_mrp_user"/> -->
|
<!-- groups="sf_base.group_sf_mrp_user"/> -->
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//tree//button[@name='button_pending']" position="replace">
|
<xpath expr="//tree//button[@name='button_pending']" position="replace">
|
||||||
<button name="button_pending" type="object" string="暂停" class="btn-warning"
|
<button name="button_pending" type="object" string="暂停" class="btn-warning"
|
||||||
@@ -322,7 +324,7 @@
|
|||||||
<xpath expr="//tree//button[@name='button_finish']" position="replace">
|
<xpath expr="//tree//button[@name='button_finish']" position="replace">
|
||||||
<button name="button_finish" type="object" string="完成" class="btn-success"
|
<button name="button_finish" type="object" string="完成" class="btn-success"
|
||||||
attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
|
attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False), ('routing_type', '=', 'CNC加工')]}"
|
||||||
groups="sf_base.group_sf_mrp_user"/>
|
groups="sf_base.group_sf_mrp_user" confirm="是否确认完成?"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
|
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
|
||||||
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="阻塞"
|
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="阻塞"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/>
|
<field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/>
|
||||||
</field>
|
</field>
|
||||||
<field name="name" position="before">
|
<field name="name" position="before">
|
||||||
<field name="sequence"/>
|
<field name="sequence" optional="hide"/>
|
||||||
<field name='user_permissions' invisible="1"/>
|
<field name='user_permissions' invisible="1"/>
|
||||||
</field>
|
</field>
|
||||||
<field name="name" position="after">
|
<field name="name" position="after">
|
||||||
@@ -21,6 +21,12 @@
|
|||||||
<field name="work_state" optional="hide"/>
|
<field name="work_state" optional="hide"/>
|
||||||
<field name="product_tmpl_name" invisible="1"/>
|
<field name="product_tmpl_name" invisible="1"/>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="duration" position="replace">
|
||||||
|
<field name="duration" optional="hide"/>
|
||||||
|
</field>
|
||||||
|
<field name="workcenter_id" position="replace">
|
||||||
|
<field name="workcenter_id" optional="hide"/>
|
||||||
|
</field>
|
||||||
<field name="product_id" position="after">
|
<field name="product_id" position="after">
|
||||||
<field name="equipment_id" optional="hide"/>
|
<field name="equipment_id" optional="hide"/>
|
||||||
</field>
|
</field>
|
||||||
@@ -31,7 +37,7 @@
|
|||||||
<field name="date_planned_start" string="计划开始日期" optional="show"/>
|
<field name="date_planned_start" string="计划开始日期" optional="show"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='date_planned_finished']" position="replace">
|
<xpath expr="//field[@name='date_planned_finished']" position="replace">
|
||||||
<field name="date_planned_finished" string="计划结束日期" optional="show"/>
|
<field name="date_planned_finished" string="计划结束日期" optional="hide"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//button[@name='button_start']" position="attributes">
|
<xpath expr="//button[@name='button_start']" position="attributes">
|
||||||
<attribute name="attrs">{'invisible': ['|', '|', '|','|','|', ('production_state','in', ('draft',
|
<attribute name="attrs">{'invisible': ['|', '|', '|','|','|', ('production_state','in', ('draft',
|
||||||
@@ -118,6 +124,7 @@
|
|||||||
<field name='user_permissions' invisible="1"/>
|
<field name='user_permissions' invisible="1"/>
|
||||||
<field name='name' invisible="1"/>
|
<field name='name' invisible="1"/>
|
||||||
<field name='is_delivery' invisible="1"/>
|
<field name='is_delivery' invisible="1"/>
|
||||||
|
<field name='is_send_program_again' invisible="1"/>
|
||||||
<!-- 工单form页面的开始停工按钮等 -->
|
<!-- 工单form页面的开始停工按钮等 -->
|
||||||
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
|
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
|
||||||
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('pending_processing', 'pending_cam', 'pending_era_cam')), ('state','!=','ready'), ('routing_type', 'not in', ('装夹预调', 'CNC加工', '解除装夹'))]}" -->
|
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'not in', ('pending_processing', 'pending_cam', 'pending_era_cam')), ('state','!=','ready'), ('routing_type', 'not in', ('装夹预调', 'CNC加工', '解除装夹'))]}" -->
|
||||||
@@ -152,7 +159,12 @@
|
|||||||
<!-- groups="sf_base.group_sf_mrp_user" -->
|
<!-- groups="sf_base.group_sf_mrp_user" -->
|
||||||
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -->
|
<!-- attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/> -->
|
||||||
<button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"
|
<button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"
|
||||||
attrs="{'invisible': ['|',('routing_type','!=','装夹预调'),('is_delivery','=',True)]}"/>
|
attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('is_delivery','=',True),('state','!=','done')]}"/>
|
||||||
|
<button name="button_send_program_again" type="object" string="重新下发NC程序" class="btn-primary"
|
||||||
|
confirm="是否确认重新下发NC程序?"
|
||||||
|
groups="sf_base.group_sf_order_user,sf_base.group_sf_equipment_user"
|
||||||
|
attrs="{'invisible': ['|', '|', '|',('routing_type','!=','装夹预调'),('state','in',['done', 'cancel',
|
||||||
|
'progress']),('cnc_worksheet','=',False),('is_send_program_again','=',True)]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//page[1]" position="before">
|
<xpath expr="//page[1]" position="before">
|
||||||
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>
|
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>
|
||||||
@@ -204,17 +216,17 @@
|
|||||||
<field name="processing_panel" readonly="1"
|
<field name="processing_panel" readonly="1"
|
||||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||||
<field name="equipment_id"
|
<field name="equipment_id"
|
||||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||||
<field name="production_line_id"
|
<field name="production_line_id"
|
||||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||||
<field name="production_line_state"
|
<field name="production_line_state"
|
||||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||||
<field name="functional_fixture_id"
|
<!-- <field name="functional_fixture_id" -->
|
||||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> -->
|
||||||
<field name="functional_fixture_code" force_save="1"
|
<!-- <field name="functional_fixture_code" force_save="1" -->
|
||||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> -->
|
||||||
<field name="functional_fixture_type_id"
|
<!-- <field name="functional_fixture_type_id" -->
|
||||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> -->
|
||||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||||
@@ -282,20 +294,26 @@
|
|||||||
<!-- </group>-->
|
<!-- </group>-->
|
||||||
<group string="托盘">
|
<group string="托盘">
|
||||||
<field name="tray_serial_number" readonly="1" string="序列号"/>
|
<field name="tray_serial_number" readonly="1" string="序列号"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
<field name="tray_product_id" readonly="1" string="名称"/>
|
<field name="tray_product_id" readonly="1" string="名称"/>
|
||||||
<field name="tray_brand_id" readonly="1" string="品牌"/>
|
<field name="tray_brand_id" readonly="1" string="品牌"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
<field name="tray_type_id" readonly="1" string="类型"/>
|
<field name="tray_type_id" readonly="1" string="类型"/>
|
||||||
<field name="tray_model_id" readonly="1" string="型号"/>
|
<field name="tray_model_id" readonly="1" string="型号"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
<group string="加工图纸">
|
||||||
|
<!-- 隐藏加工图纸字段名 -->
|
||||||
|
<field name="processing_drawing" widget="pdf_viewer" string="" readonly="1"/>
|
||||||
|
</group>
|
||||||
<group string="预调程序信息">
|
<group string="预调程序信息">
|
||||||
<field name="preset_program_information" colspan="2" nolabel="1"
|
<field name="preset_program_information" colspan="2" nolabel="1"
|
||||||
placeholder="如有预调程序信息请在此处输入....."/>
|
placeholder="如有预调程序信息请在此处输入....."/>
|
||||||
</group>
|
</group>
|
||||||
<group string="加工图纸">
|
|
||||||
<!-- 隐藏加工图纸字段名 -->
|
|
||||||
<field name="processing_drawing" widget="pdf_viewer" string=""/>
|
|
||||||
</group>
|
|
||||||
</page>
|
</page>
|
||||||
<page string="前置三元检测定位参数" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
|
<page string="前置三元检测定位参数" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
|
||||||
|
|
||||||
@@ -478,13 +496,13 @@
|
|||||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||||
<group>
|
<group>
|
||||||
<field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/>
|
<field name="test_results" attrs='{"invisible":[("results","!=",False)]}'/>
|
||||||
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>-->
|
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>-->
|
||||||
<!-- <field name="is_fetchcnc"-->
|
<!-- <field name="is_fetchcnc"-->
|
||||||
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>-->
|
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>-->
|
||||||
<!-- <field name="reason"-->
|
<!-- <field name="reason"-->
|
||||||
<!-- attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>-->
|
<!-- attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")]}'/>-->
|
||||||
<!-- <field name="detailed_reason" attrs='{"invisible":[("test_results","=","合格")]}'/>-->
|
<!-- <field name="detailed_reason" attrs='{"invisible":[("test_results","=","合格")]}'/>-->
|
||||||
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>-->
|
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>-->
|
||||||
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
|
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
|
||||||
widget="pdf_viewer"/>
|
widget="pdf_viewer"/>
|
||||||
</group>
|
</group>
|
||||||
@@ -497,11 +515,11 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//page[1]" position="before">
|
<xpath expr="//page[1]" position="before">
|
||||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||||
<field name="cnc_ids" widget="one2many" string="工作程序" default_order="sequence_number,id">
|
<field name="cnc_ids" widget="one2many" string="工作程序" default_order="sequence_number,id"
|
||||||
<tree decoration-success="button_state" decoration-bf="button_state">
|
readonly="1">
|
||||||
|
<tree>
|
||||||
<field name="sequence_number"/>
|
<field name="sequence_number"/>
|
||||||
<field name="program_name"/>
|
<field name="program_name"/>
|
||||||
<field name="cnc_id" string="文件"/>
|
|
||||||
<field name="cutting_tool_name"/>
|
<field name="cutting_tool_name"/>
|
||||||
<field name="cutting_tool_no"/>
|
<field name="cutting_tool_no"/>
|
||||||
<field name="processing_type"/>
|
<field name="processing_type"/>
|
||||||
@@ -511,8 +529,10 @@
|
|||||||
<field name="cutting_tool_extension_length"/>
|
<field name="cutting_tool_extension_length"/>
|
||||||
<field name="cutting_tool_handle_type"/>
|
<field name="cutting_tool_handle_type"/>
|
||||||
<field name="estimated_processing_time"/>
|
<field name="estimated_processing_time"/>
|
||||||
|
<field name="program_path"/>
|
||||||
|
<field name="program_create_date"/>
|
||||||
<field name="remark"/>
|
<field name="remark"/>
|
||||||
<field name="button_state" invisible="1"/>
|
<!-- <field name="button_state" invisible="1"/>-->
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
<group>
|
<group>
|
||||||
@@ -520,20 +540,12 @@
|
|||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="CMM程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
<page string="CMM程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||||
<field name="cmm_ids" widget="one2many" string="CMM程序">
|
<field name="cmm_ids" widget="one2many" string="CMM程序" readonly="1">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="sequence_number"/>
|
<field name="sequence_number"/>
|
||||||
<field name="program_name"/>
|
<field name="program_name"/>
|
||||||
<field name="cmm_id" string="文件"/>
|
<field name="program_path"/>
|
||||||
<field name="cutting_tool_name"/>
|
<field name="program_create_date"/>
|
||||||
<field name="cutting_tool_no"/>
|
|
||||||
<field name="processing_type"/>
|
|
||||||
<field name="margin_x_y"/>
|
|
||||||
<field name="margin_z"/>
|
|
||||||
<field name="depth_of_processing_z"/>
|
|
||||||
<field name="cutting_tool_extension_length"/>
|
|
||||||
<field name="cutting_tool_handle_type"/>
|
|
||||||
<field name="estimated_processing_time"/>
|
|
||||||
<field name="remark"/>
|
<field name="remark"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
@@ -563,9 +575,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//form//sheet//group//group//div[3]" position="after">
|
<xpath expr="//form//sheet//group//group//div[3]" position="after">
|
||||||
<field name="is_ok"/>
|
<field name="is_ok" attrs='{"invisible": [("routing_type","=","装夹预调")]}'/>
|
||||||
<field name="processing_user_id"/>
|
<field name="processing_user_id" attrs='{"invisible": [("routing_type","=","装夹预调")]}'/>
|
||||||
<field name="inspection_user_id"/>
|
<field name="inspection_user_id" attrs='{"invisible": [("routing_type","=","装夹预调")]}'/>
|
||||||
<field name="save_name" widget="CopyClipboardChar"
|
<field name="save_name" widget="CopyClipboardChar"
|
||||||
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
|
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
|
||||||
<label for="material_length" string="物料尺寸"/>
|
<label for="material_length" string="物料尺寸"/>
|
||||||
@@ -580,10 +592,24 @@
|
|||||||
<field name="material_height" class="o_address_zip"/>
|
<field name="material_height" class="o_address_zip"/>
|
||||||
</div>
|
</div>
|
||||||
<field name="part_number" string="成品的零件图号"/>
|
<field name="part_number" string="成品的零件图号"/>
|
||||||
|
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||||
|
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||||
|
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="workcenter_form_workorder_search" model="ir.ui.view">
|
||||||
|
<field name="name">custom.workorder.search</field>
|
||||||
|
<field name="model">mrp.workorder</field>
|
||||||
|
<field name="inherit_id" ref="mrp.view_mrp_production_work_order_search"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="product_id" position="after">
|
||||||
|
<field name="part_number" string="成品零件图号"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="mrp_workorder_action_schedule" model="ir.actions.act_window">
|
<record id="mrp_workorder_action_schedule" model="ir.actions.act_window">
|
||||||
<field name="name">工单</field>
|
<field name="name">工单</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
|||||||
@@ -24,82 +24,71 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
ret = json.loads(ret['result'])
|
ret = json.loads(ret['result'])
|
||||||
logging.info('下发编程单:%s' % ret)
|
logging.info('下发编程单:%s' % ret)
|
||||||
is_delete_file = False
|
productions = request.env['mrp.production'].with_user(
|
||||||
# 查询状态为进行中且类型为获取CNC加工程序的工单
|
|
||||||
cnc_production = request.env['mrp.production'].with_user(
|
|
||||||
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])])
|
|
||||||
cnc_program = request.env['mrp.production'].with_user(
|
|
||||||
request.env.ref("base.user_admin")).search(
|
request.env.ref("base.user_admin")).search(
|
||||||
[('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)])
|
[('programming_no', '=', ret['programming_no'])])
|
||||||
if cnc_production.workorder_ids.filtered(lambda a: a.routing_type == 'CNC加工').cnc_ids:
|
if productions:
|
||||||
is_delete_file = True
|
|
||||||
cnc_production.workorder_ids.filtered(
|
|
||||||
lambda a1: a1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
|
||||||
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_production)
|
|
||||||
if cnc_program.workorder_ids.filtered(lambda c: c.routing_type == 'CNC加工').cnc_ids:
|
|
||||||
cnc_program.workorder_ids.filtered(
|
|
||||||
lambda c1: c1.routing_type == 'CNC加工').cnc_ids.sudo().unlink()
|
|
||||||
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_program)
|
|
||||||
# cnc_program = request.env['mrp.production'].with_user(
|
|
||||||
# request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)])
|
|
||||||
logging.info('制造订单号:%s' % cnc_production.name)
|
|
||||||
if cnc_production:
|
|
||||||
# if ret['glb_file']:
|
|
||||||
# cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
|
||||||
# 拉取所有加工面的程序文件
|
# 拉取所有加工面的程序文件
|
||||||
if is_delete_file is True:
|
for r in ret['processing_panel'].split(','):
|
||||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', 'R')
|
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||||
files_r = os.listdir(program_path_tmp_r)
|
files_r = os.listdir(program_path_tmp_r)
|
||||||
if files_r:
|
if files_r:
|
||||||
for file_name in files_r:
|
for file_name in files_r:
|
||||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
for r in ret['processing_panel']:
|
download_state = request.env['sf.cnc.processing'].with_user(
|
||||||
download_state = request.env['sf.cnc.processing'].with_user(
|
request.env.ref("base.user_admin")).download_file_tmp(
|
||||||
request.env.ref("base.user_admin")).download_file_tmp(
|
ret['folder_name'], r)
|
||||||
ret['folder_name'], r)
|
if download_state == 0:
|
||||||
if download_state == 0:
|
res['status'] = -2
|
||||||
res['status'] = -2
|
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
|
||||||
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
|
return json.JSONEncoder().encode(res)
|
||||||
return json.JSONEncoder().encode(res)
|
for production in productions:
|
||||||
logging.info('创建cnc工单')
|
if not production.workorder_ids:
|
||||||
program_path_tmp = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
production.product_id.model_processing_panel = ret['processing_panel']
|
||||||
# program_path_tmp = "C://Users//43484//Desktop//机企猫工作文档//其他//model_analysis"
|
production._create_workorder(ret)
|
||||||
files = os.listdir(program_path_tmp)
|
else:
|
||||||
cnc_processing_arr = []
|
for panel in ret['processing_panel'].split(','):
|
||||||
for f in files:
|
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
program_path = os.path.join(program_path_tmp, f)
|
cnc_workorder = production.workorder_ids.filtered(
|
||||||
logging.info('cnc程序路径 :%s' % program_path)
|
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
|
||||||
if f.endswith(".doc"):
|
'cancel'] and ac.processing_panel == panel)
|
||||||
# 插入cmm程序数据
|
if cnc_workorder:
|
||||||
cmm_program = request.env['sf.cmm.program'].with_user(
|
if cnc_workorder.cnc_ids:
|
||||||
request.env.ref("base.user_admin")).cmm_program_create(ret, program_path, program_path_tmp)
|
cnc_workorder.cmm_ids.sudo().unlink()
|
||||||
cnc_processing = request.env['sf.cnc.processing'].with_user(
|
cnc_workorder.cnc_ids.sudo().unlink()
|
||||||
request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret, program_path,
|
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
|
||||||
program_path_tmp)
|
production)
|
||||||
logging.info('cnc_processing111:%s' % cnc_processing)
|
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||||
if cnc_processing:
|
# panel)
|
||||||
cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing))
|
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||||
if (cnc_program and cnc_processing_arr) or (not cnc_program and cnc_processing_arr):
|
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
||||||
cnc_production.workorder_ids.filtered(lambda g: g.routing_type == '装夹预调').write(
|
files_panel = os.listdir(program_path_tmp_panel)
|
||||||
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
if files_panel:
|
||||||
lambda g1: g1.routing_type == 'CNC加工').cnc_worksheet})
|
for file in files_panel:
|
||||||
if cnc_program and cnc_processing_arr:
|
file_extension = os.path.splitext(file)[1]
|
||||||
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
logging.info('file_extension:%s' % file_extension)
|
||||||
cnc_program.workorder_ids.filtered(lambda d: d.routing_type == '装夹预调').write(
|
if file_extension.lower() == '.pdf':
|
||||||
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||||
lambda d1: d1.routing_type == 'CNC加工').cnc_worksheet})
|
logging.info('panel_file_path:%s' % panel_file_path)
|
||||||
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
cnc_workorder.write(
|
||||||
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
{'is_send_program_again': False,
|
||||||
lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
|
'cnc_ids': cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel, ret),
|
||||||
cnc_program |= cnc_production
|
'cmm_ids': cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel, ret),
|
||||||
if not cnc_program and cnc_processing_arr:
|
'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
cnc_program = cnc_production
|
pre_workorder = production.workorder_ids.filtered(
|
||||||
cnc_program_ids = [item.id for item in cnc_program]
|
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done',
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
'cancel'] and ap.processing_panel == panel)
|
||||||
[('production_id', 'in', cnc_program_ids)])
|
if pre_workorder:
|
||||||
if workpiece_delivery:
|
pre_workorder.write(
|
||||||
workpiece_delivery.write({'is_cnc_program_down': True})
|
{'is_send_program_again': False,
|
||||||
|
'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
|
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
|
cnc_program_ids = [item.id for item in productions]
|
||||||
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
|
[('production_id', 'in', cnc_program_ids)])
|
||||||
|
if workpiece_delivery:
|
||||||
|
workpiece_delivery.write({'is_cnc_program_down': True})
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
else:
|
else:
|
||||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class sf_production_plan(models.Model):
|
|||||||
('done', '已排程'),
|
('done', '已排程'),
|
||||||
('processing', '加工中'),
|
('processing', '加工中'),
|
||||||
('finished', '已完成')
|
('finished', '已完成')
|
||||||
], string='工单状态', tracking=True)
|
], string='状态', tracking=True)
|
||||||
|
|
||||||
state_order = fields.Integer(compute='_compute_state_order', store=True)
|
state_order = fields.Integer(compute='_compute_state_order', store=True)
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class sf_production_plan(models.Model):
|
|||||||
|
|
||||||
_order = 'state_order asc, write_date desc'
|
_order = 'state_order asc, write_date desc'
|
||||||
|
|
||||||
name = fields.Char(string='工单编号')
|
name = fields.Char(string='制造订单')
|
||||||
active = fields.Boolean(string='已归档', default=True)
|
active = fields.Boolean(string='已归档', default=True)
|
||||||
# selected = fields.Boolean(default=False)
|
# selected = fields.Boolean(default=False)
|
||||||
# order_number = fields.Char(string='订单号')
|
# order_number = fields.Char(string='订单号')
|
||||||
@@ -52,7 +52,7 @@ class sf_production_plan(models.Model):
|
|||||||
schedule_setting = fields.Selection([
|
schedule_setting = fields.Selection([
|
||||||
('reverse', '倒排'), ('positive', '顺排')], string='排程设置', default='reverse')
|
('reverse', '倒排'), ('positive', '顺排')], string='排程设置', default='reverse')
|
||||||
product_id = fields.Many2one('product.product', '关联产品')
|
product_id = fields.Many2one('product.product', '关联产品')
|
||||||
origin = fields.Char(string='订单号')
|
origin = fields.Char(string='销售订单')
|
||||||
# # 加工时长
|
# # 加工时长
|
||||||
# process_time = fields.Float(string='加工时长', digits=(16, 2))
|
# process_time = fields.Float(string='加工时长', digits=(16, 2))
|
||||||
# 实际加工时长、实际开始时间、实际结束时间
|
# 实际加工时长、实际开始时间、实际结束时间
|
||||||
@@ -200,22 +200,23 @@ class sf_production_plan(models.Model):
|
|||||||
raise ValidationError("未选择生产线")
|
raise ValidationError("未选择生产线")
|
||||||
else:
|
else:
|
||||||
workorder_id_list = record.production_id.workorder_ids.ids
|
workorder_id_list = record.production_id.workorder_ids.ids
|
||||||
if record.production_id.workorder_ids:
|
if record.production_id:
|
||||||
for item in record.production_id.workorder_ids:
|
if record.production_id.workorder_ids:
|
||||||
if item.name == 'CNC加工':
|
for item in record.production_id.workorder_ids:
|
||||||
item.date_planned_finished = datetime.now() + timedelta(days=100)
|
if item.name == 'CNC加工':
|
||||||
# item.date_planned_start = record.date_planned_start
|
item.date_planned_finished = datetime.now() + timedelta(days=100)
|
||||||
item.date_planned_start = self.date_planned_start if self.date_planned_start else datetime.now()
|
# item.date_planned_start = record.date_planned_start
|
||||||
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
item.date_planned_start = self.date_planned_start if self.date_planned_start else datetime.now()
|
||||||
item.date_planned_finished = item.date_planned_start + timedelta(
|
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||||
minutes=record.env['mrp.routing.workcenter'].sudo().search(
|
item.date_planned_finished = item.date_planned_start + timedelta(
|
||||||
[('name', '=', 'CNC加工')]).time_cycle)
|
minutes=record.env['mrp.routing.workcenter'].sudo().search(
|
||||||
item.duration_expected = record.env['mrp.routing.workcenter'].sudo().search(
|
[('name', '=', 'CNC加工')]).time_cycle)
|
||||||
[('name', '=', 'CNC加工')]).time_cycle
|
item.duration_expected = record.env['mrp.routing.workcenter'].sudo().search(
|
||||||
record.calculate_plan_time_before(item, workorder_id_list)
|
[('name', '=', 'CNC加工')]).time_cycle
|
||||||
record.calculate_plan_time_after(item, workorder_id_list)
|
record.calculate_plan_time_before(item, workorder_id_list)
|
||||||
record.date_planned_start, record.date_planned_finished = \
|
record.calculate_plan_time_after(item, workorder_id_list)
|
||||||
item.date_planned_start, item.date_planned_finished
|
record.date_planned_start, record.date_planned_finished = \
|
||||||
|
item.date_planned_start, item.date_planned_finished
|
||||||
record.state = 'done'
|
record.state = 'done'
|
||||||
# record.production_id.schedule_state = '已排'
|
# record.production_id.schedule_state = '已排'
|
||||||
record.sudo().production_id.schedule_state = '已排'
|
record.sudo().production_id.schedule_state = '已排'
|
||||||
@@ -231,12 +232,12 @@ class sf_production_plan(models.Model):
|
|||||||
# record.production_id.date_planned_start = record.date_planned_start
|
# record.production_id.date_planned_start = record.date_planned_start
|
||||||
# record.production_id.date_planned_finished = record.date_planned_finished
|
# record.production_id.date_planned_finished = record.date_planned_finished
|
||||||
record.sudo().production_id.production_line_id = record.production_line_id.id
|
record.sudo().production_id.production_line_id = record.production_line_id.id
|
||||||
record.sudo().production_id.workorder_ids.filtered(
|
if record.production_id.workorder_ids:
|
||||||
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
|
record.sudo().production_id.workorder_ids.filtered(
|
||||||
{'production_line_id': record.production_line_id.id,
|
lambda b: b.routing_type == "装夹预调").workpiece_delivery_ids.write(
|
||||||
'plan_start_processing_time': record.date_planned_start})
|
{'production_line_id': record.production_line_id.id,
|
||||||
else:
|
'plan_start_processing_time': record.date_planned_start})
|
||||||
raise ValidationError("未找到工单")
|
|
||||||
# record.date_planned_finished = record.date_planned_start + timedelta(days=3)
|
# record.date_planned_finished = record.date_planned_start + timedelta(days=3)
|
||||||
# record.state = 'done'
|
# record.state = 'done'
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -17,18 +17,18 @@
|
|||||||
decoration-danger="state == 'finished'"/>
|
decoration-danger="state == 'finished'"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
<field name="order_deadline"/>
|
<field name="order_deadline" widget="date"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="production_line_id"/>
|
<field name="production_line_id"/>
|
||||||
<field name="date_planned_start"/>
|
<field name="date_planned_start"/>
|
||||||
<field name="date_planned_finished"/>
|
<field name="date_planned_finished"/>
|
||||||
<field name="actual_start_time"/>
|
<field name="actual_start_time" optional='hide'/>
|
||||||
<field name="actual_end_time"/>
|
<field name="actual_end_time" optional='hide'/>
|
||||||
<field name="actual_process_time"/>
|
<field name="actual_process_time" optional='hide'/>
|
||||||
<field name="schedule_setting"/>
|
<field name="schedule_setting" optional='hide'/>
|
||||||
<button name="do_production_schedule" class="btn schedule_done" string="生产排程" type="object"
|
<!-- <button name="do_production_schedule" class="btn schedule_done" string="生产排程" type="object" -->
|
||||||
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('actual_start_time', '!=', False)]}"
|
<!-- attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('actual_start_time', '!=', False)]}" -->
|
||||||
groups="sf_base.group_plan_dispatch"/>
|
<!-- groups="sf_base.group_plan_dispatch"/> -->
|
||||||
<button name="cancel_production_schedule" class="btn schedule_cancel" string="取消排程" type="object"
|
<button name="cancel_production_schedule" class="btn schedule_cancel" string="取消排程" type="object"
|
||||||
attrs="{'invisible': ['|', ('state', '!=', 'done'), ('actual_start_time', '!=', False)]}"
|
attrs="{'invisible': ['|', ('state', '!=', 'done'), ('actual_start_time', '!=', False)]}"
|
||||||
groups="sf_base.group_plan_dispatch"/>
|
groups="sf_base.group_plan_dispatch"/>
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="order_deadline"/>
|
<field name="order_deadline" widget="date"/>
|
||||||
<!-- <field name="process_time"/> -->
|
<!-- <field name="process_time"/> -->
|
||||||
<field name="schedule_setting"/>
|
<field name="schedule_setting"/>
|
||||||
<field name="production_line_id" domain="[('name', 'ilike', 'CNC')]"/>
|
<field name="production_line_id" domain="[('name', 'ilike', 'CNC')]"/>
|
||||||
@@ -152,16 +152,27 @@
|
|||||||
<field name="model">sf.production.plan</field>
|
<field name="model">sf.production.plan</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="订单计划">
|
<search string="订单计划">
|
||||||
|
|
||||||
<!-- Your other filters go here -->
|
<!-- Your other filters go here -->
|
||||||
<filter name="archived" string="已归档" domain="[('active','=',False)]"/>
|
<!-- <filter name="archived" string="已归档" domain="[('active','=',False)]"/> -->
|
||||||
<filter name="not archived" string="未归档" domain="[('active','=',True)]"/>
|
<!-- <filter name="not archived" string="未归档" domain="[('active','=',True)]"/> -->
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="date_planned_start"/>
|
|
||||||
<field name="date_planned_finished"/>
|
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<searchpanel class="account_root">
|
<filter string="待排程" name="draft" domain="[('state','=','draft')]"/>
|
||||||
<field name="state" icon="fa-filter"/>
|
<filter string="已排程" name="done" domain="[('state','=','done')]"/>
|
||||||
|
<filter string="加工中" name="processing" domain="[('state','=','processing')]"/>
|
||||||
|
<filter string="已完成" name="finished" domain="[('state','=','finished')]"/>
|
||||||
|
<group expand="0" string="Group By">
|
||||||
|
<filter name="group_by_state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
|
||||||
|
</group>
|
||||||
|
<group expand="0" string="Group By">
|
||||||
|
<filter name="group_by_production_line_id" string="生产线" domain="[]" context="{'group_by': 'production_line_id'}"/>
|
||||||
|
</group>
|
||||||
|
<searchpanel>
|
||||||
|
<!-- <field name="state" icon="fa-filter"/> -->
|
||||||
|
<field name="production_line_id" select="multi" string="生产线" icon="fa-building" enable_counters="1"/>
|
||||||
|
<field name="state" select="multi" string="状态" icon="fa-building" enable_counters="1"/>
|
||||||
</searchpanel>
|
</searchpanel>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
@@ -188,30 +199,41 @@
|
|||||||
<field name="date_planned_start"/>
|
<field name="date_planned_start"/>
|
||||||
<field name="date_planned_finished"/>
|
<field name="date_planned_finished"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
|
<field name="origin"/>
|
||||||
|
<field name="order_deadline"/>
|
||||||
|
<field name="product_id"/>
|
||||||
<templates>
|
<templates>
|
||||||
<div t-name="gantt-popover" class="container-fluid">
|
<div t-name="gantt-popover" class="container-fluid">
|
||||||
<div class="row g-0">
|
<div class="row g-0">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<ul class="ps-1 mb-0 list-unstyled">
|
<ul class="ps-1 mb-0 list-unstyled">
|
||||||
<li>
|
<li>
|
||||||
<strong>开始时间:</strong>
|
<strong>销售订单号:</strong>
|
||||||
<t t-out="userTimezoneStartDate.format('L LTS')"/>
|
<t t-out="origin"/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>结束时间:</strong>
|
<strong>制造订单号:</strong>
|
||||||
<t t-out="userTimezoneStopDate.format('L LTS')"/>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<strong>名称:</strong>
|
|
||||||
<t t-out="name"/>
|
<t t-out="name"/>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>订单交期:</strong>
|
||||||
|
<t t-out="order_deadline"/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>产品名称:</strong>
|
||||||
|
<t t-out="product_id"/>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>数量:</strong>
|
<strong>数量:</strong>
|
||||||
<t t-out="product_qty"/>
|
<t t-out="product_qty"/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>状态:</strong>
|
<strong>计划开始时间:</strong>
|
||||||
<t t-out="state"/>
|
<t t-out="userTimezoneStartDate.format('L LTS')"/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>计划结束时间:</strong>
|
||||||
|
<t t-out="userTimezoneStopDate.format('L LTS')"/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -246,6 +268,7 @@
|
|||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">sf.production.plan</field>
|
<field name="res_model">sf.production.plan</field>
|
||||||
<field name="view_mode">tree,gantt,form</field>
|
<field name="view_mode">tree,gantt,form</field>
|
||||||
|
<field name="context">{'search_default_group_by_state': 1, 'search_default_draft': 1, 'display_complete': True}</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem
|
<menuitem
|
||||||
|
|||||||
@@ -581,6 +581,15 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
|
|
||||||
active = fields.Boolean(string='已归档', default=True)
|
active = fields.Boolean(string='已归档', default=True)
|
||||||
|
|
||||||
|
def action_open_reference1(self):
|
||||||
|
self.ensure_one()
|
||||||
|
return {
|
||||||
|
'res_model': self._name,
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'views': [[False, "form"]],
|
||||||
|
'res_id': self.id,
|
||||||
|
}
|
||||||
|
|
||||||
def put_start_preset(self):
|
def put_start_preset(self):
|
||||||
self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False})
|
self.search([('start_preset_bool', '=', True)]).write({'start_preset_bool': False})
|
||||||
self.write({
|
self.write({
|
||||||
@@ -750,7 +759,8 @@ class FunctionalToolDismantle(models.Model):
|
|||||||
return 'GNDJ-CJD-%s-%s' % (datetime, num)
|
return 'GNDJ-CJD-%s-%s' % (datetime, num)
|
||||||
|
|
||||||
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
|
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
|
||||||
domain=[('functional_tool_status', '!=', '已拆除')])
|
domain=[('functional_tool_status', '!=', '已拆除'),
|
||||||
|
('current_location', '=', '刀具房')])
|
||||||
tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
|
tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True,
|
||||||
compute='_compute_functional_tool_num')
|
compute='_compute_functional_tool_num')
|
||||||
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True)
|
tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True)
|
||||||
@@ -1028,7 +1038,7 @@ class ProductProduct(models.Model):
|
|||||||
'product_id': self.id,
|
'product_id': self.id,
|
||||||
'lot_id': lot_id.id,
|
'lot_id': lot_id.id,
|
||||||
'move_id': stock_move_id.id,
|
'move_id': stock_move_id.id,
|
||||||
'destination_location_id': shelf_location_id.id,
|
'destination_location_id': shelf_location_id.id if shelf_location_id else False,
|
||||||
'install_tool_time': fields.Datetime.now(),
|
'install_tool_time': fields.Datetime.now(),
|
||||||
'qty_done': 1.0,
|
'qty_done': 1.0,
|
||||||
'state': 'done',
|
'state': 'done',
|
||||||
|
|||||||
@@ -387,6 +387,22 @@ class StockMoveLine(models.Model):
|
|||||||
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
||||||
return categories.browse(names)
|
return categories.browse(names)
|
||||||
|
|
||||||
|
def action_open_reference1(self):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.functional_tool_name_id:
|
||||||
|
action = self.functional_tool_name_id.action_open_reference1()
|
||||||
|
return action
|
||||||
|
elif self.move_id:
|
||||||
|
action = self.move_id.action_open_reference()
|
||||||
|
if action['res_model'] != 'stock.move':
|
||||||
|
return action
|
||||||
|
return {
|
||||||
|
'res_model': self._name,
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'views': [[False, "form"]],
|
||||||
|
'res_id': self.id,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class RealTimeDistributionOfFunctionalTools(models.Model):
|
class RealTimeDistributionOfFunctionalTools(models.Model):
|
||||||
_name = 'sf.real.time.distribution.of.functional.tools'
|
_name = 'sf.real.time.distribution.of.functional.tools'
|
||||||
@@ -404,8 +420,8 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
|
|||||||
side_shelf_num = fields.Integer(string='线边刀库数量', compute='_compute_stock_num', store=True)
|
side_shelf_num = fields.Integer(string='线边刀库数量', compute='_compute_stock_num', store=True)
|
||||||
on_tool_stock_num = fields.Integer(string='机内刀库数量', compute='_compute_stock_num', store=True)
|
on_tool_stock_num = fields.Integer(string='机内刀库数量', compute='_compute_stock_num', store=True)
|
||||||
tool_stock_total = fields.Integer(string='当前库存量', compute='_compute_tool_stock_total', store=True)
|
tool_stock_total = fields.Integer(string='当前库存量', compute='_compute_tool_stock_total', store=True)
|
||||||
min_stock_num = fields.Integer('最低库存量')
|
min_stock_num = fields.Integer('最低库存量', tracking=True)
|
||||||
max_stock_num = fields.Integer('最高库存量')
|
max_stock_num = fields.Integer('最高库存量', tracking=True)
|
||||||
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num',
|
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num',
|
||||||
store=True)
|
store=True)
|
||||||
unit = fields.Char('单位', default="件")
|
unit = fields.Char('单位', default="件")
|
||||||
|
|||||||
@@ -477,7 +477,8 @@
|
|||||||
<field name="name">功能刀具出入库记录</field>
|
<field name="name">功能刀具出入库记录</field>
|
||||||
<field name="model">stock.move.line</field>
|
<field name="model">stock.move.line</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="功能刀具出入库记录" create="0" edit="0" delete="0">
|
<tree string="功能刀具出入库记录" create="0" edit="0" delete="0" default_order="id desc"
|
||||||
|
action="action_open_reference1" type="object">
|
||||||
<field name="reference" string="单据号"/>
|
<field name="reference" string="单据号"/>
|
||||||
<field name="lot_id" invisible="1"/>
|
<field name="lot_id" invisible="1"/>
|
||||||
<field name="rfid"/>
|
<field name="rfid"/>
|
||||||
@@ -531,7 +532,7 @@
|
|||||||
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_tree"/>
|
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_tree"/>
|
||||||
<field name="search_view_id"
|
<field name="search_view_id"
|
||||||
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_search"/>
|
ref="sf_tool_management.sf_inbound_and_outbound_records_of_functional_tools_view_search"/>
|
||||||
<field name="domain">[('functional_tool_name', '!=', False)]</field>
|
<field name="domain">[('rfid', '!=', ''),('functional_tool_name', '!=', '')]</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
Reference in New Issue
Block a user