1.新增加工面模型2.制造订单详情页面的返工操作上的加工面根据产品的加工面板进行过滤
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
'data': [
|
||||
'data/stock_data.xml',
|
||||
'data/empty_racks_data.xml',
|
||||
'data/panel_data.xml',
|
||||
'security/group_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/workpiece_delivery_views.xml',
|
||||
|
||||
24
sf_manufacturing/data/panel_data.xml
Normal file
24
sf_manufacturing/data/panel_data.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="panel_zm" model="sf.processing.panel">
|
||||
<field name="name">ZM</field>
|
||||
</record>
|
||||
|
||||
<record id="panel_fm" model="sf.processing.panel">
|
||||
<field name="name">FM</field>
|
||||
</record>
|
||||
<record id="panel_yc" model="sf.processing.panel">
|
||||
<field name="name">YC</field>
|
||||
</record>
|
||||
<record id="panel_zc" model="sf.processing.panel">
|
||||
<field name="name">ZC</field>
|
||||
</record>
|
||||
<record id="panel_qc" model="sf.processing.panel">
|
||||
<field name="name">QC</field>
|
||||
</record>
|
||||
<record id="panel_hc" model="sf.processing.panel">
|
||||
<field name="name">HC</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -691,7 +691,17 @@ class MrpProduction(models.Model):
|
||||
|
||||
# 返工
|
||||
def button_rework(self):
|
||||
return True
|
||||
return {
|
||||
'name': _('返工'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.rework.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_production_id': [(6, 0, [self.id])],
|
||||
'default_product_id': self.product_id.id
|
||||
}
|
||||
}
|
||||
|
||||
# 报废
|
||||
def button_scrap_new(self):
|
||||
@@ -733,3 +743,26 @@ class sf_detection_result(models.Model):
|
||||
# },
|
||||
'target': 'new'
|
||||
}
|
||||
|
||||
|
||||
class sf_processing_panel(models.Model):
|
||||
_name = 'sf.processing.panel'
|
||||
_description = "加工面"
|
||||
|
||||
name = fields.Char('加工面')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.model
|
||||
# def name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||
# if self.env.user.has_group('sf_base.group_sf_order_user'):
|
||||
# if self._context.get('product_id'):
|
||||
# product = self.env['product.product'].search([('id', '=', self._context.get('product_id'))])
|
||||
# if product:
|
||||
# panel = self.env['sf.processing.panel'].search([('name', 'ilike', 'ZM')])
|
||||
# if panel:
|
||||
# ids = [t.id for t in panel]
|
||||
# domain = [('id', 'in', ids)]
|
||||
# else:
|
||||
# domain = [('id', '=', False)]
|
||||
# return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||
# return super()._name_search(name, args, operator, limit, name_get_uid)
|
||||
|
||||
@@ -143,4 +143,6 @@ access_mrp_bom_byproduct_group_sf_stock_manager,mrp_bom_byproduct_group_sf_mrp_m
|
||||
|
||||
access_sf_rework_wizard_group_sf_order_user,sf_rework_wizard_group_sf_order_user,model_sf_rework_wizard,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_sf_detection_result_group_sf_order_user,sf_detection_result_group_sf_order_user,model_sf_detection_result,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_sf_processing_panel_group_sf_order_user,sf_processing_panel_group_sf_order_user,model_sf_processing_panel,sf_base.group_sf_order_user,1,1,1,0
|
||||
|
||||
|
||||
|
||||
|
@@ -184,7 +184,7 @@
|
||||
<xpath expr="//label[1]" position="before">
|
||||
<field name='routing_type' readonly="1"/>
|
||||
<field name='process_state' attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||
<field name="rfid_code" cache="True"
|
||||
<field name="rfid_code" cache="True"
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||
</xpath>
|
||||
@@ -217,11 +217,11 @@
|
||||
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
||||
<field name="processing_panel" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||
<field name="equipment_id"
|
||||
<field name="equipment_id" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||
<field name="production_line_id"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||
<field name="production_line_state"
|
||||
<field name="production_line_state" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||
<!-- <field name="functional_fixture_id" -->
|
||||
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> -->
|
||||
|
||||
@@ -11,6 +11,7 @@ class ReworkWizard(models.TransientModel):
|
||||
_description = '返工向导'
|
||||
|
||||
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||
product_id = fields.Many2one('product.product')
|
||||
production_ids = fields.Many2many('mrp.production', string='制造订单号')
|
||||
rework_reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
|
||||
@@ -20,13 +21,33 @@ class ReworkWizard(models.TransientModel):
|
||||
routing_type = fields.Selection([
|
||||
('装夹预调', '装夹预调'),
|
||||
('CNC加工', 'CNC加工')], string="工序类型")
|
||||
# 根据工单的加工面来显示
|
||||
processing_panel_id = fields.Many2one('sf.processing.panel', string="加工面")
|
||||
|
||||
def confirm(self):
|
||||
self.workorder_id.is_rework = True
|
||||
if len(self.production_ids) == 1:
|
||||
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,
|
||||
# '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):
|
||||
for item in self:
|
||||
domain = [('id', '=', False)]
|
||||
product_id = item.product_id
|
||||
if product_id:
|
||||
if self.env.user.has_group('sf_base.group_sf_order_user'):
|
||||
panel_ids = []
|
||||
for p in product_id.model_processing_panel.split(','):
|
||||
panel = self.env['sf.processing.panel'].search(
|
||||
[('name', 'ilike', p)])
|
||||
if panel:
|
||||
panel_ids.append(panel.id)
|
||||
domain = {'processing_panel_id': [('id', 'in', panel_ids)]}
|
||||
return {'domain': domain}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
<sheet>
|
||||
<field name="production_ids" invisible="True"/>
|
||||
<field name="workorder_id" invisible="True"/>
|
||||
<field name="product_id" invisible="True"/>
|
||||
<group>
|
||||
<field name="processing_panel_id" options="{'no_create': True}" />
|
||||
<field name="rework_reason" required="1"/>
|
||||
<field name="detailed_reason" required="1"/>
|
||||
</group>
|
||||
|
||||
@@ -29,21 +29,21 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
[('programming_no', '=', ret['programming_no'])])
|
||||
if productions:
|
||||
# # 拉取所有加工面的程序文件
|
||||
for r in ret['processing_panel'].split(','):
|
||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
if os.path.exists(program_path_tmp_r):
|
||||
files_r = os.listdir(program_path_tmp_r)
|
||||
if files_r:
|
||||
for file_name in files_r:
|
||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
os.remove(file_path)
|
||||
download_state = request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).download_file_tmp(
|
||||
ret['folder_name'], r)
|
||||
if download_state is False:
|
||||
res['status'] = -2
|
||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
return json.JSONEncoder().encode(res)
|
||||
# for r in ret['processing_panel'].split(','):
|
||||
# program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
# if os.path.exists(program_path_tmp_r):
|
||||
# files_r = os.listdir(program_path_tmp_r)
|
||||
# if files_r:
|
||||
# for file_name in files_r:
|
||||
# file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
# os.remove(file_path)
|
||||
# download_state = request.env['sf.cnc.processing'].with_user(
|
||||
# request.env.ref("base.user_admin")).download_file_tmp(
|
||||
# ret['folder_name'], r)
|
||||
# if download_state is False:
|
||||
# res['status'] = -2
|
||||
# res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
# return json.JSONEncoder().encode(res)
|
||||
for production in productions:
|
||||
if not production.workorder_ids:
|
||||
production.product_id.model_processing_panel = ret['processing_panel']
|
||||
@@ -82,31 +82,31 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
# if pre_workorder:
|
||||
# pre_workorder.write(
|
||||
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
for panel in ret['processing_panel'].split(','):
|
||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||
cnc_workorder = productions.workorder_ids.filtered(
|
||||
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
|
||||
'cancel'] and ac.processing_panel == panel)
|
||||
if cnc_workorder:
|
||||
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||
# panel)
|
||||
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
||||
files_panel = os.listdir(program_path_tmp_panel)
|
||||
if files_panel:
|
||||
for file in files_panel:
|
||||
file_extension = os.path.splitext(file)[1]
|
||||
logging.info('file_extension:%s' % file_extension)
|
||||
if file_extension.lower() == '.pdf':
|
||||
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||
logging.info('panel_file_path:%s' % panel_file_path)
|
||||
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
pre_workorder = productions.workorder_ids.filtered(
|
||||
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done',
|
||||
'cancel'] and ap.processing_panel == panel)
|
||||
if pre_workorder:
|
||||
pre_workorder.write(
|
||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
# for panel in ret['processing_panel'].split(','):
|
||||
# # 查询状态为进行中且工序类型为CNC加工的工单
|
||||
# cnc_workorder = productions.workorder_ids.filtered(
|
||||
# lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done',
|
||||
# 'cancel'] and ac.processing_panel == panel)
|
||||
# if cnc_workorder:
|
||||
# # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||
# # panel)
|
||||
# program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||
# logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
||||
# files_panel = os.listdir(program_path_tmp_panel)
|
||||
# if files_panel:
|
||||
# for file in files_panel:
|
||||
# file_extension = os.path.splitext(file)[1]
|
||||
# logging.info('file_extension:%s' % file_extension)
|
||||
# if file_extension.lower() == '.pdf':
|
||||
# panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||
# logging.info('panel_file_path:%s' % panel_file_path)
|
||||
# cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
# pre_workorder = productions.workorder_ids.filtered(
|
||||
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done',
|
||||
# 'cancel'] and ap.processing_panel == panel)
|
||||
# if pre_workorder:
|
||||
# pre_workorder.write(
|
||||
# {'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(
|
||||
|
||||
Reference in New Issue
Block a user