Compare commits
3 Commits
c5dfb50da5
...
feature/wo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97a26dfa06 | ||
|
|
1224e0e094 | ||
|
|
a571a870d3 |
@@ -43,7 +43,7 @@ class WorkorderExceptionConroller(http.Controller):
|
|||||||
})
|
})
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': str(e)}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
_logger.info('workder_exception error:%s' % e)
|
_logger.info('workder_exception error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class StatusChange(models.Model):
|
|||||||
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
||||||
try:
|
try:
|
||||||
res = super(StatusChange, self).action_confirm()
|
res = super(StatusChange, self).action_confirm()
|
||||||
logging.info('原生方法返回结果:%s' % res)
|
|
||||||
# 原有方法执行后,进行额外的操作(如调用外部API)
|
# 原有方法执行后,进行额外的操作(如调用外部API)
|
||||||
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
@@ -62,7 +61,6 @@ class StatusChange(models.Model):
|
|||||||
traceback_error = traceback.format_exc()
|
traceback_error = traceback.format_exc()
|
||||||
logging.error("工厂加工同步订单状态失败:%s " % traceback_error)
|
logging.error("工厂加工同步订单状态失败:%s " % traceback_error)
|
||||||
raise UserError(e)
|
raise UserError(e)
|
||||||
logging.info('最终返回值:%s' % res)
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
'data/cron_data.xml',
|
'data/cron_data.xml',
|
||||||
'data/template_data.xml',
|
'data/template_data.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
'views/mrp_workorder_views.xml',
|
||||||
],
|
],
|
||||||
'test': [
|
'test': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class SFMessageSale(models.Model):
|
|||||||
purchase_order_info.add_queue('坯料采购提醒')
|
purchase_order_info.add_queue('坯料采购提醒')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info('add_queue error:%s' % e)
|
logging.info('add_queue error:%s' % e)
|
||||||
logging.info('action_confirm res:%s' % res)
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class SFMessageWork(models.Model):
|
|||||||
if record:
|
if record:
|
||||||
i += 1
|
i += 1
|
||||||
if i >= 1:
|
if i >= 1:
|
||||||
action_id = self.env.ref('sf_manufacturing.mrp_workorder_action_tablet').id
|
action_id = self.env.ref('sf_message.mrp_workorder_action_notify').id
|
||||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||||
content_template = content.replace('{{url}}', url_with_id)
|
content_template = content.replace('{{url}}', url_with_id)
|
||||||
if bussiness_node in template_names['预警']:
|
if bussiness_node in template_names['预警']:
|
||||||
@@ -85,7 +85,7 @@ class SFMessageWork(models.Model):
|
|||||||
|
|
||||||
def request_url(self):
|
def request_url(self):
|
||||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||||
action_id = self.env.ref('sf_manufacturing.mrp_workorder_action_tablet').id
|
action_id = self.env.ref('sf_message.mrp_workorder_action_notify').id
|
||||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_stock_dropshipping')]).id
|
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_stock_dropshipping')]).id
|
||||||
# 查询参数
|
# 查询参数
|
||||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||||
|
|||||||
@@ -5,28 +5,24 @@ access_jikimo_message_template_group_purchase,jikimo_message_template,jikimo_mes
|
|||||||
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
access_jikimo_message_template_group_purchase_director,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_purchase_director,1,1,1,0
|
|
||||||
|
|
||||||
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
access_jikimo_message_bussiness_node_group_purchase_director,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase_director,1,1,1,0
|
|
||||||
|
|
||||||
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
access_jikimo_message_queue_group_purchase_director,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase_director,1,1,1,0
|
|
||||||
|
|
||||||
access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0
|
access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0
|
access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0
|
access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0
|
||||||
access_jikimo_message_reminder_time_group_purchase_director,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase_director,1,1,1,0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
34
sf_message/views/mrp_workorder_views.xml
Normal file
34
sf_message/views/mrp_workorder_views.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.actions.act_window" id="mrp_workorder_action_notify">
|
||||||
|
<field name="name">工单</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">mrp.workorder</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="view_ids" eval="[(5, 0, 0),
|
||||||
|
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp.mrp_production_workorder_tree_editable_view')}) ]"/>
|
||||||
|
<!-- (0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')})-->
|
||||||
|
<!-- <field name="target">fullscreen</field>-->
|
||||||
|
<field name="target">current</field>
|
||||||
|
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||||
|
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
||||||
|
active_id,'search_default_filter_order_warning':1,'search_default_filter_order_overdue':1,
|
||||||
|
'search_default_ready': 1, 'search_default_progress': 1}
|
||||||
|
</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_workorder">
|
||||||
|
没有工单要做!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
工作订单是作为制造订单的一部分执行的操作。
|
||||||
|
工序在物料清单中定义或直接添加到制造订单中。
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
使用工作台工作中心控制面板直接登记车间中的操作.
|
||||||
|
平板电脑为您的工人提供工作表,并允许他们报废产品,跟踪时间,
|
||||||
|
发起维护请求,执行质量测试等.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -219,7 +219,7 @@ class sf_production_plan(models.Model):
|
|||||||
|
|
||||||
return num
|
return num
|
||||||
|
|
||||||
def do_production_schedule(self):
|
def do_production_schedule(self, count=1):
|
||||||
"""
|
"""
|
||||||
排程方法
|
排程方法
|
||||||
"""
|
"""
|
||||||
@@ -227,27 +227,29 @@ class sf_production_plan(models.Model):
|
|||||||
if not record.production_line_id:
|
if not record.production_line_id:
|
||||||
raise ValidationError("未选择生产线")
|
raise ValidationError("未选择生产线")
|
||||||
else:
|
else:
|
||||||
|
is_schedule = self.deal_processing_schedule(record.date_planned_start, count)
|
||||||
|
if not is_schedule:
|
||||||
|
raise ValidationError("排程失败")
|
||||||
|
workorder_id_list = record.production_id.workorder_ids.ids
|
||||||
|
if record.production_id:
|
||||||
if record.production_id.workorder_ids:
|
if record.production_id.workorder_ids:
|
||||||
last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
|
||||||
for item in record.production_id.workorder_ids:
|
for item in record.production_id.workorder_ids:
|
||||||
if item.name == 'CNC加工':
|
if item.name == 'CNC加工':
|
||||||
# 将同一个面的所有工单筛选出来
|
item.date_planned_finished = datetime.now() + timedelta(days=100)
|
||||||
workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
|
item.date_planned_start = self.date_planned_start if self.date_planned_start else datetime.now()
|
||||||
routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
[('name', '=', 'CNC加工')], limit=1)
|
|
||||||
# 设置一个小的开始时间
|
|
||||||
item.date_planned_start = datetime.now() - timedelta(days=100)
|
|
||||||
item.date_planned_finished = last_cnc_start + timedelta(
|
|
||||||
minutes=routing_workcenter.time_cycle)
|
|
||||||
item.date_planned_start = last_cnc_start
|
|
||||||
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||||
item.duration_expected = routing_workcenter.time_cycle
|
item.date_planned_finished = item.date_planned_start + timedelta(
|
||||||
pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
|
minutes=record.env['mrp.routing.workcenter'].sudo().search(
|
||||||
record.date_planned_finished = item.date_planned_finished
|
[('name', '=', 'CNC加工')]).time_cycle)
|
||||||
# 计算下一个cnc工单的开始时间
|
item.duration_expected = record.env['mrp.routing.workcenter'].sudo().search(
|
||||||
last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
|
[('name', '=', 'CNC加工')]).time_cycle
|
||||||
# 没有工单也能排程
|
record.calculate_plan_time_before(item, workorder_id_list)
|
||||||
|
record.calculate_plan_time_after(item, workorder_id_list)
|
||||||
|
record.date_planned_start, record.date_planned_finished = \
|
||||||
|
item.date_planned_start, item.date_planned_finished
|
||||||
record.state = 'done'
|
record.state = 'done'
|
||||||
|
record.date_planned_finished = record.date_planned_start + timedelta(
|
||||||
|
minutes=60) if not record.date_planned_finished else record.date_planned_finished
|
||||||
# record.production_id.schedule_state = '已排'
|
# record.production_id.schedule_state = '已排'
|
||||||
record.sudo().production_id.schedule_state = '已排'
|
record.sudo().production_id.schedule_state = '已排'
|
||||||
record.sudo().production_id.process_state = '待装夹'
|
record.sudo().production_id.process_state = '待装夹'
|
||||||
@@ -280,9 +282,9 @@ class sf_production_plan(models.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 处理是否可排程
|
# 处理是否可排程
|
||||||
def deal_processing_schedule(self, date_planned_start,):
|
def deal_processing_schedule(self, date_planned_start, count):
|
||||||
count = len(self)
|
for record in self:
|
||||||
workcenter_ids = self.production_line_id.mrp_workcenter_ids
|
workcenter_ids = record.production_line_id.mrp_workcenter_ids
|
||||||
if not workcenter_ids:
|
if not workcenter_ids:
|
||||||
raise UserError('生产线没有配置工作中心')
|
raise UserError('生产线没有配置工作中心')
|
||||||
production_lines = workcenter_ids.filtered(lambda b: "自动生产线" in b.name)
|
production_lines = workcenter_ids.filtered(lambda b: "自动生产线" in b.name)
|
||||||
@@ -299,47 +301,35 @@ class sf_production_plan(models.Model):
|
|||||||
raise UserError('当前计划开始时间不能预约排程,生产线该时间段没有可排程的资源')
|
raise UserError('当前计划开始时间不能预约排程,生产线该时间段没有可排程的资源')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def calculate_plan_time(self, item, workorder_list):
|
def calculate_plan_time_before(self, item, workorder_id_list):
|
||||||
"""
|
"""
|
||||||
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
||||||
"""
|
"""
|
||||||
item_position = 0
|
sequence = workorder_id_list.index(item.id) - 1
|
||||||
for index, workorder in enumerate(workorder_list):
|
# 计算CNC加工之前工单的开始结束时间
|
||||||
if workorder.id == item.id:
|
for i in range(1 if sequence == 0 else sequence):
|
||||||
item_position = index
|
current_workorder_id = (item.id - (i + 1))
|
||||||
break
|
current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
routing_workcenters = self.env['mrp.routing.workcenter'].sudo().search([])
|
[('id', '=', current_workorder_id)])
|
||||||
# 记录所有前序工序时长
|
old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
previous_workorder_duration = 0
|
[('id', '=', (current_workorder_id + 1))])
|
||||||
for i in range(item_position, -1, -1):
|
work_order = self.env['mrp.workorder'].sudo().search(
|
||||||
if i < 1:
|
[('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
||||||
break
|
work_order.date_planned_finished = datetime.now() + timedelta(days=100)
|
||||||
current_workorder = workorder_list[i]
|
work_order.date_planned_start = old_workorder_obj.date_planned_start - timedelta(
|
||||||
next_workorder = workorder_list[i - 1]
|
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
[('name', '=', current_workorder_obj.name)]).time_cycle)
|
||||||
# 设置一个小的开始时间
|
work_order.date_planned_finished = old_workorder_obj.date_planned_start
|
||||||
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
next_workorder.date_planned_finished = current_workorder.date_planned_start
|
[('name', '=', current_workorder_obj.name)]).time_cycle
|
||||||
next_workorder.date_planned_start = next_workorder.date_planned_finished - timedelta(
|
first_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id_list[0])])
|
||||||
minutes=routing_workcenter.time_cycle)
|
second_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id_list[1])])
|
||||||
next_workorder.duration_expected = routing_workcenter.time_cycle
|
if second_workorder.date_planned_start < first_workorder.date_planned_finished:
|
||||||
previous_workorder_duration += routing_workcenter.time_cycle
|
item.date_planned_start += timedelta(minutes=60)
|
||||||
# 记录所有后续工序时长
|
item.date_planned_finished += timedelta(minutes=60)
|
||||||
next_workorder_duration = 0
|
item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
for i in range(item_position, len(workorder_list) - 1):
|
[('name', '=', 'CNC加工')]).time_cycle
|
||||||
if i > len(workorder_list) - 1:
|
self.calculate_plan_time_before(item, workorder_id_list)
|
||||||
break
|
|
||||||
current_workorder = workorder_list[i]
|
|
||||||
next_workorder = workorder_list[i + 1]
|
|
||||||
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
|
||||||
# 设置一个小的开始时间
|
|
||||||
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
|
||||||
next_workorder.date_planned_finished = current_workorder.date_planned_finished + timedelta(
|
|
||||||
minutes=routing_workcenter.time_cycle)
|
|
||||||
next_workorder.date_planned_start = current_workorder.date_planned_finished
|
|
||||||
next_workorder.duration_expected = routing_workcenter.time_cycle
|
|
||||||
next_workorder_duration += routing_workcenter.time_cycle
|
|
||||||
return previous_workorder_duration, next_workorder_duration
|
|
||||||
|
|
||||||
def calculate_plan_time_after(self, item, workorder_id_list):
|
def calculate_plan_time_after(self, item, workorder_id_list):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -31,10 +31,46 @@ class Action_Plan_All_Wizard(models.TransientModel):
|
|||||||
# 确认排程按钮
|
# 确认排程按钮
|
||||||
def action_plan_all(self):
|
def action_plan_all(self):
|
||||||
# 使用传递过来的计划ID
|
# 使用传递过来的计划ID
|
||||||
self.plan_ids.production_line_id = self.production_line_id.id
|
temp_plan_ids = self.plan_ids
|
||||||
self.plan_ids.date_planned_start = self.date_planned_start
|
|
||||||
# 在这里添加您的逻辑来处理这些ID
|
# 在这里添加您的逻辑来处理这些ID
|
||||||
# 判断能否排成
|
count = len(temp_plan_ids) + 1
|
||||||
self.plan_ids.deal_processing_schedule(self.date_planned_start)
|
for plan in temp_plan_ids:
|
||||||
self.plan_ids.do_production_schedule()
|
count = count - 1
|
||||||
_logger.info('处理计划: %s 完成', self.plan_ids.ids)
|
# 处理每个计划
|
||||||
|
# 比如更新计划状态、分配资源等
|
||||||
|
# 示例:plan.state = 'scheduled'
|
||||||
|
print('处理计划:', plan.id)
|
||||||
|
# 拿到计划对象
|
||||||
|
plan_obj = self.env['sf.production.plan'].browse(plan.id)
|
||||||
|
plan_obj.production_line_id = self.production_line_id.id
|
||||||
|
plan.date_planned_start = self.date_planned_start
|
||||||
|
plan_obj.do_production_schedule(count)
|
||||||
|
# plan_obj.state = 'done'
|
||||||
|
print('处理计划:', plan.id, '完成')
|
||||||
|
|
||||||
|
# # 获取当前生产线
|
||||||
|
# production_line_id = self.production_line_id
|
||||||
|
# # 获取当前生产线的所有生产订单
|
||||||
|
# production_order_ids = self.env['mrp.production'].search([('production_line_id', '=', production_line_id.id)])
|
||||||
|
# # 获取当前生产线的所有生产订单的id
|
||||||
|
# production_order_id_list = []
|
||||||
|
# for production_order_id in production_order_ids:
|
||||||
|
# production_order_id_list.append(production_order_id.id)
|
||||||
|
# # 获取当前生产线的所有生产订单的排程状态
|
||||||
|
# production_order_plan_state_list = []
|
||||||
|
# for production_order_id in production_order_ids:
|
||||||
|
# production_order_plan_state_list.append(production_order_id.plan_state)
|
||||||
|
# # 如果当前生产线的所有生产订单的排程状态都是已排程,则报错
|
||||||
|
# if all(production_order_plan_state == '已排程' for production_order_plan_state in production_order_plan_state_list):
|
||||||
|
# raise UserError('当前生产线的所有生产订单都已排程,请勿重复排程!')
|
||||||
|
# # 如果当前生产线的所有生产订单的排程状态都是未排程,则报错
|
||||||
|
# if all(production_order_plan_state == '未排程' for production_order_plan_state in production_order_plan_state_list):
|
||||||
|
# raise UserError('当前生产线的所有生产订单都未排程,请先排程!')
|
||||||
|
# # 如果当前生产线的所有生产订单的排程状态都是已完成,则报错
|
||||||
|
# if all(production_order_plan_state == '已完成' for production_order_plan_state in production_order_plan_state_list):
|
||||||
|
# raise UserError('当前生产线的所有生产订单都已完成,请勿重复排程!')
|
||||||
|
# # 如果当前生产线的所有生产订单的排程状态都是已取消,则报错
|
||||||
|
# if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list):
|
||||||
|
# raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!')
|
||||||
|
# # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错
|
||||||
|
# if all(production_order_plan_state == '已暂停' for production_order_plan_state in production
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
{
|
{
|
||||||
'name': "机企猫 库存/代发货",
|
'name': "sf_stock",
|
||||||
|
|
||||||
'summary': """
|
'summary': """
|
||||||
处理仓库 -代发货业务""",
|
处理仓库 -代发货业务""",
|
||||||
|
|||||||
Reference in New Issue
Block a user