This commit is contained in:
jinling.yang
2024-06-25 11:07:41 +08:00
4 changed files with 93 additions and 66 deletions

View File

@@ -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" attrs="{'readonly': [('id', '!=', False)]}"/> <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" required="1" attrs="{'readonly': [('id', '!=', False)]}"/> <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"/>

View File

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

View File

@@ -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))
# 实际加工时长、实际开始时间、实际结束时间 # 实际加工时长、实际开始时间、实际结束时间

View File

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