Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/tax_sync

This commit is contained in:
liaodanlong
2024-07-31 14:41:02 +08:00
13 changed files with 8349 additions and 77260 deletions

View File

@@ -149,7 +149,7 @@ class JdEclp(models.Model):
},
}
_logger.info('准备调接口1')
url1 = config['bfm_url'] + '/api/create/jd/order'
url1 = config['bfm_url_new'] + '/api/create/jd/order'
requests.post(url1, json=json1, data=None)
_logger.info('调用成功1')
_logger.info('准备调接口2')
@@ -158,7 +158,7 @@ class JdEclp(models.Model):
'orderNo': self.origin,
},
}
url2 = config['bfm_url'] + '/api/get/jd/no'
url2 = config['bfm_url_new'] + '/api/get/jd/no'
response = requests.post(url2, json=json2, data=None)
# _logger.info('调用成功2', response.json()['result']['wbNo'])
tem_ret = response.json().get('result')
@@ -196,7 +196,7 @@ class JdEclp(models.Model):
'no': self.origin,
},
}
url1 = config['bfm_url'] + '/api/create/jd/bill'
url1 = config['bfm_url_new'] + '/api/create/jd/bill'
response = requests.post(url1, json=json1, data=None)
# _logger.info('调用成功2', response.json())

View File

@@ -30,7 +30,7 @@ class StatusChange(models.Model):
'process_start_time': process_start_time,
},
}
url1 = config['bfm_url'] + '/api/get/state/get_order'
url1 = config['bfm_url_new'] + '/api/get/state/get_order'
requests.post(url1, json=json1, data=None)
logging.info('接口已经执行=============')
@@ -54,7 +54,7 @@ class StatusChange(models.Model):
'state': '待派单',
},
}
url1 = config['bfm_url'] + '/api/get/state/cancel_order'
url1 = config['bfm_url_new'] + '/api/get/state/cancel_order'
requests.post(url1, json=json1, data=None)
return res

View File

@@ -8,11 +8,14 @@ _logger = logging.getLogger(__name__)
class ResBFMConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
bfm_url = fields.Selection(
[("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"),
("https://bfm.t.jikimo.com", "测试环境(https://bfm.t.jikimo.com)"),
# ("正式环境", "https://bfm.jikimo.com")], string='bfm环境', store=True)
("https://bfm.jikimo.com", "正式环境(https://bfm.jikimo.com)")], string='bfm环境', store=True)
# bfm_url = fields.Selection(
# [("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"),
# ("https://bfm.t.jikimo.com", "测试环境(https://bfm.t.jikimo.com)"),
# ("https://bfm.r.jikimo.com", "预发布环境(https://bfm.r.jikimo.com)"),
# # ("正式环境", "https://bfm.jikimo.com")], string='bfm环境', store=True)
# ("https://bfm.jikimo.com", "正式环境(https://bfm.jikimo.com)")], string='bfm环境', store=True)
bfm_url_new = fields.Char('业务平台环境路径', placeholder='请输入当前对应的业务平台环境路径')
@api.model
def get_values(self):
@@ -22,14 +25,14 @@ class ResBFMConfigSettings(models.TransientModel):
"""
values = super(ResBFMConfigSettings, self).get_values()
config = self.env['ir.config_parameter'].sudo()
bfm_url = config.get_param('bfm_url', default='')
bfm_url_new = config.get_param('bfm_url_new', default='')
values.update(
bfm_url=bfm_url,
bfm_url_new=bfm_url_new,
)
return values
def set_values(self):
super(ResBFMConfigSettings, self).set_values()
ir_config = self.env['ir.config_parameter'].sudo()
ir_config.set_param("bfm_url", self.bfm_url or "")
ir_config.set_param("bfm_url_new", self.bfm_url_new or "")

View File

@@ -14,8 +14,8 @@
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<div class="text-muted">
<label for="bfm_url" />
<field name="bfm_url" string="访问地址"/>
<label for="bfm_url_new" />
<field name="bfm_url_new" string="业务平台访问地址"/>
</div>
</div>
<!-- </div> -->

View File

@@ -260,40 +260,27 @@ class Manufacturing_Connect(http.Controller):
request.env['center_control.interface.log'].sudo().create(
{'content': ret, 'name': 'AutoDeviceApi/PartQualityInspect'})
production_id = ret['BillId']
routing_type = ret['CraftId']
# routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type), ('state', '!=', 'rework')],
[('production_id', '=', production_id), ('routing_type', '=', 'CNC加工'),
('state', 'not in', ['rework', 'done', 'cancel'])], order='sequence asc',
limit=1)
if workorder:
# workorder.test_results = ret['Quality']
logging.info('制造订单:%s' % workorder.production_id.name)
if 'ReportPaht' in ret:
download_state = request.env['mrp.workorder'].with_user(
request.env.ref("base.user_admin")).download_reportfile_tmp(workorder,
ret['ReportPaht'])
if download_state == 1:
detection_ret = request.env['mrp.workorder'].with_user(
request.env.ref("base.user_admin")).get_detection_file(workorder, ret['ReportPaht'])
if detection_ret is True:
stock_picking_type = request.env['stock.picking.type'].sudo().search(
[('sequence_code', '=', 'SFP')])
if stock_picking_type:
stock_picking = request.env['stock.picking'].sudo().search(
[('product_id', '=', workorder.product_id.id),
('origin', '=', workorder.production_id.origin),
('picking_type_id', '=', stock_picking_type.id)])
if stock_picking:
quality_check = request.env['quality.check'].sudo().search(
[('product_id', '=', workorder.product_id.id),
('picking_id', '=', stock_picking.id)])
if quality_check:
logging.info('质检单:%s' % quality_check.name)
quality_check.write({'report_pdf': workorder.detection_report})
elif download_state == 2:
res = {'Succeed': False, 'ErrorCode': 205,
'Error': 'ReportPaht中的工件号与制造订单%s不匹配请检查ReportPaht是否正确' % workorder.production_id.name}
else:
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '检测报告文件从FTP拉取失败'}
if ret['ReportPaht'].find('.pdf') != -1:
download_state = request.env['mrp.workorder'].with_user(
request.env.ref("base.user_admin")).download_reportfile_tmp(workorder,
ret['ReportPaht'])
if download_state is True:
detection_ret = request.env['mrp.workorder'].with_user(
request.env.ref("base.user_admin")).get_detection_file(workorder, ret['ReportPaht'])
logging.info('detection_ret:%s' % detection_ret)
if detection_ret is False:
res = {'Succeed': False, 'ErrorCode': 205, 'Error': '检测报告文件读取失败'}
else:
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '检测报告文件从FTP拉取失败'}
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传ReportPaht字段'}
else:

View File

@@ -36,15 +36,13 @@ class MrpProduction(models.Model):
def _compute_tool_state_remark(self):
for item in self:
if item.workorder_ids:
work_ids = []
for workorder_id in item.workorder_ids:
if workorder_id.tool_state == '1':
work_ids.append(workorder_id)
if work_ids:
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel'])
if workorder_ids.filtered(lambda a: a.tool_state == '1'):
work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1')
tool_state_remark = ''
for work_id in work_ids:
if tool_state_remark == '':
tool_state_remark = f"{work_id.tool_state_remark}"
tool_state_remark = f'{work_id.tool_state_remark}'
else:
tool_state_remark = f"{tool_state_remark}\n{work_id.tool_state_remark}"
item.tool_state_remark = tool_state_remark
@@ -56,16 +54,10 @@ class MrpProduction(models.Model):
for item in self:
if item.workorder_ids:
tool_state = item.tool_state
work_ids_1 = []
work_ids_2 = []
for workorder_id in item.workorder_ids:
if workorder_id.tool_state == '2':
work_ids_2.append(workorder_id)
elif workorder_id.tool_state == '1':
work_ids_1.append(workorder_id)
if work_ids_2:
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ['rework', 'done', 'cancel'])
if workorder_ids.filtered(lambda a: a.tool_state == '2'):
item.tool_state = '2'
elif work_ids_1:
elif workorder_ids.filtered(lambda a: a.tool_state == '1'):
item.tool_state = '1'
else:
item.tool_state = '0'
@@ -695,6 +687,9 @@ class MrpProduction(models.Model):
for work_id in work_ids:
if panel_sequence_list.get(work_id.name):
work_id.sequence = panel_sequence_list[work_id.name]
if rec.tool_state in ['1', '2']:
rec.workorder_ids.filtered(
lambda a: a.routing_type == '装夹预调' and a.state in 'ready').compute_state()
# 创建工单并进行排序
def _create_workorder(self, item):

View File

@@ -910,39 +910,49 @@ class ResMrpWorkOrder(models.Model):
# if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework'
if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
if workorder.production_id.tool_state in ['1', '2']:
if workorder.state in ['ready']:
workorder.state = 'waiting'
continue
elif workorder.state in ['waiting']:
continue
elif workorder.state == 'pending' and workorder == self.search(
[('production_id', '=', workorder.production_id.id),
('routing_type', '=', '装夹预调'),
('state', 'not in', ['rework', 'done', 'cancel'])],
limit=1,
order="sequence"):
workorder.state = 'waiting'
continue
elif workorder.production_id.tool_state in ['0']:
if workorder.production_id.workorder_ids.filtered(lambda a: a.state == 'rework'):
if not workorder.production_id.workorder_ids.filtered(
lambda a: (a.routing_type not in ['装夹预调'] and
a.state not in ['pending', 'done', 'rework', 'cancel'])):
# 查询工序最小的非完工、非返工的装夹预调工单
work_id = self.search(
workorder_ids = workorder.production_id.workorder_ids
work_bo = True
for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
if not workorder_ids.filtered(
lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
and a.processing_panel == wo.processing_panel)):
work_bo = False
break
if (workorder.production_id.programming_state == '已编程' and work_bo
and not workorder_ids.filtered(lambda a: a.sequence == 0)):
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
if workorder.production_id.tool_state in ['1', '2']:
if workorder.state in ['ready']:
workorder.state = 'waiting'
continue
elif workorder.state in ['waiting']:
continue
elif workorder.state == 'pending' and workorder == self.search(
[('production_id', '=', workorder.production_id.id),
('routing_type', '=', '装夹预调'),
('state', 'not in', ['rework', 'done', 'cancel'])],
limit=1,
order="sequence")
if workorder == work_id:
if workorder.production_id.reservation_state == 'assigned':
workorder.state = 'ready'
elif workorder.production_id.reservation_state != 'assigned':
workorder.state = 'waiting'
continue
order="sequence"):
workorder.state = 'waiting'
continue
elif workorder.production_id.tool_state in ['0']:
if workorder_ids.filtered(lambda a: a.state == 'rework'):
if not workorder_ids.filtered(
lambda a: (a.routing_type not in ['装夹预调'] and
a.state not in ['pending', 'done', 'rework', 'cancel'])):
# 查询工序最小的非完工、非返工的装夹预调工单
work_id = self.search(
[('production_id', '=', workorder.production_id.id),
('routing_type', '=', '装夹预调'),
('state', 'not in', ['rework', 'done', 'cancel'])],
limit=1,
order="sequence")
if workorder == work_id:
if workorder.production_id.reservation_state == 'assigned':
workorder.state = 'ready'
elif workorder.production_id.reservation_state != 'assigned':
workorder.state = 'waiting'
continue
logging.info('工序:%s' % workorder.sequence)
logging.info('工单最终状态:%s' % workorder.state)
@@ -978,6 +988,9 @@ class ResMrpWorkOrder(models.Model):
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
# workorder.state = 'waiting'
def compute_state(self):
self._compute_state()
# 重写工单开始按钮方法
def button_start(self):
if self.routing_type == '装夹预调':
@@ -1195,38 +1208,27 @@ class ResMrpWorkOrder(models.Model):
# 将FTP的检测报告文件下载到临时目录
def download_reportfile_tmp(self, workorder, reportpath):
logging.info('reportpath:%s' % reportpath)
production_no_ftp = reportpath.split('/')
production_no = workorder.production_id.name.replace('/', '_')
# ftp地址
remotepath = os.path.join('/NC', production_no_ftp[1], 'detection')
logging.info('ftp地址:%s' % remotepath)
if reportpath.find(production_no) != -1:
# 服务器内临时地址
serverdir = os.path.join('/tmp', production_no_ftp[1], 'detection')
ftp_resconfig = self.env['res.config.settings'].get_values()
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']),
ftp_resconfig['ftp_user'],
ftp_resconfig['ftp_password'])
download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath)
logging.info('download_state:%s' % download_state)
else:
download_state = 2
logging.info('reportpath/ftp地址:%s' % reportpath)
logging.info('processing_panel:%s' % workorder.processing_panel)
serverdir = os.path.join('/tmp', workorder.production_id.name.replace('/', '_'), 'detection',
workorder.processing_panel)
ftp_resconfig = self.env['res.config.settings'].get_values()
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']),
ftp_resconfig['ftp_user'],
ftp_resconfig['ftp_password'])
if not ftp.file_exists_1(reportpath):
logging.info('文件不存在:%s' % reportpath)
download_state = ftp.download_program_file(reportpath, serverdir)
logging.info('download_state:%s' % download_state)
return download_state
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
def get_detection_file(self, workorder, reportPath):
# if reportPath.startswith('/'):
# reportPath = reportPath[4:]
# serverdir = os.path.join('/tmp', reportPath)
serverdir = '/tmp' + reportPath
serverdir = os.path.join('/tmp', workorder.production_id.name.replace('/', '_'), 'detection',
workorder.processing_panel)
logging.info('get_detection_file-serverdir:%s' % serverdir)
serverdir_prefix = os.path.dirname(serverdir)
logging.info('serverdir_prefix-serverdir:%s' % serverdir_prefix)
for root, dirs, files in os.walk(serverdir_prefix):
for root, dirs, files in os.walk(serverdir):
for filename in files:
logging.info('filename:%s' % filename)
logging.info('reportPath:%s' % os.path.basename(reportPath))
if filename == os.path.basename(reportPath):
report_file_path = os.path.join(root, filename)
logging.info('get_detection_file-report_file_path:%s' % report_file_path)

View File

@@ -132,7 +132,7 @@ class ReworkWizard(models.TransientModel):
'sequence_number': cmm_line.sequence_number,
'program_name': cmm_line.program_name,
'program_path': cmm_line.program_path,
'ftp_path': item_line.program_path,
'ftp_path': cmm_line.program_path,
'processing_panel': panel.name,
'program_create_date': datetime.strftime(
cmm_line.program_create_date,

View File

@@ -49,7 +49,7 @@ class FtpController():
logging.error(f"Error checking file: {e}")
return False
# 下载目录下的pdf文件(程序单)
# 下载目录下的pdf文件(程序单/检测文件)
def download_program_file(self, target_dir, serverdir):
if not os.path.exists(serverdir):
os.makedirs(serverdir)

File diff suppressed because it is too large Load Diff

View File

@@ -158,7 +158,7 @@ class QuickEasyOrder(models.Model):
payload = {
'file_path': new_file_path,
'dest_path': new_folder_path,
'back_url': config['bfm_url']
'back_url': config['bfm_url_new']
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:

View File

@@ -1,6 +1,6 @@
import logging
from datetime import timedelta, datetime
from datetime import timedelta, datetime, date
from odoo import fields, models, api
from odoo.exceptions import ValidationError
@@ -603,6 +603,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
功能刀具组装
:return:
"""
logging.info('功能刀具开始组装!')
# 获取组装单对象
functional_tool_assembly = self.env['sf.functional.tool.assembly'].search([
('assembly_order_code', '=', self.assembly_order_code),
@@ -649,6 +650,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
])
cam_plan.write({'plan_execute_status': '2'})
logging.info('功能刀具组装完成!')
# 关闭弹出窗口
return {'type': 'ir.actions.act_window_close'}
@@ -865,9 +868,10 @@ class StockPicking(models.Model):
# 设置数量,并验证完成
picking_id.action_set_quantities_to_reservation()
picking_id.button_validate()
logging.info(f'刀具物料调拨单状态:{picking_id.state}')
def _get_name_stock1(self, picking_type_id):
name = picking_type_id.sequence_id.prefix
name = f'{picking_type_id.sequence_id.prefix}DJ/{date.today().strftime("%y")}'
stock_id = self.env['stock.picking'].sudo().search(
[('name', 'like', name), ('picking_type_id', '=', picking_type_id.id)],
limit=1,

View File

@@ -2,6 +2,9 @@
<odoo>
<data>
<record model="ir.actions.act_window" id="stock.stock_picking_type_action">
<field name="context">{'search_default_groupby_code':1}</field>
</record>
<record id="view_location_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.location.form.sf.inherit</field>