Accept Merge Request #160: (feature/增加一键合并下发功能,修正合并下发逻辑 -> develop)
Merge Request: 一键下发代码请求合并 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/160
This commit is contained in:
@@ -52,13 +52,10 @@ class JdEclp(models.Model):
|
||||
sale_order_id = self.env['sale.order'].search([('name', '=', self.origin)])
|
||||
# stock_picking_type_id = self.enc['stock.picking.type'].search([('picking_type_id', '=', '')])
|
||||
# if sale_order_id.address_of_delivery != False:
|
||||
|
||||
|
||||
|
||||
try:
|
||||
if 'OUT' in self.name:
|
||||
raw_addres = sale_order_id.address_of_delivery.split('这是一个标志位,用来不分隔字符串')
|
||||
# _logger.info('=================dddd====', sale_order_id.address_of_delivery)
|
||||
# _logger.info('=================dddd====', type(sale_order_id.address_of_delivery))
|
||||
# _logger.info('========================================', raw_addres)
|
||||
# _logger.info('=================dddd====', self.display_name)
|
||||
# _logger.info('=================dddd====', type(self.display_name))
|
||||
@@ -77,6 +74,9 @@ class JdEclp(models.Model):
|
||||
self.receiverCityName = self.receiverCityName
|
||||
self.receiverCountyName = self.receiverCountyName
|
||||
self.receiverTownName = self.receiverTownName
|
||||
except Exception as e:
|
||||
print(f"Error address is none: {e}")
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import hashlib
|
||||
import time
|
||||
import requests
|
||||
from datetime import datetime
|
||||
|
||||
from odoo.http import request
|
||||
from odoo import fields, models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
@@ -138,16 +138,49 @@ class Machine_ftp(models.Model):
|
||||
machine_ip = fields.Char('机床IP')
|
||||
machine_signed = fields.Char('机床刷新间隔')
|
||||
machine_status = fields.Char('机床在线状态')
|
||||
machine_time_on = fields.Char('机床总在线时长')
|
||||
machine_tool_num = fields.Char('机床当前刀具')
|
||||
machine_program = fields.Char('机床当前程序')
|
||||
machine_cnc_type = fields.Char('机床CNC型号')
|
||||
machine_axis_count = fields.Char('机床轴总数')
|
||||
machine_run_status = fields.Char('机床运行状态')
|
||||
machine_run_time = fields.Char('机床总运行时长')
|
||||
machine_cut_time = fields.Char('机床总切削时长')
|
||||
machine_cut_status = fields.Char('机床切削状态')
|
||||
machine_emg_status = fields.Char('机床急停状态')
|
||||
machine_mode = fields.Char('机床操作模式')
|
||||
machine_spindle_speed = fields.Char('机床主轴转速')
|
||||
machine_cut_status = fields.Char('机床当前切削状态')
|
||||
machine_mode = fields.Char('机床当前操作模式')
|
||||
machine_spindle_load = fields.Char('机床主轴负载')
|
||||
machine_x_mach = fields.Char('机床X轴机械坐标')
|
||||
machine_x_abs_mach = fields.Char('机床X轴当前位置')
|
||||
machine_x_rel_mach = fields.Char('机床X轴相对工件坐标')
|
||||
machine_x_dis_mach = fields.Char('机床X轴目标距离')
|
||||
machine_x_axis_load = fields.Char('机床X轴伺服轴负载')
|
||||
machine_y_mach = fields.Char('机床Y轴机械坐标')
|
||||
machine_y_abs_mach = fields.Char('机床Y轴当前位置')
|
||||
machine_y_rel_mach = fields.Char('机床Y轴相对工件坐标')
|
||||
machine_y_dis_mach = fields.Char('机床Y轴目标距离')
|
||||
machine_y_axis_load = fields.Char('机床Y轴伺服轴负载')
|
||||
machine_z_mach = fields.Char('机床Z轴机械坐标')
|
||||
machine_z_abs_mach = fields.Char('机床Z轴当前位置')
|
||||
machine_z_rel_mach = fields.Char('机床Z轴相对工件坐标')
|
||||
machine_z_dis_mach = fields.Char('机床Z轴目标距离')
|
||||
machine_z_axis_load = fields.Char('机床Z轴伺服轴负载')
|
||||
machine_tool_num = fields.Char('机床当前刀位号')
|
||||
machine_program = fields.Char('机床主程序名称')
|
||||
machine_current_prg = fields.Char('机床当前执行指令')
|
||||
machine_prg_seq = fields.Char('机床当前执行语句号')
|
||||
machine_spindle_speed_set = fields.Char('机床设定主轴速度')
|
||||
machine_act_spindle_speed = fields.Char('机床实际主轴转速')
|
||||
machine_feed_speed_set = fields.Char('机床设定进给速度')
|
||||
machine_act_feed_speed = fields.Char('机床实际进给速度')
|
||||
machine_spindle_feed = fields.Char('机床主轴倍率')
|
||||
machine_feed_rate = fields.Char('机床进给倍率')
|
||||
machine_rapid_feed = fields.Char('机床快速移动倍率')
|
||||
machine_run_time = fields.Char('机床运行时间')
|
||||
machine_cut_time = fields.Char('机床切削时间')
|
||||
machine_keep_alive_time = fields.Char('机床上电时间')
|
||||
machine_circle_time = fields.Char('机床循环时间')
|
||||
machine_product_counts = fields.Char('机床加工件数')
|
||||
machine_system_date = fields.Char('机床系统日期')
|
||||
machine_system_time = fields.Char('机床系统时间')
|
||||
machine_alarm_msg = fields.Char('机床系统报警')
|
||||
|
||||
|
||||
# 刀位配置
|
||||
tool_num1 = fields.Char('刀位1')
|
||||
tool_num2 = fields.Char('刀位2')
|
||||
@@ -222,6 +255,7 @@ class WorkCenterBarcode(models.Model):
|
||||
"""
|
||||
_inherit = "mrp.workorder"
|
||||
|
||||
# barcode = fields.Binary(string='条码', default='UP-ALL')
|
||||
compensation_value_x = fields.Float(string='X轴补偿值')
|
||||
compensation_value_y = fields.Float(string='Y轴补偿值')
|
||||
button_compensation_state = fields.Boolean(string='是否已经补偿', readonly=True)
|
||||
@@ -343,6 +377,95 @@ class WorkCenterBarcode(models.Model):
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||
|
||||
def up_merge_all(self):
|
||||
"""
|
||||
此函数用于将NC代码一键合并下发到机床
|
||||
:return:
|
||||
"""
|
||||
# 一键合并下发前删除机床上的全部程序
|
||||
try:
|
||||
filepath = '/nc2machine'
|
||||
del_list = os.listdir(filepath)
|
||||
_logger.info("=====================================%s" % del_list)
|
||||
for f in del_list:
|
||||
file_path = os.path.join(filepath, f)
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('程序删除失败,请重试')
|
||||
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
||||
try:
|
||||
self.compensation()
|
||||
except Exception:
|
||||
raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态")
|
||||
sequence_collect = []
|
||||
host = self.workcenter_id.machine_tool_id.ftp_host
|
||||
port = self.workcenter_id.machine_tool_id.ftp_port
|
||||
username = self.workcenter_id.machine_tool_id.ftp_num
|
||||
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
||||
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
|
||||
_logger.info("=====================1666666661111================%s,%s,%s,%s" % (host, port, username, pwd))
|
||||
ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||
_logger.info("=====================1777777777111================")
|
||||
file_path_local = ''
|
||||
file_path_remote = ''
|
||||
|
||||
try:
|
||||
# 给文件名
|
||||
_logger.info('启动')
|
||||
begin_name1 = self.cnc_ids[0].cnc_id.display_name.split('-')
|
||||
_logger.info(begin_name1)
|
||||
temp_name1 = begin_name1[-1].split('.')
|
||||
final_name = '%s-ALL-MERGE.%s' % (begin_name1[0], temp_name1[-1])
|
||||
_logger.info(final_name)
|
||||
for item in self.cnc_ids:
|
||||
a = item.cnc_id
|
||||
sequence_collect.append(item.sequence_number)
|
||||
datas = base64.standard_b64decode(a.datas)
|
||||
# file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
||||
file_path_local = '{}/{}'.format('/nc2machine', final_name)
|
||||
# 本地测试一键下发
|
||||
# file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name)
|
||||
# file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name)
|
||||
file_path_remote = '{}\{}'.format(remote_path, final_name)
|
||||
# 合并文件
|
||||
with open(file_path_local, mode='ab+') as file:
|
||||
file.write(datas)
|
||||
item.button_state = True
|
||||
_logger.info('========一键下发前合并成功===============')
|
||||
|
||||
# 去除合并文件中间部分的头尾
|
||||
with open(file_path_local, mode='rb+') as f:
|
||||
# _logger.info(f.read())
|
||||
# content = f.read()
|
||||
# _logger.info(content)
|
||||
new_content = f.read().replace(b'\r\nM30\r\n%\r\n%\r\n', b'\r\n')
|
||||
# _logger.info(new_content)
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.write(new_content)
|
||||
_logger.info('========二次合并成功===============')
|
||||
|
||||
# 存在本地的文件下发到机床
|
||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
_logger.info("======%s一键合并下发成功======" % a.display_name)
|
||||
ftp.close_ftp()
|
||||
# 增加一键合并下发记录
|
||||
up_time = str(datetime.now())
|
||||
sequence_str = ','.join(sequence_collect)
|
||||
self.delivery_records.create({
|
||||
'delivery_type': '一键合并下发',
|
||||
'delivery_time': up_time,
|
||||
'influence_record': sequence_str,
|
||||
})
|
||||
_logger.info("=====================22================")
|
||||
except Exception as e:
|
||||
for item in self.cnc_ids:
|
||||
item.button_state = False
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||
|
||||
def get__state(self):
|
||||
pay_time = str(datetime.now())
|
||||
json = {
|
||||
@@ -359,6 +482,59 @@ class WorkCenterBarcode(models.Model):
|
||||
url = 'https://bfm.cs.jikimo.com/api/get/state'
|
||||
requests.post(url, json=json, data=None)
|
||||
|
||||
def action_test(self, barcode=12345):
|
||||
|
||||
workorder_obj = self.env['mrp.workorder'].sudo().search([('tray_code', '=', barcode)])
|
||||
action = {
|
||||
'name': '工单',
|
||||
# 'name': name,
|
||||
'type': 'ir.actions.act_window',
|
||||
# 'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mrp.workorder',
|
||||
'view_id': self.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
|
||||
'res_id': 1023,
|
||||
'target': 'current',
|
||||
'context': {'id': workorder_obj.id},
|
||||
# 'flags': {'initial_mode': 'edit'},
|
||||
}
|
||||
return action
|
||||
# result = request.env['ir.actions.act_window'].sudo().create(action).read()[0]
|
||||
# action = {'action': action}
|
||||
# return result
|
||||
|
||||
@api.model
|
||||
def get_product_id_by_barcode(self, barcode, **kwargs):
|
||||
print(kwargs)
|
||||
print(barcode)
|
||||
print('111111111111111111111')
|
||||
workorder_obj_target = self.env['mrp.workorder'].sudo().search([('tray_code', '=', barcode)])
|
||||
workorder_obj_current = self.env['mrp.workorder'].sudo().search([('id', '=', kwargs['current_id'])])
|
||||
# workorder_cnc = self.env['mrp.workorder'].sudo().search(['&', ('production_id', '=', workorder_obj.production_id.id), ('name', '=', 'CNC加工')])
|
||||
workorder_cnc = self.env['mrp.workorder'].sudo().search(['&', ('production_id', '=', workorder_obj_target.production_id.id), ('name', '=', workorder_obj_current.name)])
|
||||
print('222222222222222222222222')
|
||||
if workorder_obj_target:
|
||||
print(workorder_obj_target)
|
||||
print(workorder_obj_target.id)
|
||||
action = {
|
||||
'name': '工单',
|
||||
'type': 'ir.actions.act_window',
|
||||
# 'view_type': 'form',
|
||||
'views': [[False, 'form']],
|
||||
'view_mode': 'form',
|
||||
'res_model': 'mrp.workorder',
|
||||
'view_id': request.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
|
||||
'res_id': workorder_cnc.id,
|
||||
'target': 'current',
|
||||
'context': {'id': workorder_obj_target.id},
|
||||
# 'flags': {'initial_mode': 'edit'},
|
||||
}
|
||||
action = {'result': action, 'error': '返回错误'}
|
||||
action1 = json.dumps(action)
|
||||
return action1
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class CuttingTimeToolType(models.Model):
|
||||
_inherit = 'sf.cutting_tool.type'
|
||||
@@ -381,6 +557,7 @@ class DeliveryRecord(models.Model):
|
||||
扫码托盘码可查到制造订单,由制造订单查工单
|
||||
"""
|
||||
_name = "delivery.record"
|
||||
_description = "Delivery Record"
|
||||
|
||||
delivery_type = fields.Char(string='下发方式', readonly=True)
|
||||
delivery_time = fields.Char(string='下发时间', readonly=True)
|
||||
|
||||
@@ -49,7 +49,7 @@ class FtpController:
|
||||
self.port = port
|
||||
self.username = username
|
||||
self.password = password
|
||||
_logger.info("===================ftppppp==================%s,%s,%s,%s" % self.host, self.port, self.username, self.password)
|
||||
# _logger.info("===================ftppppp==================%s,%s,%s,%s" % self.host, self.port, self.username, self.password)
|
||||
# 测试
|
||||
print("==============================================")
|
||||
print(self.username, self.port, self.host, self.password)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
|
||||
access_up_select_wizard,up.select.wizard,model_up_select_wizard,base.group_user,1,1,1,1
|
||||
access_delivery_record,delivery.record,model_delivery_record,base.group_user,1,1,1,1
|
||||
access_mrp_workorder,mrp.workorder,model_mrp_workorder,base.group_user,1,1,1,1
|
||||
|
||||
|
@@ -1,3 +1,85 @@
|
||||
// /** @odoo-module **/
|
||||
//
|
||||
// import { browser } from "@web/core/browser/browser";
|
||||
// import { Dialog } from "@web/core/dialog/dialog";
|
||||
// import { _lt } from "@web/core/l10n/translation";
|
||||
// import { useChildRef, useOwnedDialogs, useService } from "@web/core/utils/hooks";
|
||||
// import { sprintf } from "@web/core/utils/strings";
|
||||
// import { isMobileOS } from "@web/core/browser/feature_detection";
|
||||
// import * as BarcodeScanner from "@web/webclient/barcode/barcode_scanner";
|
||||
//
|
||||
// const {xml, Component} = owl;
|
||||
// import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
||||
// // Import the registry
|
||||
// import {registry} from "@web/core/registry";
|
||||
//
|
||||
//
|
||||
// export class CodeField extends Component {
|
||||
// setup() {
|
||||
// super.setup();
|
||||
// }
|
||||
// async onBarcodeBtnClick() {
|
||||
// const barcode = await BarcodeScanner.scanBarcode();
|
||||
// if (barcode) {
|
||||
// await this.onBarcodeScanned(barcode);
|
||||
// if ("vibrate" in browser.navigator) {
|
||||
// browser.navigator.vibrate(100);
|
||||
// }
|
||||
// } else {
|
||||
// this.notification.add(this.env._t("Please, scan again !"), {
|
||||
// type: "warning",
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// async search(barcode) {
|
||||
// const results = await this.orm.call("sf.tray", "name_search", [code], {
|
||||
// name: barcode,
|
||||
// args: this.getDomain(),
|
||||
// operator: "ilike",
|
||||
// limit: 2, // If one result we set directly and if more than one we use normal flow so no need to search more
|
||||
// context: this.context,
|
||||
// });
|
||||
// return results.map((result) => {
|
||||
// const [id, displayName] = result;
|
||||
// return {
|
||||
// id,
|
||||
// name: displayName,
|
||||
// };
|
||||
// });
|
||||
// }
|
||||
// async onBarcodeScanned(barcode) {
|
||||
// const results = await this.search(barcode);
|
||||
// const records = results.filter((r) => !!r.id);
|
||||
// if (records.length === 1) {
|
||||
// this.update([{ id: records[0].id, name: records[0].name }]);
|
||||
// } else {
|
||||
// const searchInput = this.autocompleteContainerRef.el.querySelector("input");
|
||||
// searchInput.value = barcode;
|
||||
// searchInput.dispatchEvent(new Event("input"));
|
||||
// if (this.env.isSmall) {
|
||||
// searchInput.click();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// CodeField.template = xml`
|
||||
// <button
|
||||
// t-on-click="onBarcodeBtnClick"
|
||||
// type="button"
|
||||
// class="btn ms-3 o_barcode"
|
||||
// tabindex="-1"
|
||||
// draggable="false"
|
||||
// aria-label="Scan barcode"
|
||||
// title="Scan barcode"
|
||||
// data-tooltip="Scan barcode"
|
||||
// />
|
||||
// `;
|
||||
// // CodeField.template = 'sf_machine_connect.CodeField';
|
||||
// CodeField.props = standardFieldProps;
|
||||
//
|
||||
// // Add the field to the correct category
|
||||
// registry.category("fields").add("code", CodeField);
|
||||
/** @odoo-module **/
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
@@ -17,6 +99,8 @@ import {registry} from "@web/core/registry";
|
||||
export class CodeField extends Component {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.orm = this.env.services.orm;
|
||||
this.record = this.props.record;
|
||||
}
|
||||
async onBarcodeBtnClick() {
|
||||
// console.log(BarcodeScanner)
|
||||
@@ -41,26 +125,97 @@ export class CodeField extends Component {
|
||||
}
|
||||
}
|
||||
async search(barcode) {
|
||||
const results = await this.orm.call("sf.tray", "name_search", [code], {
|
||||
name: barcode,
|
||||
args: this.getDomain(),
|
||||
operator: "ilike",
|
||||
limit: 2, // If one result we set directly and if more than one we use normal flow so no need to search more
|
||||
context: this.context,
|
||||
});
|
||||
alert('我是search')
|
||||
const domain = [["code", "=", barcode]];
|
||||
// const domain = [];
|
||||
console.log(domain)
|
||||
alert('走到这里了')
|
||||
const fields = ["id", "code", "name", "state"];
|
||||
console.log(fields)
|
||||
alert('走到这里了1')
|
||||
const results = await this.orm.call("sf.tray", "search_read", [domain, fields]);
|
||||
const values = await this.orm.call("sf.tray", "search_read", [domain]);
|
||||
console.log(results)
|
||||
alert('走到这里了2')
|
||||
return results.map((result) => {
|
||||
const [id, displayName] = result;
|
||||
return {
|
||||
id,
|
||||
name: displayName,
|
||||
id: result.id,
|
||||
code: result.code,
|
||||
name: result.name,
|
||||
state: result.state,
|
||||
values: values,
|
||||
};
|
||||
});
|
||||
}
|
||||
async onBarcodeScanned(barcode) {
|
||||
// alert('我是ONbarcodeScanned')
|
||||
const results = await this.search(barcode);
|
||||
console.log(results)
|
||||
const records = results.filter((r) => !!r.id);
|
||||
console.log(records)
|
||||
if (records.length === 1) {
|
||||
this.update([{ id: records[0].id, name: records[0].name }]);
|
||||
if (records[0].state === '空闲') {
|
||||
// const currentModel = this.env.models['mrp.workorder'];
|
||||
console.log('currentModel',this)
|
||||
console.log('this.record.data',this.record.data)
|
||||
// const recordID = this.controllerParams.recordID;
|
||||
// console.log('当前页面记录 ID:', recordID);
|
||||
// console.log('this.record',this.record.id)
|
||||
// console.log('this.record',this.controllerParams.recordID)
|
||||
// const workorder = await this.orm.call('mrp.workorder', 'read', [this.record.data.id, ['id']]);
|
||||
console.log('this.record.data.id', this.record.data.id)
|
||||
const workorder = await this.orm.call('mrp.workorder', 'read', [this.record.data.id]);
|
||||
console.log('workorder', workorder[0])
|
||||
const updatedRecord = await this.orm.call("sf.tray", "write", [
|
||||
[records[0].id],
|
||||
{
|
||||
// state: "占用",
|
||||
workorder_id: workorder[0].id,
|
||||
production_id: workorder[0].product_id[0],
|
||||
// workorder_id: workorder.id,
|
||||
}]);
|
||||
console.log(workorder[0].routing_type);
|
||||
console.log(workorder[0].production_id);
|
||||
// const productionIDS = await this.orm.call('mrp.production', 'search', [[['id', '=', workorder[0].production_id[0]]]]);
|
||||
const productionIDS = await this.orm.call('mrp.workorder', 'search', [[["production_id", "=", workorder[0].production_id[0]]]]);
|
||||
console.log('prooooooo', productionIDS);
|
||||
console.log('values', records[0].values[0]);
|
||||
productionIDS.forEach(async (data) => {
|
||||
// 处理每一个数据
|
||||
console.log(data);
|
||||
const updatetrayRecord = await this.orm.call("mrp.workorder", "write", [
|
||||
[data],
|
||||
{
|
||||
tray_id: records[0].values[0].id,
|
||||
// tray_id: false,
|
||||
}]);
|
||||
console.log(updatetrayRecord)
|
||||
});
|
||||
// this.trigger_up('reload')
|
||||
// this.props.update(records[0].code, records[0].values);
|
||||
this.props.update(records[0].code, records[0].tray_id);
|
||||
// this.trigger_up('button_clicked', {
|
||||
// attrs: {
|
||||
// name: 'save',
|
||||
// },
|
||||
// });
|
||||
// this.do_action({
|
||||
// 'type': 'ir.actions.act_window',
|
||||
// 'res_model': 'mrp.workorder',
|
||||
// 'view_mode': 'form',
|
||||
// 'view_type': 'form',
|
||||
// 'res_id': workorder[0].id,
|
||||
// 'target': 'current',
|
||||
// })
|
||||
} else {
|
||||
if (records[0].state === '占用') {
|
||||
console.log('此托盘已占用,请检查')
|
||||
alert('此托盘已占用,请检查')
|
||||
} else {
|
||||
console.log('此托盘已损坏,请登记')
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
const searchInput = this.autocompleteContainerRef.el.querySelector("input");
|
||||
searchInput.value = barcode;
|
||||
@@ -73,19 +228,27 @@ export class CodeField extends Component {
|
||||
}
|
||||
|
||||
CodeField.template = xml`
|
||||
<div class="o_field_widget o_input o_barcode_field">
|
||||
<!-- <input class="o_input" type="text" t-att-value="value"/>-->
|
||||
<div class="o_input_container">
|
||||
<t t-raw="widget"/>
|
||||
</div>
|
||||
<button
|
||||
t-on-click="onBarcodeBtnClick"
|
||||
type="button"
|
||||
class="btn ms-3 o_barcode"
|
||||
class="sf_button o_barcode btn ms-3 o_barcode"
|
||||
tabindex="-1"
|
||||
draggable="false"
|
||||
aria-label="Scan barcode"
|
||||
title="Scan barcode"
|
||||
data-tooltip="Scan barcode"
|
||||
/>
|
||||
</div>
|
||||
`;
|
||||
// CodeField.template = 'sf_machine_connect.CodeField';
|
||||
CodeField.props = standardFieldProps;
|
||||
|
||||
// Add the field to the correct category
|
||||
registry.category("fields").add("code", CodeField);
|
||||
|
||||
// style="position: relative; left: 200px;"
|
||||
@@ -3,13 +3,18 @@
|
||||
<record id="sf_install_the_tray_workorder_form_view__scan_barcode" model="ir.ui.view">
|
||||
<field name="name">sf.install.the.tray.workorder.form.scan.barcode</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<!-- <field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/> -->
|
||||
<!-- <field name="arch" type="xml"> -->
|
||||
<!-- <xpath expr="//page//field[@name='tray_code']" position="before"> -->
|
||||
<!-- --><!-- invisible="1" -->
|
||||
<!-- <field name="_barcode_scanned" widget="barcode_handler" string="扫码"/> -->
|
||||
<!-- </xpath> -->
|
||||
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page//field[@name='tray_code']" position="before">
|
||||
<xpath expr="//group//field[@name='processing_panel']" position="after">
|
||||
<!-- invisible="1" -->
|
||||
<field name="_barcode_scanned" widget="barcode_handler" string="扫码"/>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -28,6 +28,10 @@
|
||||
<button string="合并下发" id="action_up_select" name="%(sf_machine_connect.action_up_select)d"
|
||||
type="action" class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
|
||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
||||
<span> </span>
|
||||
<button string="一键合并下发" name="up_merge_all" type="object" style="text-align: right;" confirm="是否确认一键合并下发"
|
||||
class="btn-primary" context="{'default_workorder_id': id}" attrs='{"invisible": ["|",
|
||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
||||
</div>
|
||||
</div>
|
||||
</group>
|
||||
|
||||
@@ -8,22 +8,30 @@
|
||||
<xpath expr="//page[last()-3]" position="before">
|
||||
<page string="机床信息" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<group string="机床信息">
|
||||
<group>
|
||||
<field name="machine_tool_name"/>
|
||||
<field name="machine_tool_type_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="machine_tool_machine_ip"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="运行信息">
|
||||
<group>
|
||||
<field name="machine_tool_timestamp"/>
|
||||
<field name="machine_tool_status"/>
|
||||
<field name="machine_tool_run_status"/>
|
||||
<field name="machine_tool_time_on"/>
|
||||
<field name="machine_tool_time_on_now"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="machine_tool_tool_num"/>
|
||||
<field name="machine_tool_program"/>
|
||||
<field name="machine_tool_cut_status"/>
|
||||
<field name="machine_tool_compensation_value_x"/>
|
||||
<field name="machine_tool_compensation_value_y"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -11,47 +11,62 @@
|
||||
<!-- <xpath expr="//page[@name='other']" position="before">-->
|
||||
<notebook>
|
||||
<page string="机床监控">
|
||||
<!-- <group string="监控">-->
|
||||
<group col='12'>
|
||||
<group string='状态监控'>
|
||||
<group>
|
||||
<field name="timestamp"/>
|
||||
<field name="signed"/>
|
||||
<field name="status"/>
|
||||
<field name="time_on"/>
|
||||
<field name="time_on_now"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="run_status"/>
|
||||
<field name="run_time"/>
|
||||
<field name="cut_status"/>
|
||||
<!-- <field name="cut_time"/>-->
|
||||
<!-- <field name="cut_time"/> -->
|
||||
<field name="program"/>
|
||||
<field name="tool_num"/>
|
||||
<field name="spindle_speed"/>
|
||||
|
||||
</group>
|
||||
<group string='刀位统计' col='8'>
|
||||
</group>
|
||||
<group string='刀位统计'>
|
||||
<group>
|
||||
<group>
|
||||
<field name="tool_num_process_time1"/>
|
||||
<field name="tool_num_process_time2"/>
|
||||
<field name="tool_num_process_time3"/>
|
||||
<field name="tool_num_process_time4"/>
|
||||
<field name="tool_num_process_time5"/>
|
||||
<field name="tool_num_process_time6"/>
|
||||
<field name="tool_num_process_time7"/>
|
||||
<field name="tool_num_process_time8"/>
|
||||
<field name="tool_num_process_time9"/>
|
||||
<field name="tool_num_process_time10"/>
|
||||
<field name="tool_num_process_time11"/>
|
||||
<field name="tool_num_process_time12"/>
|
||||
<field name="tool_num_process_time13"/>
|
||||
<field name="tool_num_process_time14"/>
|
||||
<field name="tool_num_process_time15"/>
|
||||
<field name="tool_num_process_time16"/>
|
||||
<field name="tool_num_process_time17"/>
|
||||
<field name="tool_num_process_time18"/>
|
||||
<field name="tool_num_process_time19"/>
|
||||
<field name="tool_num_process_time20"/>
|
||||
<field name="tool_num_process_time21"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="tool_num_process_time2"/>
|
||||
<field name="tool_num_process_time6"/>
|
||||
<field name="tool_num_process_time10"/>
|
||||
<field name="tool_num_process_time14"/>
|
||||
<field name="tool_num_process_time18"/>
|
||||
<field name="tool_num_process_time22"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="tool_num_process_time3"/>
|
||||
<field name="tool_num_process_time7"/>
|
||||
<field name="tool_num_process_time11"/>
|
||||
<field name="tool_num_process_time15"/>
|
||||
<field name="tool_num_process_time19"/>
|
||||
<field name="tool_num_process_time23"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="tool_num_process_time4"/>
|
||||
<field name="tool_num_process_time8"/>
|
||||
<field name="tool_num_process_time12"/>
|
||||
<field name="tool_num_process_time16"/>
|
||||
<field name="tool_num_process_time20"/>
|
||||
<field name="tool_num_process_time24"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<!-- <div class="o_address_format"> -->
|
||||
<!-- <label for="tool_num_process_time1" string="刀位1"/> -->
|
||||
@@ -126,74 +141,122 @@
|
||||
<!-- <label for="tool_num_process_time24" string="刀位24"/> -->
|
||||
<!-- <field name="tool_num_process_time24" class="o_form_label"/> -->
|
||||
<!-- </div> -->
|
||||
</group>
|
||||
<!-- </group> -->
|
||||
</page>
|
||||
<page string="机床配置">
|
||||
<!-- <group string="机床配置">-->
|
||||
<group>
|
||||
<!-- <group string="机床配置">--> -->
|
||||
<group string="ftp相关">
|
||||
<group>
|
||||
<field name="ftp_num"/>
|
||||
<field name="ftp_pwd"/>
|
||||
<field name="ftp_host"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="ftp_port"/>
|
||||
<field name="ftp_remote_path"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="补偿值相关">
|
||||
<group>
|
||||
<field name="x_compensation_node"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="y_compensation_node"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="数采相关">
|
||||
<group>
|
||||
<field name="machine_ip"/>
|
||||
<field name="machine_signed"/>
|
||||
<field name="machine_status"/>
|
||||
<field name="machine_time_on"/>
|
||||
<field name="machine_cnc_type"/>
|
||||
<field name="machine_axis_count"/>
|
||||
<field name="machine_run_status"/>
|
||||
<field name="machine_emg_status"/>
|
||||
<field name="machine_cut_status"/>
|
||||
<field name="machine_mode"/>
|
||||
<field name="machine_spindle_load"/>
|
||||
<field name="machine_x_mach"/>
|
||||
<field name="machine_x_abs_mach"/>
|
||||
<field name="machine_x_rel_mach"/>
|
||||
<field name="machine_x_dis_mach"/>
|
||||
<field name="machine_x_axis_load"/>
|
||||
<field name="machine_y_mach"/>
|
||||
<field name="machine_y_abs_mach"/>
|
||||
<field name="machine_y_rel_mach"/>
|
||||
<field name="machine_y_dis_mach"/>
|
||||
<field name="machine_y_axis_load"/>
|
||||
<field name="machine_z_mach"/>
|
||||
<field name="machine_z_abs_mach"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="machine_z_rel_mach"/>
|
||||
<field name="machine_z_dis_mach"/>
|
||||
<field name="machine_z_axis_load"/>
|
||||
<field name="machine_tool_num"/>
|
||||
<field name="machine_program"/>
|
||||
<field name="machine_run_status"/>
|
||||
<field name="machine_current_prg"/>
|
||||
<field name="machine_prg_seq"/>
|
||||
<field name="machine_spindle_speed_set"/>
|
||||
<field name="machine_act_spindle_speed"/>
|
||||
<field name="machine_feed_speed_set"/>
|
||||
<field name="machine_act_feed_speed"/>
|
||||
<field name="machine_spindle_feed"/>
|
||||
<field name="machine_feed_rate"/>
|
||||
<field name="machine_rapid_feed"/>
|
||||
<field name="machine_run_time"/>
|
||||
<field name="machine_cut_time"/>
|
||||
<field name="machine_cut_status"/>
|
||||
<field name="machine_emg_status"/>
|
||||
<field name="machine_mode"/>
|
||||
<field name="machine_spindle_speed"/>
|
||||
<field name="machine_keep_alive_time"/>
|
||||
<field name="machine_circle_time"/>
|
||||
<field name="machine_product_counts"/>
|
||||
<field name="machine_system_date"/>
|
||||
<field name="machine_system_time"/>
|
||||
<field name="machine_alarm_msg"/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
<!-- </group> -->
|
||||
</page>
|
||||
<page string="刀位配置">
|
||||
<!-- <group string="机床配置">-->
|
||||
<group string="刀位配置">
|
||||
<group>
|
||||
<group>
|
||||
<field name="tool_num1"/>
|
||||
<field name="tool_num2"/>
|
||||
<field name="tool_num3"/>
|
||||
<field name="tool_num4"/>
|
||||
<field name="tool_num5"/>
|
||||
<field name="tool_num6"/>
|
||||
<field name="tool_num7"/>
|
||||
<field name="tool_num8"/>
|
||||
<field name="tool_num9"/>
|
||||
<field name="tool_num10"/>
|
||||
<field name="tool_num11"/>
|
||||
<field name="tool_num12"/>
|
||||
<field name="tool_num13"/>
|
||||
<field name="tool_num14"/>
|
||||
<field name="tool_num15"/>
|
||||
<field name="tool_num16"/>
|
||||
<field name="tool_num17"/>
|
||||
<field name="tool_num18"/>
|
||||
<field name="tool_num19"/>
|
||||
<field name="tool_num20"/>
|
||||
<field name="tool_num21"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="tool_num2"/>
|
||||
<field name="tool_num6"/>
|
||||
<field name="tool_num10"/>
|
||||
<field name="tool_num14"/>
|
||||
<field name="tool_num18"/>
|
||||
<field name="tool_num22"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="tool_num3"/>
|
||||
<field name="tool_num7"/>
|
||||
<field name="tool_num11"/>
|
||||
<field name="tool_num15"/>
|
||||
<field name="tool_num19"/>
|
||||
<field name="tool_num23"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="tool_num4"/>
|
||||
<field name="tool_num8"/>
|
||||
<field name="tool_num12"/>
|
||||
<field name="tool_num16"/>
|
||||
<field name="tool_num20"/>
|
||||
<field name="tool_num24"/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -18,13 +18,13 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
class UpSelectWizard(models.TransientModel):
|
||||
_name = 'up.select.wizard'
|
||||
_description = 'Up Select Wizard'
|
||||
|
||||
workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
|
||||
workcenter_id = fields.Many2one('mrp.workcenter', string='工作中心', related='workorder_id.workcenter_id',
|
||||
readonly=True)
|
||||
program_ids = fields.Many2many('sf.cnc.processing', string='程序列表')
|
||||
|
||||
|
||||
def confirm_up(self):
|
||||
# 合并下发前删除机床上的全部程序
|
||||
try:
|
||||
@@ -73,10 +73,21 @@ class UpSelectWizard(models.TransientModel):
|
||||
# 合并文件
|
||||
with open(file_path_local, mode='ab+') as file:
|
||||
file.write(datas)
|
||||
|
||||
# 下发成功标识
|
||||
item.button_state = True
|
||||
|
||||
_logger.info('========初次合并成功===============')
|
||||
_logger.info(file_path_local)
|
||||
# 去除合并文件中间部分的头尾
|
||||
with open(file_path_local, mode='rb+') as f:
|
||||
# _logger.info(f.read())
|
||||
# content = f.read()
|
||||
# _logger.info(content)
|
||||
new_content = f.read().replace(b'\r\nM30\r\n%\r\n%\r\n', b'\r\n')
|
||||
# _logger.info(new_content)
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.write(new_content)
|
||||
_logger.info('========二次合并成功===============')
|
||||
# 存在本地的文件下发到机床
|
||||
_logger.info("==========存在服务器成功,准备下发===========")
|
||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
@@ -95,4 +106,3 @@ class UpSelectWizard(models.TransientModel):
|
||||
item.button_state = False
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||
|
||||
|
||||
@@ -661,17 +661,48 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
def on_barcode_scanned(self, barcode):
|
||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||
if "*" not in barcode:
|
||||
if self.routing_type == '装夹':
|
||||
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||
self.tray_code = tray_code.code
|
||||
self.tray_id = workorder.gettray_auto(barcode)
|
||||
elif self.routing_type == '前置三元定位检测':
|
||||
print('我是前置三元检测')
|
||||
logging.info('我是前置三元检测')
|
||||
elif self.routing_type == 'CNC加工':
|
||||
if barcode == 'UP-ALL':
|
||||
print("我是一键合并下发")
|
||||
logging.info('我是一键合并下发')
|
||||
self.up_merge_all()
|
||||
else:
|
||||
print('CNC加工')
|
||||
# print(barcode)
|
||||
# a = self.env['sf.tray'].search([('code', '=', barcode)])
|
||||
# print(a)
|
||||
# # workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)], limit=1)
|
||||
# workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)])
|
||||
# e = workorder_obj.id
|
||||
# print(workorder_obj)
|
||||
# action = {
|
||||
# 'name': '工单',
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# # 'view_type': 'form',
|
||||
# 'view_mode': 'form',
|
||||
# 'res_model': 'mrp.workorder',
|
||||
# 'view_id': self.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
|
||||
# # 'res_id': workorder_obj.id,
|
||||
# 'res_id': 1023,
|
||||
# 'target': 'current',
|
||||
# # 'context': self.env.context,
|
||||
# # 'flags': {'initial_mode': 'edit'},
|
||||
# }
|
||||
# return action
|
||||
|
||||
elif self.routing_type == '后置三元质量检测':
|
||||
print('后置三元检测')
|
||||
elif self.routing_type == '解除装夹':
|
||||
print("我是解除装夹")
|
||||
else:
|
||||
pass
|
||||
|
||||
else:
|
||||
self.pro_code_ok = workorder.pro_code_is_ok(barcode)
|
||||
|
||||
# return {
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# 'name': '工单',
|
||||
# 'res_model': 'mrp.workorder',
|
||||
# 'view_mode': 'form',
|
||||
# 'context': {'active_id': self.id},
|
||||
# # 'target': 'current',
|
||||
# }
|
||||
|
||||
Reference in New Issue
Block a user