Accept Merge Request #1165: (feature/修复返工向导 -> develop)
Merge Request: 修复返工向导 Created By: @杨金灵 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @杨金灵 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1165
This commit is contained in:
@@ -803,7 +803,7 @@ class MrpProduction(models.Model):
|
|||||||
'default_production_id': self.id,
|
'default_production_id': self.id,
|
||||||
'default_reprogramming_num': cloud_programming['reprogramming_num'],
|
'default_reprogramming_num': cloud_programming['reprogramming_num'],
|
||||||
'default_programming_state': cloud_programming['programming_state'],
|
'default_programming_state': cloud_programming['programming_state'],
|
||||||
'default_is_reprogramming': False if cloud_programming['programming_state'] not in ['已下发'] else True
|
'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from dateutil.relativedelta import relativedelta
|
|||||||
# import subprocess
|
# import subprocess
|
||||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from odoo.exceptions import UserError,ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
|
from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController
|
||||||
|
|
||||||
|
|
||||||
@@ -801,6 +801,13 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'cancel']:
|
'cancel']:
|
||||||
if re_work and workorder.production_id.is_rework is False:
|
if re_work and workorder.production_id.is_rework is False:
|
||||||
workorder.state = 'ready'
|
workorder.state = 'ready'
|
||||||
|
if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
|
||||||
|
unclamp_workorder = self.env['mrp.workorder'].search(
|
||||||
|
[('production_id', '=', workorder.production_id.id),
|
||||||
|
('sequence', '=', workorder.sequence - 1),
|
||||||
|
('state', 'in', ['done'])])
|
||||||
|
if unclamp_workorder:
|
||||||
|
workorder.state = 'ready'
|
||||||
# else:
|
# else:
|
||||||
# if workorder.state not in ['cancel', 'rework']:
|
# if workorder.state not in ['cancel', 'rework']:
|
||||||
# workorder.state = 'rework'
|
# workorder.state = 'rework'
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ReworkWizard(models.TransientModel):
|
|||||||
# 根据工单的加工面来显示
|
# 根据工单的加工面来显示
|
||||||
processing_panel_id = fields.Many2many('sf.processing.panel', string="加工面")
|
processing_panel_id = fields.Many2many('sf.processing.panel', string="加工面")
|
||||||
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
|
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
|
||||||
|
is_reprogramming_readonly = fields.Boolean(string='申请重新编程(只读)', default=False)
|
||||||
reprogramming_num = fields.Integer('重新编程次数', default=0)
|
reprogramming_num = fields.Integer('重新编程次数', default=0)
|
||||||
programming_state = fields.Selection(
|
programming_state = fields.Selection(
|
||||||
[('待编程', '待编程'), ('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发'),
|
[('待编程', '待编程'), ('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发'),
|
||||||
@@ -85,35 +86,36 @@ class ReworkWizard(models.TransientModel):
|
|||||||
lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write(
|
lambda ap1: ap1.processing_panel == panel.name and ap1.handle_result == '待处理').write(
|
||||||
{'handle_result': '已处理'})
|
{'handle_result': '已处理'})
|
||||||
if self.is_reprogramming is False:
|
if self.is_reprogramming is False:
|
||||||
if self.reprogramming_num >= 1:
|
if self.programming_state in ['已编程', '已下发']:
|
||||||
self.production_id.get_new_program(panel.name)
|
if self.reprogramming_num >= 1 and self.programming_state == '已编程':
|
||||||
else:
|
self.production_id.get_new_program(panel.name)
|
||||||
ret = {'programming_list': []}
|
if self.reprogramming_num >= 0 and self.programming_state == '已下发':
|
||||||
cnc_rework = self.production_id.workorder_ids.filtered(
|
ret = {'programming_list': []}
|
||||||
lambda crw: crw.processing_panel == panel.name and crw.state in (
|
cnc_rework = self.production_id.workorder_ids.filtered(
|
||||||
'rework') and crw.routing_type == 'CNC加工')
|
lambda crw: crw.processing_panel == panel.name and crw.state in (
|
||||||
if cnc_rework.cnc_ids:
|
'rework') and crw.routing_type == 'CNC加工')
|
||||||
for item_line in cnc_rework.cnc_ids:
|
if cnc_rework.cnc_ids:
|
||||||
vals = {
|
for item_line in cnc_rework.cnc_ids:
|
||||||
'sequence_number': item_line.sequence_number,
|
vals = {
|
||||||
'program_name': item_line.program_name,
|
'sequence_number': item_line.sequence_number,
|
||||||
'cutting_tool_name': item_line.cutting_tool_name,
|
'program_name': item_line.program_name,
|
||||||
'cutting_tool_no': item_line.cutting_tool_no,
|
'cutting_tool_name': item_line.cutting_tool_name,
|
||||||
'processing_type': item_line.processing_type,
|
'cutting_tool_no': item_line.cutting_tool_no,
|
||||||
'margin_x_y': item_line.margin_x_y,
|
'processing_type': item_line.processing_type,
|
||||||
'margin_z': item_line.margin_z,
|
'margin_x_y': item_line.margin_x_y,
|
||||||
'depth_of_processing_z': item_line.depth_of_processing_z,
|
'margin_z': item_line.margin_z,
|
||||||
'cutting_tool_extension_length': item_line.cutting_tool_extension_length,
|
'depth_of_processing_z': item_line.depth_of_processing_z,
|
||||||
'estimated_processing_time': item_line.estimated_processing_time,
|
'cutting_tool_extension_length': item_line.cutting_tool_extension_length,
|
||||||
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
'estimated_processing_time': item_line.estimated_processing_time,
|
||||||
'program_path': item_line.program_path,
|
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
||||||
'ftp_path': item_line.program_path,
|
'program_path': item_line.program_path,
|
||||||
'processing_panel': panel.name,
|
'ftp_path': item_line.program_path,
|
||||||
'program_create_date': datetime.strftime(item_line.program_create_date,
|
'processing_panel': panel.name,
|
||||||
'%Y-%m-%d %H:%M:%S'),
|
'program_create_date': datetime.strftime(item_line.program_create_date,
|
||||||
'remark': item_line.remark
|
'%Y-%m-%d %H:%M:%S'),
|
||||||
}
|
'remark': item_line.remark
|
||||||
ret['programming_list'].append(vals)
|
}
|
||||||
|
ret['programming_list'].append(vals)
|
||||||
for cmm_line in cnc_rework.cmm_ids:
|
for cmm_line in cnc_rework.cmm_ids:
|
||||||
vals = {
|
vals = {
|
||||||
'sequence_number': cmm_line.sequence_number,
|
'sequence_number': cmm_line.sequence_number,
|
||||||
@@ -121,35 +123,40 @@ class ReworkWizard(models.TransientModel):
|
|||||||
'program_path': cmm_line.program_path,
|
'program_path': cmm_line.program_path,
|
||||||
'ftp_path': item_line.program_path,
|
'ftp_path': item_line.program_path,
|
||||||
'processing_panel': panel.name,
|
'processing_panel': panel.name,
|
||||||
'program_create_date': datetime.strftime(cmm_line.program_create_date,
|
'program_create_date': datetime.strftime(
|
||||||
'%Y-%m-%d %H:%M:%S')
|
cmm_line.program_create_date,
|
||||||
|
'%Y-%m-%d %H:%M:%S')
|
||||||
}
|
}
|
||||||
ret['programming_list'].append(vals)
|
ret['programming_list'].append(vals)
|
||||||
new_cnc_workorder = self.production_id.workorder_ids.filtered(
|
new_cnc_workorder = self.production_id.workorder_ids.filtered(
|
||||||
lambda ap1: ap1.processing_panel == panel.name and ap1.state not in (
|
lambda ap1: ap1.processing_panel == panel.name and ap1.state not in (
|
||||||
'rework', 'done') and ap1.routing_type == 'CNC加工')
|
'rework', 'done') and ap1.routing_type == 'CNC加工')
|
||||||
if not new_cnc_workorder.cnc_ids:
|
if not new_cnc_workorder.cnc_ids:
|
||||||
new_cnc_workorder.write({
|
new_cnc_workorder.write({
|
||||||
'cnc_ids': new_cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel.name,
|
'cnc_ids': new_cnc_workorder.cnc_ids.sudo()._json_cnc_processing(panel.name,
|
||||||
ret),
|
ret),
|
||||||
'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name, ret),
|
'cmm_ids': new_cnc_workorder.cmm_ids.sudo()._json_cmm_program(panel.name,
|
||||||
'cnc_worksheet': new_cnc_workorder.cnc_worksheet})
|
ret),
|
||||||
new_pre_workorder = self.production_id.workorder_ids.filtered(lambda
|
'cnc_worksheet': new_cnc_workorder.cnc_worksheet})
|
||||||
p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in (
|
new_pre_workorder = self.production_id.workorder_ids.filtered(lambda
|
||||||
'rework', 'done'))
|
p: p.routing_type == '装夹预调' and p.processing_panel == panel.name and p.state not in (
|
||||||
if new_pre_workorder:
|
'rework', 'done'))
|
||||||
pre_rework = self.production_id.workorder_ids.filtered(
|
if new_pre_workorder:
|
||||||
lambda pr: pr.processing_panel == panel.name and pr.state in (
|
pre_rework = self.production_id.workorder_ids.filtered(
|
||||||
'rework') and pr.routing_type == '装夹预调')
|
lambda pr: pr.processing_panel == panel.name and pr.state in (
|
||||||
new_pre_workorder.write(
|
'rework') and pr.routing_type == '装夹预调')
|
||||||
{'processing_drawing': pre_rework.processing_drawing})
|
new_pre_workorder.write(
|
||||||
self.production_id.write({'state': 'progress', 'is_rework': False})
|
{'processing_drawing': pre_rework.processing_drawing})
|
||||||
|
self.production_id.write({'state': 'progress', 'is_rework': False})
|
||||||
|
elif self.programming_state in ['待编程', '编程中']:
|
||||||
|
self.production_id.write(
|
||||||
|
{'programming_state': '编程中', 'work_state': '编程中', 'is_rework': True})
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
self.production_id.update_programming_state()
|
self.production_id.update_programming_state()
|
||||||
self.production_id.write(
|
self.production_id.write(
|
||||||
{'programming_state': '编程中', 'work_state': '编程中'})
|
{'programming_state': '编程中', 'work_state': '编程中'})
|
||||||
if self.production_id.state == 'progress':
|
if self.production_id.state == 'progress':
|
||||||
self.production_id.write({'programming_state': '已编程', 'work_state': '编程中'})
|
self.production_id.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
|
|
||||||
@api.onchange('production_id')
|
@api.onchange('production_id')
|
||||||
def onchange_processing_panel_id(self):
|
def onchange_processing_panel_id(self):
|
||||||
|
|||||||
@@ -25,8 +25,10 @@
|
|||||||
decoration-danger="programming_state =='已编程'" readonly="1"/>
|
decoration-danger="programming_state =='已编程'" readonly="1"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<field name="is_reprogramming"
|
<field name="is_reprogramming" force_save="1"
|
||||||
attrs='{"invisible": [("routing_type","in",["装夹预调","CNC加工"])],"readonly": [("is_reprogramming","=",False)]}'/>
|
attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","not in",["已下发"])]}'/>
|
||||||
|
<field name="is_reprogramming_readonly" string="申请重新编程"
|
||||||
|
attrs='{"invisible": ["|",("routing_type","in",["装夹预调","CNC加工"]),("programming_state","in",["已下发"])],"readonly": [("is_reprogramming_readonly","=",False)]}'/>
|
||||||
<field name="rework_reason"
|
<field name="rework_reason"
|
||||||
attrs='{"invisible": [("routing_type","not in",["装夹预调","CNC加工"])],"required": [("routing_type","in",["装夹预调"])]}'/>
|
attrs='{"invisible": [("routing_type","not in",["装夹预调","CNC加工"])],"required": [("routing_type","in",["装夹预调"])]}'/>
|
||||||
<field name="detailed_reason"
|
<field name="detailed_reason"
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ class ReSaleOrder(models.Model):
|
|||||||
store=True, readonly=False, precompute=True, check_company=True, tracking=True,
|
store=True, readonly=False, precompute=True, check_company=True, tracking=True,
|
||||||
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
|
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
|
||||||
remark = fields.Text('备注')
|
remark = fields.Text('备注')
|
||||||
translated_display_name = fields.Char('交货人电话号码')
|
|
||||||
validity_date = fields.Date(
|
validity_date = fields.Date(
|
||||||
string="Expiration",
|
string="Expiration",
|
||||||
compute='_compute_validity_date',
|
compute='_compute_validity_date',
|
||||||
|
|||||||
Reference in New Issue
Block a user