去掉注释代码

This commit is contained in:
jinling.yang
2024-07-16 17:24:15 +08:00
parent a0bd214118
commit c536dde2cc
10 changed files with 62 additions and 47 deletions

View File

@@ -8,7 +8,6 @@ _logger = logging.getLogger(__name__)
class ResBFMConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
lost_agent_id = fields.Char('22')
bfm_url = fields.Selection(
[("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"),
("https://bfm.t.jikimo.com", "测试环境(https://bfm.t.jikimo.com)"),

View File

@@ -129,13 +129,16 @@ class MrpProduction(models.Model):
if production.state == 'progress':
if all(wo_state not in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'pending_cam'
if production.state == 'pending_cam':
if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
production.state = 'done'
# if production.state == 'pending_cam':
# if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')):
# production.state = 'done'
if any(
(
wo.test_results == '返工' and wo.state == 'done' and programming_state == '编程') or wo.state == 'rework' or (
wo.is_rework is True and wo.state == 'done') for wo in
wo.test_results == '返工' and wo.state == 'done' and production.programming_state == '编程') or (
wo.state == 'rework' and production.programming_state == '编程中') or (
wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中',
'已编程'])
for wo in
production.workorder_ids):
production.state = 'rework'
@@ -198,8 +201,8 @@ class MrpProduction(models.Model):
production.write({'programming_state': '已编程未下发' if item[
'programming_state'] == '已编程' else '编程中'})
else:
self.write({'programming_state': '已编程未下发' if item[
'programming_state'] == '已编程' else '编程中'})
return item['programming_state']
else:
raise UserError(ret['message'])
except Exception as e:
@@ -760,8 +763,11 @@ class MrpProduction(models.Model):
# 返工
def button_rework(self):
if self.programming_state != '已编程':
self._cron_get_programming_state()
cloud_programming_state = None
if self.programming_state != '已编程' and self.reprogramming_num >= 1:
cloud_programming_state = self._cron_get_programming_state()
logging.info('cloud_programming_state:%s' % cloud_programming_state)
logging.info('programming_state:%s' % self.programming_state)
return {
'name': _('返工'),
'type': 'ir.actions.act_window',
@@ -771,8 +777,12 @@ class MrpProduction(models.Model):
'context': {
'default_production_id': self.id,
'default_product_id': self.product_id.id,
'default_programming_state': self.programming_state,
'default_is_reprogramming': True if self.programming_state in ['编程'] else False
'default_programming_state': self.programming_state if cloud_programming_state is not None else cloud_programming_state,
'default_is_reprogramming': False if (cloud_programming_state in ['编程',
'待编程'] and self.programming_state in [
'编程中'])
or (cloud_programming_state in [
'已编程'] and self.programming_state in ['已编程未下发']) else True
}
}
@@ -807,13 +817,7 @@ class MrpProduction(models.Model):
lambda m1: m1.state != 'rework' and m1.processing_panel == rework_workorder[0].processing_panel)
if not new_pancel_workorder.cnc_ids:
production.get_new_program(rework_workorder[0].processing_panel)
rework_production = self.env['mrp.production'].search(
[('state', '=', 'rework'), ('programming_no', '=', production.programming_no)])
if rework_production:
rework_production.workorder_ids.filtered(
lambda m2: m2.state != 'rework' and m2.processing_panel == rework_workorder[
0].processing_panel and m2.routing_type == '装夹预调').write({'state': 'ready'})
rework_production.write({'state': 'progress'})
production.write({'state': 'progress', 'programming_state': '已下发'})
# 从cloud获取重新编程过的最新程序
def get_new_program(self, processing_panel):

View File

@@ -827,6 +827,7 @@ class ResMrpWorkOrder(models.Model):
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel),
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
logging.info('re_work:%s' % re_work.state)
if workorder.state not in ['cancel', 'progress', 'rework']:
logging.info('工序:%s' % workorder.routing_type)
logging.info('状态:%s' % workorder.state)
@@ -840,10 +841,14 @@ class ResMrpWorkOrder(models.Model):
# if re_work:
# workorder.state = 'rework'
if workorder.production_id.state == 'rework':
if (workorder.routing_type == 'CNC加工' and re_work.state == 'done') or (
if (workorder.routing_type == 'CNC加工' and workorder.state == 'done') or (
workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '编程中' and re_work):
logging.info('面111:%s' % workorder.processing_panel)
workorder.state = 'waiting'
elif workorder.production_id.state == 'progress':
logging.info('面222:%s' % workorder.processing_panel)
if workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已下发' and re_work:
workorder.state = 'ready'
# else:
# if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework'
@@ -998,6 +1003,7 @@ class ResMrpWorkOrder(models.Model):
'detailed_reason': record.detailed_reason,
'processing_panel': record.processing_panel,
'routing_type': record.routing_type,
'handle_result': '待处理' if record.test_results == '返工' or record.is_rework is True else '',
'test_results': record.test_results,
'test_report': record.detection_report})]})
if record.routing_type == '解除装夹':

View File

@@ -7,8 +7,8 @@ import os
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
class ResProductMo(models.Model):

View File

@@ -120,9 +120,9 @@
<button name="button_scrap" invisible="1"/>
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
confirm="是否确认更新程序"
attrs="{'invisible': ['&amp;',('state', '!=', 'rework'), ('programming_state', '!=', '已编程未下发')]}"/>
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
<button name="button_rework" string="返工" type="object" groups="sf_base.group_sf_mrp_user"
attrs="{'invisible': [('state', '!=', 'rework'), ('programming_state', '!=', '已编程')]}"/>
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程')]}"/>
<button name="button_scrap_new" string="报废" type="object" groups="sf_base.group_sf_mrp_user"
confirm="是否确认报废" attrs="{'invisible': [('state', '!=', 'cancel')]}"/>
</xpath>
@@ -279,7 +279,7 @@
<xpath expr="//sheet//notebook//page[@name='operations']" position="after">
<page string="检测结果" attrs="{'invisible': [('detection_result_ids', '=', [])]}">
<field name="detection_result_ids" string="" readonly="1">
<field name="detection_result_ids" string="" readonly="0">
<tree sample="1">
<field name="production_id" invisible="1"/>
<field name="processing_panel"/>
@@ -555,6 +555,7 @@
<field name="arch" type="xml">
<form>
<group>
<field name="handle_result"/>
<field name="test_report" readonly="1" widget="pdf_viewer"/>
</group>
</form>

View File

@@ -26,7 +26,8 @@ class ReworkWizard(models.TransientModel):
is_reprogramming = fields.Boolean(string='申请重新编程', default=False)
reprogramming_num = fields.Integer('重新编程次数', default=0)
programming_state = fields.Selection(
[('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发')], string='编程状态')
[('待编程', '待编程'), ('编程中', '编程中'), ('已编程', '已编程'), ('已编程未下发', '已编程未下发')],
string='编程状态')
def confirm(self):
if self.routing_type in ['装夹预调', 'CNC加工']:
@@ -69,6 +70,8 @@ class ReworkWizard(models.TransientModel):
self.production_id.update_programming_state()
else:
self.production_id.do_update_program()
if self.production_id.state == 'progress':
self.production_id.write({'programming_state': '已编程'})
@api.onchange('production_id')
def onchange_processing_panel_id(self):

View File

@@ -19,13 +19,14 @@
readonly="1"
style='color:red;'/>次,且当前编程状态为
<field name="programming_state" string=""
decoration-info="programming_state == '待编程'"
decoration-success="programming_state == '已编程'"
decoration-warning="programming_state =='编程中'"
decoration-danger="programming_state =='已编程未下发'" readonly="1"/>
</div>
<group>
<field name="is_reprogramming"
attrs='{"invisible": [("programming_state","=",False)],"readonly": [("programming_state","in",["编程中","已编程未下发"])]}'/>
attrs='{"invisible": [("routing_type","in",["装夹预调","CNC加工"])],"readonly": [("programming_state","in",["编程中","已编程未下发"])]}'/>
<field name="rework_reason"
attrs='{"invisible": [("routing_type","not in",["装夹预调","CNC加工"])],"required": [("routing_type","in",["装夹预调"])]}'/>
<field name="detailed_reason"

View File

@@ -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']
@@ -112,7 +112,8 @@ class Sf_Mrs_Connect(http.Controller):
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('production_id', 'in', cnc_program_ids)])
if workpiece_delivery:
workpiece_delivery.write({'is_cnc_program_down': True})
workpiece_delivery.write(
{'is_cnc_program_down': True, 'production_line_id': productions.production_line_id.id})
return json.JSONEncoder().encode(res)
else:
res = {'status': 0, 'message': '该制造订单暂未开始'}

View File

@@ -8,8 +8,8 @@ from datetime import datetime
import requests
from odoo import http
from odoo.http import request
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
from odoo import models, fields, api
from odoo.modules import get_resource_path
from odoo.exceptions import ValidationError, UserError

View File

@@ -6,8 +6,8 @@ import os
from datetime import datetime
from stl import mesh
# from OCC.Core.GProp import GProp_GProps
# from OCC.Extend.DataExchange import read_step_file
# from OCC.Extend.DataExchange import write_stl_file
from OCC.Extend.DataExchange import read_step_file
from OCC.Extend.DataExchange import write_stl_file
from odoo.addons.sf_base.commons.common import Common
from odoo import models, fields, api
from odoo.modules import get_resource_path