%|p7mDn;9}Iq|bu
zoRf`RO`IheCAx`zWV-{C=iW#uO1{9UjJM==_ZF5W(ke=Oww&f(?o^AZvWkU*oI}P}
z#j{J2tRS!8suHYpx@>O0ORy9pZ38>3-{(YVF%KQ{uqTcA4YqkUc>bE%py!wh*E(W&
zWW(V807-v#`lk?`qpo
z8Yz8QFz&86s8Ch3H_EbX=D?d9oYdHvt*MPVwr2?W@%7p>WoOKP7utde2*1gdk@-xe
zooPjnSs2=d``99=(ajc<;c3qkx@orVKY1wH#_mwD*Huhu9lKblQ`=do`|`1hyF0hL
zjGbQTqY!r6`^vNR>p9>NLyP3I-)ijCt9%lZdeAjBm!@^?Ds6G0u+RC()a3a4*7F+4
zkK-oh3ksqH5J}J8T9Jr*>5<+qQN|uoCNS8JIC=Y$$x(XbHosDtcS{Ss0axBIaxrwd
z_q}%=)v>lFrlZ==uZ#Ax{{9~j|7Io)ZK|u8s1MHwf3oz>$=@vZkJtK7>#O}Vt~NEf
z4UX^3ot(PzU3kRAK#XOo^fs|=F7}t)^NtI%v+k#ik%n6))Zrl`4JqyU%|9y5^+9VR
zA6ksPSzx@m@wfpG9ck;BJ+!RE{DGuBb!-~cjo01MU
zK8=~e>c}EtFh=f+p(&xkhMj3lXS|v7y4Rk{&3df$!se!WPi(?blOKy;N1km6dSb4}
zR8a0#%L@7XQlRC@jGtDv=WW(TH98)>9NKzr`#o^}X1mK@_pUi&JNo-&!>x(@mrHv)
z0tRpQ#itQM`r8(o^=D=pv?D6-<=Kpm@edt6+WhRHZd`Y>@-#}nqD!``wOMA7)c?*Z
zENhUqHRqPo)9%0*2|n5B{YKA&ZymPx7q{ORD=Y2q&qyO1ZrVJds#QLDpS0~%;YQ5(
zk+2Uol_&4+C{Mo>Wjb^}Xp8!vXQUX(-<Q>nRb&B$%Ob=
zeu-)Hdv;~zjg`zBiBfE1BWcfr_zn$?gWcf^yl+v_TeW*8=uDqBAd3
z?}QJPF+=*m@43|nyvfYo@?FmNUELD~)r&O`6h@bWrZ^!?ldZ4+$gA&O>dVa)2Mb(7
zSEz>v&JI%>PMGLD<~#4p$&VVgSR5FLd9Qk>L-MVldN#0hS8qy#p3F(Js;j}u@5%)O
z{s=w7ir)X2vXbCj>->CloF7<|#Vxl3L_CnKeRx>jt#mgxYw<2L18<=(w00hB@spQUvI4mKb>M%#eE6)LA1mQD!FFp!Box_l9hg3^93Tsx(*4_CHx1+dPMtv7Z
zQm}qxP^RQGiE)o!r%?##RFyy3TWV62gbln~@=A-kyg0j8aPe^R@nwZ`Hv)kZFAQMX
zru#;;EjPBFHcj2rS{LvXs7Vv)U)OG2zE=-S0OvR7>+7u_$_HPaR87o{1OA*;-I@Cf
zc~bj_rn~fual&guF3R70Ln;RK^=nT2l}1-M@m>^J^v+z%P|5H2r>!~eJsp>cDml12
zULJ$ji`BF})!*q1Pmj?R$Qpll6;9VbpI8ZBjyg3V%$q2%;YoW>m;4r1Qb_I7L~d&q
zs)r>?5-M)TjOwlc?rlFA{q0cLoidg4qF?RUKzyEYkGE+ya1Jp)RA=?J2Gs?1lFV@N0cfC=wb4(grcR=%aZ8OxT^e>x1a=_^W#9PMKT2#!Hi(V#o
zjm=qU+Q;L<8Y8@0gHf*6H%|L3Fckx%=~Wk0RibAG5NMLk_IA(2z4c4^z&c>W@z8wp
So9!R}7oF@~D7Wo=qW=r=(43S2
literal 0
HcmV?d00001
diff --git a/jikimo_system_order/views/notice_user_config.xml b/jikimo_system_order/views/notice_user_config.xml
new file mode 100644
index 00000000..353afb96
--- /dev/null
+++ b/jikimo_system_order/views/notice_user_config.xml
@@ -0,0 +1,58 @@
+
+
+
+ # ---------- 工单通知处理人设置 ------------
+
+
+ tree.system.order.notice
+ system.order.notice
+
+
+
+
+
+
+
+
+
+ search.system.order.notice
+ system.order.notice
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 工单处理人
+ system.order.notice
+ tree
+ []
+ {}
+
+
+ [工单处理人] 还没有哦!点左上角的[创建]按钮,沙发归你了!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jikimo_system_order/views/work_order_number.xml b/jikimo_system_order/views/work_order_number.xml
new file mode 100644
index 00000000..63f0d5a3
--- /dev/null
+++ b/jikimo_system_order/views/work_order_number.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ seq_work_order
+
+ system.work.order
+ SO%(year)s%(month)s%(day)s
+ 1
+
+
+
+
+ seq_order_template
+
+ work.order.template
+ TL
+ 1
+
+
+
\ No newline at end of file
diff --git a/jikimo_system_order/views/yizuo_system_order_view.xml b/jikimo_system_order/views/yizuo_system_order_view.xml
new file mode 100644
index 00000000..b5de3bcc
--- /dev/null
+++ b/jikimo_system_order/views/yizuo_system_order_view.xml
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+ 工单信息
+ system.work.order
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 新建系统工单
+ system.work.order
+
+
+
+
+
+
+
+ 搜索工单
+ system.work.order
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 工单图表
+ system.work.order
+
+
+
+
+
+
+
+
+
+
+
+ 工单
+ system.work.order
+ tree,form,search,graph,pivot
+
+
+
+
+ 工单模板信息
+ work.order.template
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 新建系统工单模板
+ work.order.template
+
+
+
+
+
+
+
+ 工单模板
+ work.order.template
+ tree,form
+
+
+
+
+ 工单分类信息
+ order.classify
+
+
+
+
+
+
+
+
+
+
+
+ 新建系统分类信息
+ order.classify
+
+
+
+
+
+
+
+ 工单分类
+ order.classify
+ tree,form
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jikimo_system_order/wizard/__init__.py b/jikimo_system_order/wizard/__init__.py
new file mode 100644
index 00000000..8cf586ce
--- /dev/null
+++ b/jikimo_system_order/wizard/__init__.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+
+from . import order_other_wizard
+from . import order_technician_wizard
+from . import order_close_wizard
+from . import system_work_order_wizard
diff --git a/jikimo_system_order/wizard/order_close_wizard.py b/jikimo_system_order/wizard/order_close_wizard.py
new file mode 100644
index 00000000..ca10ae7c
--- /dev/null
+++ b/jikimo_system_order/wizard/order_close_wizard.py
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+
+from odoo import models, fields, api
+from odoo.addons.jikimo_system_order.models.constant import STATE_SELECTION
+from odoo.exceptions import ValidationError
+import datetime, logging
+
+
+class OrderCloseWizard(models.TransientModel):
+ _name = 'order.close.wizard'
+
+
+ def get_context(self):
+ if self._context.get('active_id'):
+ obj = self.env['system.work.order'].browse(self._context.get('active_id'))
+ if obj.initiator_id.id != self.env.user.id:
+ raise ValidationError(u'非本人无法操作')
+ return obj
+
+ order_id = fields.Many2one('system.work.order', string=u'工单ID',
+ default=lambda self: self.get_context().id)
+ # 关闭原因
+ close_cause = fields.Text(string=u'关闭问题原因', default=lambda self: self.get_context().close_cause)
+ # 关闭时间
+ close_time = fields.Datetime(string=u'关闭问题时间', default=fields.datetime.now())
+ # 状态
+ state = fields.Selection(STATE_SELECTION, default='closed', string=u'状态')
+ # 关闭人
+ close_user_id = fields.Many2one('res.users', string=u'关闭人', default=lambda self: self.env.user)
+
+
+ def sure(self):
+ self.order_id.close_cause = self.close_cause
+ self.order_id.close_time = self.close_time
+ if self.order_id.state == 'unconfirmed':
+ state_remark = u'待确认 --> 已关闭'
+ if self.order_id.state == 'pending':
+ state_remark = u'待处理 --> 已关闭'
+ if self.order_id.state == 'processed':
+ state_remark = u'已处理待评分 --> 已关闭'
+ # self.order_id.message_post(u'操作人:%s,操作时间:%s,状态变更过程:%s' % (
+ # self.env.user.name,
+ # (datetime.datetime.now() + datetime.timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S'), state_remark))
+ self.order_id.state = self.state
+ self.order_id.close_user_id = self.close_user_id
+ we_employee_ids = []
+ if self.order_id.initiator_id.we_employee_id:
+ we_employee_ids.append(self.order_id.initiator_id.we_employee_id)
+ lost_agent_id = self.env['ir.config_parameter'].sudo().get_param('lost_agent_id')
+ wechat = self.env['we.config'].sudo().get_wechat(agent_id=lost_agent_id)
+ # agent_id, user_ids, content
+ content = """您提交的工单-**工单标题:{0}**-**已关闭**
+ >提交时间:{1}
+ >处理时间:{2}
+ >处理人:{3}
+ 如有问题,请联系系统管理员!
+ """.format(self.order_id.title,
+ (self.order_id.date + datetime.timedelta(hours=8)).strftime(
+ '%Y-%m-%d %H:%M'), (datetime.datetime.now() + datetime.timedelta(
+ hours=8)).strftime('%Y-%m-%d %H:%M'), self.env.user.name or '')
+ # wechat.message.send_markdown(agent_id=lost_agent_id, user_ids=we_employee_ids, content=content)
+ for we_employee_id in we_employee_ids:
+ try:
+ wechat.message.send_markdown(agent_id=lost_agent_id, user_ids=we_employee_id, content=content)
+ except Exception as e:
+ logging.error('工单关闭发送消息异常%s' % str(e))
+ return {}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jikimo_system_order/wizard/order_other_wizard.py b/jikimo_system_order/wizard/order_other_wizard.py
new file mode 100644
index 00000000..3f6c8710
--- /dev/null
+++ b/jikimo_system_order/wizard/order_other_wizard.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+
+from odoo import models, fields, api
+from odoo.exceptions import ValidationError
+from odoo.addons.jikimo_system_order.models.constant import STATE_SELECTION, GRADE
+import datetime
+
+
+class OrderOtherWizard(models.TransientModel):
+ _name = 'order.other.wizard'
+
+
+ def get_context(self):
+ if self._context.get('active_id'):
+ obj = self.env['system.work.order'].browse(self._context.get('active_id'))
+ if obj.initiator_id.id != self.env.user.id:
+ raise ValidationError(u'非本人无法操作')
+ return obj
+
+ order_id = fields.Many2one('system.work.order', string=u'工单ID',
+ default=lambda self: self.get_context().id)
+ # 关闭时间
+ close_time = fields.Datetime(string=u'关闭时间', default=fields.datetime.now())
+ # 状态
+ state = fields.Selection(STATE_SELECTION, default='completed', string=u'状态')
+ # 打分
+ grade = fields.Selection(GRADE, string=u'评分')
+ # 关闭人
+ close_user_id = fields.Many2one('res.users', string=u'关闭人', default=lambda self: self.env.user)
+
+
+ def sure(self):
+ self.order_id.close_time = self.close_time
+ self.order_id.grade = self.grade
+ if self.order_id.state == 'processed':
+ state_remark = u'已处理待评分 --> 已完成'
+ # self.order_id.message_post(u'操作人:%s,操作时间:%s,状态变更过程:%s' % (
+ # self.env.user.name,
+ # (datetime.datetime.now() + datetime.timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S'), state_remark))
+ self.order_id.state = self.state
+ self.order_id.close_user_id = self.close_user_id
+ return {}
diff --git a/jikimo_system_order/wizard/order_technician_wizard.py b/jikimo_system_order/wizard/order_technician_wizard.py
new file mode 100644
index 00000000..78458038
--- /dev/null
+++ b/jikimo_system_order/wizard/order_technician_wizard.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+
+from odoo import models, fields, api
+from odoo.addons.jikimo_system_order.models.constant import STATE_SELECTION
+import datetime
+import logging
+
+
+class OrderTechnicianWizard(models.TransientModel):
+ _name = 'order.technician.wizard'
+
+ order_id = fields.Many2one('system.work.order', string=u'工单ID',
+ default=lambda self: self.env.context.get('active_id'))
+ # 解决人
+ solve_people_id = fields.Many2one('res.users', string=u'解决人', default=lambda self: self.env.user)
+ # 用户实际问题
+ users_problem = fields.Text(string=u'用户实际问题')
+ # 最终解决方案
+ solution = fields.Text(string=u'最终解决方案')
+ # 状态
+ state = fields.Selection(STATE_SELECTION, default='processed', string=u'状态')
+
+ def sure(self):
+ self.order_id.solve_people_id = self.solve_people_id
+ self.order_id.users_problem = self.users_problem
+ self.order_id.solution = self.solution
+ if self.order_id.state == 'pending':
+ state_remark = u'待处理 --> 已处理待评分'
+ # self.order_id.message_post(u'操作人:%s,操作时间:%s,状态变更过程:%s' % (
+ # self.env.user.name,
+ # (datetime.datetime.now() + datetime.timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S'), state_remark))
+ self.order_id.state = self.state
+ # 获取通知人
+ # objs = self.env['system.order.notice'].search([])
+ # user_ids = objs.notice_user_ids.filtered(lambda item: item.we_employee_id not in ['', False])
+ # we_employee_ids = user_ids.mapped('we_employee_id')
+ we_employee_ids = []
+ if self.order_id.initiator_id.we_employee_id:
+ we_employee_ids.append(self.order_id.initiator_id.we_employee_id)
+ print(we_employee_ids)
+ lost_agent_id = self.env['ir.config_parameter'].sudo().get_param('lost_agent_id')
+ wechat = self.env['we.config'].sudo().get_wechat(agent_id=lost_agent_id)
+ # agent_id, user_ids, content
+ content = """您提交的工单-**工单标题:{0}**-**已处理**
+ >提交时间:{1}
+ >处理反馈:{4}
+ >处理时间:{2}
+ >处理人:{3}
+ 如有问题,请联系系统管理员!
+ """.format(self.order_id.title,
+ (self.order_id.date + datetime.timedelta(hours=8)).strftime('%Y-%m-%d %H:%M'), (datetime.datetime.now() + datetime.timedelta(hours=8)).strftime('%Y-%m-%d %H:%M'), self.env.user.name or '', self.solution or '')
+ # wechat.message.send_markdown(agent_id=lost_agent_id, user_ids=we_employee_ids, content=content)
+ for we_employee_id in we_employee_ids:
+ try:
+ wechat.message.send_markdown(agent_id=lost_agent_id, user_ids=we_employee_id, content=content)
+ except Exception as e:
+ logging.error('工单处理发送消息异常%s' % str(e))
+
+ return {}
diff --git a/jikimo_system_order/wizard/order_wizard.xml b/jikimo_system_order/wizard/order_wizard.xml
new file mode 100644
index 00000000..64c13ccd
--- /dev/null
+++ b/jikimo_system_order/wizard/order_wizard.xml
@@ -0,0 +1,122 @@
+
+
+
+
+
+ 技术员向导
+ order.technician.wizard
+
+
+
+
+
+
+ 技术员编辑
+ ir.actions.act_window
+ order.technician.wizard
+ form
+
+ {'display_default_code':False}
+ new
+
+
+
+
+
+
+ 其它向导
+ order.other.wizard
+
+
+
+
+
+
+ 其它编辑
+ ir.actions.act_window
+ order.other.wizard
+ form
+
+ {'display_default_code':False}
+ new
+
+
+
+
+ 关闭向导
+ order.close.wizard
+
+
+
+
+
+
+ 关闭工单
+ ir.actions.act_window
+ order.close.wizard
+ form
+
+ {'display_default_code':False}
+ new
+
+
+
+ system_work_order_wizard_view
+ system.work.order.wizard
+
+
+
+
+
+
+ 二次确认
+ ir.actions.act_window
+ system.work.order.wizard
+ form
+ new
+
+
+
diff --git a/jikimo_system_order/wizard/system_work_order_wizard.py b/jikimo_system_order/wizard/system_work_order_wizard.py
new file mode 100644
index 00000000..8c8f95dc
--- /dev/null
+++ b/jikimo_system_order/wizard/system_work_order_wizard.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# @Time : 2017/12/12 9:46
+# @Author : GuoXiang
+# @Site :
+# @File : system_work_order_wizard.py
+# @Software: PyCharm
+# @Desc :
+# @license : Copyright©2018 www.dasmaster.com All Rights Reserved.
+# @Contact : xg1230205321@163.com
+from odoo import models, api, fields
+from odoo.exceptions import ValidationError
+
+
+class SystemWorkOrderWizard(models.TransientModel):
+ _name = "system.work.order.wizard"
+ _description = u"追回确认"
+
+
+ def _get_explain(self):
+ if self._context.get('object_id'):
+ obj = self.env['system.work.order'].browse(self._context.get('object_id'))
+ if obj.initiator_id.id != self.env.user.id:
+ raise ValidationError(u'非本人无法操作')
+ if self._context.get('explain'):
+ return self._context["explain"]
+
+ explain = fields.Char(default=_get_explain)
+
+
+ def sure(self):
+ """
+ 确认
+ :return:
+ """
+ if self._context.get('object_id') and self._context.get('object_name') and self._context.get(
+ 'explain') and self._context.get('function_name'):
+ work_sheet_obj = self.env[self._context["object_name"]].search([('id', '=', int(self._context["object_id"]))])
+ class_name = self._context.get('object_name') # 获得对象类名
+ method_name = self._context.get('function_name') # 获得对象的方法
+ obj_function = getattr(self.env[class_name], method_name)
+ obj_function(work_sheet_obj)
From 7533d23d3e207101dc9d1e42d99b570bd1dd0894 Mon Sep 17 00:00:00 2001
From: "jinling.yang"
Date: Tue, 9 Jul 2024 17:36:47 +0800
Subject: [PATCH 22/74] =?UTF-8?q?1.=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E2=80=98=E8=BF=94=E5=B7=A5=E2=80=99=EF=BC=8C?=
=?UTF-8?q?2=EF=BC=8C=E5=9C=A8=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E4=B8=8A=E7=82=B9=E5=87=BB=E8=BF=94=E5=B7=A5=E9=80=89=E6=8B=A9?=
=?UTF-8?q?=E5=8A=A0=E5=B7=A5=E9=9D=A2=E7=A1=AE=E8=AE=A4=E5=90=8E=EF=BC=8C?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=E5=B7=A5=E9=9D=A2=E7=9A=84=E5=AF=B9?=
=?UTF-8?q?=E5=BA=94=E5=B7=A5=E5=8D=95=E5=8F=8A=E6=96=B0=E5=A2=9E=E9=87=8D?=
=?UTF-8?q?=E7=BD=AEcloud=E7=9A=84=E7=BC=96=E7=A8=8B=E5=8D=95=E7=9A=84?=
=?UTF-8?q?=E7=8A=B6=E6=80=813.=E4=BC=98=E5=8C=96=E8=BF=94=E5=B7=A5?=
=?UTF-8?q?=E5=90=91=E5=AF=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sf_manufacturing/models/mrp_production.py | 24 ++---
sf_manufacturing/models/mrp_workorder.py | 96 ++++++++++---------
sf_manufacturing/views/mrp_workorder_view.xml | 2 +-
sf_manufacturing/wizard/rework_wizard.py | 40 ++++++--
.../wizard/rework_wizard_views.xml | 12 ++-
5 files changed, 100 insertions(+), 74 deletions(-)
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index cf9708f9..7ac20df1 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -103,7 +103,8 @@ class MrpProduction(models.Model):
precision_rounding=production.product_uom_id.rounding) >= 0:
production.state = 'to_close'
elif any(
- wo.test_results == '返工' and wo.state == 'done' for wo in production.workorder_ids):
+ (wo.test_results == '返工' and wo.state == 'done') or wo.state == 'rework' for wo in
+ production.workorder_ids):
production.state = 'rework'
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'progress'
@@ -155,27 +156,25 @@ class MrpProduction(models.Model):
for production in self:
production.maintenance_count = len(production.request_ids)
- # 制造订单报废:编程单更新
- def updateCNC(self):
+ # 编程单更新
+ def update_programming_state(self):
try:
- res = {'production_no': self.name, 'programming_no': self.programming_no,
- 'order_no': self.origin}
+ res = {'programming_no': self.programming_no}
logging.info('res=%s:' % res)
configsettings = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
- url = '/api/intelligent_programming/update_intelligent_programmings'
+ url = '/api/intelligent_programming/reset_state_again'
config_url = configsettings['sf_url'] + url
- res['token'] = configsettings['token']
ret = requests.post(config_url, json={}, data=res, headers=config_header)
ret = ret.json()
- logging.info('updateCNC-ret:%s' % ret)
+ logging.info('update_programming_state-ret:%s' % ret)
if ret['status'] == 1:
self.write({'work_state': '已编程'})
else:
raise UserError(ret['message'])
except Exception as e:
- logging.info('updateCNC error:%s' % e)
- raise UserError("更新程单失败,请联系管理员")
+ logging.info('update_programming_state error:%s' % e)
+ raise UserError("更新编程单状态失败,请联系管理员")
# cnc程序获取
def fetchCNC(self, production_names):
@@ -698,8 +697,9 @@ class MrpProduction(models.Model):
'res_model': 'sf.rework.wizard',
'target': 'new',
'context': {
- 'default_production_id': [(6, 0, [self.id])],
- 'default_product_id': self.product_id.id
+ 'default_production_id': self.id,
+ 'default_product_id': self.product_id.id,
+ 'default_is_reprogramming': True
}
}
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 9182926d..731650af 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -47,7 +47,7 @@ class ResMrpWorkOrder(models.Model):
('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型")
results = fields.Char('结果')
- state = fields.Selection(selection_add=[('to be detected', "待检测")])
+ state = fields.Selection(selection_add=[('to be detected', "待检测"), ('rework', '返工')])
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
@@ -820,26 +820,26 @@ class ResMrpWorkOrder(models.Model):
# @api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state')
# def _compute_state(self):
- # super(ResMrpWorkOrder, self)._compute_state()
- # for item in self:
- # print(item.name)
- # print(item.state)
- # print(item.is_remanufacture)
- # scrap_workorder = self.env['mrp.workorder'].search(
- # [('production_id', '=', item.production_id.id), ('routing_type', '=', 'CNC加工'),
- # ('state', '=', 'done'), ('test_results', 'in', ['返工', '报废'])])
- # print(scrap_workorder)
- # # if item.routing_type == 'CNC加工' and item.state in ['done'] and item.test_results in ['返工', '报废']:
- # if item.routing_type == '解除装夹':
- # if scrap_workorder and item.state not in ['cancel']:
- # item.state = 'cancel'
- # elif item.routing_type == '表面工艺':
- # if scrap_workorder:
- # stock_move = self.env['stock.move'].search(
- # [('origin', '=', item.production_id.name)])
- # stock_move.write({'state': 'cancel'})
- # item.picking_ids.write({'state': 'cancel'})
- # item.state = 'cancel'
+ # for workorder in self:
+ # if any(
+ # (wo.test_results == '返工' and wo.state == 'done') or wo.state == 'rework' for wo in
+ # production.workorder_ids):
+ # production.state = 'rework'
+ # if workorder.state == 'pending':
+ # if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
+ # workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
+ # continue
+ # if workorder.state not in ('waiting', 'ready'):
+ # continue
+ # if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
+ # workorder.state = 'pending'
+ # continue
+ # if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
+ # continue
+ # if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
+ # workorder.state = 'ready'
+ # elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
+ # workorder.state = 'waiting'
# 重写工单开始按钮方法
def button_start(self):
@@ -1175,24 +1175,25 @@ class CNCprocessing(models.Model):
def _json_cnc_processing(self, panel, ret):
cnc_processing = []
- for item in ret['programming_list']:
- if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') == -1:
- cnc_processing.append((0, 0, {
- 'sequence_number': item['sequence_number'],
- 'program_name': item['program_name'],
- 'cutting_tool_name': item['cutting_tool_name'],
- 'cutting_tool_no': item['cutting_tool_no'],
- 'processing_type': item['processing_type'],
- 'margin_x_y': item['margin_x_y'],
- 'margin_z': item['margin_z'],
- 'depth_of_processing_z': item['depth_of_processing_z'],
- 'cutting_tool_extension_length': item['cutting_tool_extension_length'],
- 'cutting_tool_handle_type': item['cutting_tool_handle_type'],
- 'estimated_processing_time': item['estimated_processing_time'],
- 'program_path': item['ftp_path'],
- 'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'),
- 'remark': item['remark']
- }))
+ if ret is not False:
+ for item in ret['programming_list']:
+ if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') == -1:
+ cnc_processing.append((0, 0, {
+ 'sequence_number': item['sequence_number'],
+ 'program_name': item['program_name'],
+ 'cutting_tool_name': item['cutting_tool_name'],
+ 'cutting_tool_no': item['cutting_tool_no'],
+ 'processing_type': item['processing_type'],
+ 'margin_x_y': item['margin_x_y'],
+ 'margin_z': item['margin_z'],
+ 'depth_of_processing_z': item['depth_of_processing_z'],
+ 'cutting_tool_extension_length': item['cutting_tool_extension_length'],
+ 'cutting_tool_handle_type': item['cutting_tool_handle_type'],
+ 'estimated_processing_time': item['estimated_processing_time'],
+ 'program_path': item['ftp_path'],
+ '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进行匹配
@@ -1648,12 +1649,13 @@ class CMMprogram(models.Model):
def _json_cmm_program(self, panel, ret):
cmm_program = []
- for item in ret['programming_list']:
- if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') != -1:
- cmm_program.append((0, 0, {
- 'sequence_number': 1,
- 'program_name': item['program_name'],
- 'program_path': item['ftp_path'],
- 'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'),
- }))
+ if ret is not False:
+ for item in ret['programming_list']:
+ if item['processing_panel'] == panel and item['ftp_path'].find('.dmi') != -1:
+ cmm_program.append((0, 0, {
+ 'sequence_number': 1,
+ 'program_name': item['program_name'],
+ 'program_path': item['ftp_path'],
+ 'program_create_date': datetime.strptime(item['program_create_date'], '%Y-%m-%d %H:%M:%S'),
+ }))
return cmm_program
diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml
index 42aa5891..a946eb0a 100644
--- a/sf_manufacturing/views/mrp_workorder_view.xml
+++ b/sf_manufacturing/views/mrp_workorder_view.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py
index 38637482..ee323680 100644
--- a/sf_manufacturing/wizard/rework_wizard.py
+++ b/sf_manufacturing/wizard/rework_wizard.py
@@ -12,7 +12,7 @@ class ReworkWizard(models.TransientModel):
workorder_id = fields.Many2one('mrp.workorder', string='工单')
product_id = fields.Many2one('product.product')
- production_ids = fields.Many2many('mrp.production', string='制造订单号')
+ production_id = fields.Many2one('mrp.production', string='制造订单号')
rework_reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
("operate computer", "操机"),
@@ -23,17 +23,38 @@ class ReworkWizard(models.TransientModel):
('CNC加工', 'CNC加工')], string="工序类型")
# 根据工单的加工面来显示
processing_panel_id = fields.Many2one('sf.processing.panel', string="加工面")
+ is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
def confirm(self):
- if len(self.production_ids) == 1:
+ if self.is_reprogramming is True:
+ if self.production_id.workorder_ids:
+ panel_workorder = self.production_id.workorder_ids.filtered(
+ lambda ap: ap.processing_panel == self.processing_panel_id.name)
+ if panel_workorder:
+ panel_workorder.write({'state': 'rework'})
+ product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
+ [('product_model_type_id', '=', self.production_id.product_id.product_model_type_id.id)],
+ order='sequence asc'
+ )
+ workorders_values = []
+ for route in product_routing_workcenter:
+ if route.is_repeat is True:
+ workorders_values.append(
+ self.env['mrp.workorder'].json_workorder_str(self.processing_panel_id.name,
+ self.production_id, route, False))
+ if workorders_values:
+ self.production_id.write({'workorder_ids': workorders_values, 'programming_state': '编程中'})
+ self.production_id._reset_work_order_sequence()
+ self.production_id.update_programming_state()
+ else:
self.workorder_id.is_rework = True
- self.production_ids.write({'detection_result_ids': [(0, 0, {
- 'rework_reason': self.rework_reason,
- 'detailed_reason': self.detailed_reason,
- # 'processing_panel': self.workorder_id.processing_panel,
- 'routing_type': self.workorder_id.routing_type,
- 'test_results': self.workorder_id.test_results,
- 'test_report': self.workorder_id.detection_report})]})
+ self.production_id.write({'detection_result_ids': [(0, 0, {
+ 'rework_reason': self.rework_reason,
+ 'detailed_reason': self.detailed_reason,
+ # 'processing_panel': self.workorder_id.processing_panel,
+ 'routing_type': self.workorder_id.routing_type,
+ 'test_results': self.workorder_id.test_results,
+ 'test_report': self.workorder_id.detection_report})]})
@api.onchange('product_id')
def onchange_processing_panel_id(self):
@@ -50,4 +71,3 @@ class ReworkWizard(models.TransientModel):
panel_ids.append(panel.id)
domain = {'processing_panel_id': [('id', 'in', panel_ids)]}
return {'domain': domain}
-
diff --git a/sf_manufacturing/wizard/rework_wizard_views.xml b/sf_manufacturing/wizard/rework_wizard_views.xml
index 975004d3..d08ab1ba 100644
--- a/sf_manufacturing/wizard/rework_wizard_views.xml
+++ b/sf_manufacturing/wizard/rework_wizard_views.xml
@@ -6,13 +6,17 @@