diff --git a/jikimo_frontend/static/src/js/custom_form_status_indicator.js b/jikimo_frontend/static/src/js/custom_form_status_indicator.js index fd06fe75..a5f68479 100644 --- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -11,7 +11,7 @@ var Dialog = require('web.Dialog'); patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', { // 你可以重写或者添加一些方法和属性 async _onDiscardChanges() { - var self = this; + // var self = this; Dialog.confirm(this, _t("Are you sure you want to discard changes?"), { title: _t("Discard Changes"), @@ -25,7 +25,8 @@ patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', { // if (window.confirm("Are you sure you want to discard changes?")) { // await this.props.discard(); // } - const result = await this._confirmDiscardChange(); + // const result = await this._confirmDiscardChange(); + await this._confirmDiscardChange(); await this.props.discard(); }, diff --git a/jikimo_frontend/static/src/list/custom_width.js b/jikimo_frontend/static/src/list/custom_width.js index ba35c605..31fd23ca 100644 --- a/jikimo_frontend/static/src/list/custom_width.js +++ b/jikimo_frontend/static/src/list/custom_width.js @@ -10,7 +10,7 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { // The following code manipulates the DOM directly to avoid having to wait for a // render + patch which would occur on the next frame and cause flickering. freezeColumnWidths() { - console.log('ccccccccccccccccccccccccccc') + // console.log('ccccccccccccccccccccccccccc') if (!this.keepColumnWidths) { this.columnWidths = null; } diff --git a/sf_base/commons/__init__.py b/sf_base/commons/__init__.py index d89945c1..e4193cf0 100644 --- a/sf_base/commons/__init__.py +++ b/sf_base/commons/__init__.py @@ -1 +1 @@ -from. import common +from . import common diff --git a/sf_base/security/group_security.xml b/sf_base/security/group_security.xml index 0d435401..4d57bc43 100644 --- a/sf_base/security/group_security.xml +++ b/sf_base/security/group_security.xml @@ -1,5 +1,43 @@ + + 制造普通用户 + + + + + + + + + + + + + + + 机床操作岗 + + + + + 刀具组装岗 + + + + + 工件装夹岗 + + + + + + 生产总监 + + + + + 计划 20 diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 37daa2b3..1a550d41 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -40,3 +40,5 @@ access_maintenance_equipment_image,maintenance_equipment_image,model_maintenance + + diff --git a/sf_bf_connect/models/__init__.py b/sf_bf_connect/models/__init__.py index 21f9d732..84f8bf3a 100644 --- a/sf_bf_connect/models/__init__.py +++ b/sf_bf_connect/models/__init__.py @@ -2,4 +2,3 @@ from . import http from . import models from . import process_status from . import jd_eclp - diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py index 6f6b4ab6..dfcb20f8 100644 --- a/sf_bf_connect/models/jd_eclp.py +++ b/sf_bf_connect/models/jd_eclp.py @@ -1,8 +1,8 @@ -# import cpca import base64 import logging from datetime import datetime import requests +import cpca from odoo.exceptions import UserError from odoo.exceptions import ValidationError from odoo import api, fields, models, SUPERUSER_ID, _ diff --git a/sf_bf_connect/models/models.py b/sf_bf_connect/models/models.py index 5aba960a..07393353 100644 --- a/sf_bf_connect/models/models.py +++ b/sf_bf_connect/models/models.py @@ -4,7 +4,6 @@ import uuid import string import random - from odoo import fields, models __author__ = 'jinling.yang' @@ -25,4 +24,4 @@ class ResPartner(models.Model): return ran_str sf_token = fields.Char(u'Token', default=get_token) - sf_secret_key = fields.Char(u'密钥', default=get_secret) \ No newline at end of file + sf_secret_key = fields.Char(u'密钥', default=get_secret) diff --git a/sf_machine_connect/__manifest__.py b/sf_machine_connect/__manifest__.py index 6ee1a20a..db7ae467 100644 --- a/sf_machine_connect/__manifest__.py +++ b/sf_machine_connect/__manifest__.py @@ -22,24 +22,25 @@ 'views/ftp_button.xml', 'views/compensation.xml', + # 只有它被屏蔽了 # 'views/SfWorkOrderBarcodes.xml', 'views/WorkCenterBarcodes.xml', 'views/Stock_picking_Barcodes.xml', - # 'views/machine_monitor.xml', + 'views/machine_monitor.xml', 'views/machine_info_present.xml', 'views/delivery_record.xml', 'views/res_config_settings_views.xml', ], 'assets': { - 'web.assets_backend': [ - # 'sf_machine_connect/static/src/xml/barcode_button.xml', - # 'sf_machine_connect/static/src/js/barcode_button.js', - # 'sf_machine_connect/static/src/css/barcode_button.css', + 'web.assets_backend': [ + # 'sf_machine_connect/static/src/xml/barcode_button.xml', + # 'sf_machine_connect/static/src/js/barcode_button.js', + # 'sf_machine_connect/static/src/css/barcode_button.css', ], }, - 'external_dependencies': {'python': ['opcua(使用pip install opcua -i https://pypi.tuna.tsinghua.edu.cn/simple)']}, + # 'external_dependencies': {'python': ['opcua(使用pip install opcua -i https://pypi.tuna.tsinghua.edu.cn/simple)']}, 'installable': True, 'application': True, diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py index d1295217..7ca0ad06 100644 --- a/sf_machine_connect/models/ftp_client.py +++ b/sf_machine_connect/models/ftp_client.py @@ -60,11 +60,11 @@ class FtpButton(models.Model): raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态") # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC" - host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host - port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port - username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num - pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd - remote_path = self.workorder_id.workcenter_id.machine_tool_id.ftp_remote_path + host = self.workorder_id.equipment_id.ftp_host + port = self.workorder_id.equipment_id.ftp_port + username = self.workorder_id.equipment_id.ftp_num + pwd = self.workorder_id.equipment_id.ftp_pwd + remote_path = self.workorder_id.equipment_id.ftp_remote_path print(host, port, username, pwd, remote_path) ftp = ftp_operate.FtpController(host, port, username, pwd) # ftp.delAllfile('C://Users//马广威//Desktop//ftp') @@ -107,8 +107,8 @@ class FtpButton(models.Model): 下发NC代码前自动补偿三元检测偏差值 :return: """ - hongbianliang550 = self.workorder_id.workcenter_id.machine_tool_id.x_compensation_node - hongbianliang551 = self.workorder_id.workcenter_id.machine_tool_id.y_compensation_node + hongbianliang550 = self.workorder_id.equipment_id.x_compensation_node + hongbianliang551 = self.workorder_id.equipment_id.y_compensation_node try: temp_dict = {} temp_dict[hongbianliang550] = self.workorder_id.compensation_value_x @@ -124,9 +124,9 @@ class Machine_ftp(models.Model): """ 数据采集类 """ - _inherit = 'sf.machine_tool' + _inherit = 'maintenance.equipment' - workorder_ids = fields.One2many('mrp.workorder', 'machine_tool_id', string='工单') + # workorder_ids = fields.One2many('mrp.workorder', 'machine_tool_id', string='工单') # 机床配置项目 # ftp相关 @@ -263,7 +263,7 @@ class WorkCenterBarcode(models.Model): compensation_value_y = fields.Float(string='Y轴补偿值') button_compensation_state = fields.Boolean(string='是否已经补偿', readonly=True) button_up_all_state = fields.Boolean(string='是否已经全部下发', readonly=True) - machine_tool_id = fields.Many2one('sf.machine_tool', string='机床') + machine_tool_id = fields.Many2one('sf.machine_tool.type', string='机床') machine_tool_name = fields.Char(string='机床名称', default='未知机床', compute='_run_info', readonly=True) machine_tool_type_id = fields.Char(string='机床型号', default='未知型号', compute='_run_info', readonly=True) machine_tool_status = fields.Boolean(string='在线状态', compute='_run_info', readonly=True) @@ -281,27 +281,27 @@ class WorkCenterBarcode(models.Model): machine_tool_compensation_value_y = fields.Char('y补偿值', compute='_run_info', readonly=True) delivery_records = fields.One2many('delivery.record', 'workorder_id', string="下发记录") - @api.depends('workcenter_id.machine_tool_id.timestamp') + @api.depends('equipment_id.timestamp') def _run_info(self): # self.machine_tool_name = '1号机床' - self.machine_tool_name = self.workcenter_id.machine_tool_id.name - self.machine_tool_type_id = self.workcenter_id.machine_tool_id.type_id.name - self.machine_tool_status = self.workcenter_id.machine_tool_id.status - self.machine_tool_run_status = self.workcenter_id.machine_tool_id.run_status - self.machine_tool_timestamp = self.workcenter_id.machine_tool_id.timestamp - self.machine_tool_time_on = self.workcenter_id.machine_tool_id.time_on - self.machine_tool_time_on_now = self.workcenter_id.machine_tool_id.time_on_now - self.machine_tool_tool_num = self.workcenter_id.machine_tool_id.tool_num - self.machine_tool_program = self.workcenter_id.machine_tool_id.program - self.machine_tool_machine_ip = self.workcenter_id.machine_tool_id.machine_ip - self.machine_tool_cut_status = self.workcenter_id.machine_tool_id.cut_status + self.machine_tool_name = self.equipment_id.name + self.machine_tool_type_id = self.equipment_id.type_id.name + self.machine_tool_status = self.equipment_id.status + self.machine_tool_run_status = self.equipment_id.run_status + self.machine_tool_timestamp = self.equipment_id.timestamp + self.machine_tool_time_on = self.equipment_id.time_on + self.machine_tool_time_on_now = self.equipment_id.time_on_now + self.machine_tool_tool_num = self.equipment_id.tool_num + self.machine_tool_program = self.equipment_id.program + self.machine_tool_machine_ip = self.equipment_id.machine_ip + self.machine_tool_cut_status = self.equipment_id.cut_status self.machine_tool_compensation_value_x = self.compensation_value_x self.machine_tool_compensation_value_y = self.compensation_value_y def compensation(self): - hongbianliang550 = self.workcenter_id.machine_tool_id.x_compensation_node - hongbianliang551 = self.workcenter_id.machine_tool_id.y_compensation_node + hongbianliang550 = self.equipment_id.x_compensation_node + hongbianliang551 = self.equipment_id.y_compensation_node try: temp_dict = {} temp_dict[hongbianliang550] = self.compensation_value_x @@ -339,11 +339,11 @@ class WorkCenterBarcode(models.Model): 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 + host = self.equipment_id.ftp_host + port = self.equipment_id.ftp_port + username = self.equipment_id.ftp_num + pwd = self.equipment_id.ftp_pwd + remote_path = self.equipment_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================") @@ -403,11 +403,11 @@ class WorkCenterBarcode(models.Model): 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 + host = self.equipment_id.ftp_host + port = self.equipment_id.ftp_port + username = self.equipment_id.ftp_num + pwd = self.equipment_id.ftp_pwd + remote_path = self.equipment_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================") diff --git a/sf_machine_connect/models/ftp_operate.py b/sf_machine_connect/models/ftp_operate.py index a94824f2..457ef6ed 100644 --- a/sf_machine_connect/models/ftp_operate.py +++ b/sf_machine_connect/models/ftp_operate.py @@ -91,7 +91,6 @@ class FtpController: """ self.ftp.close() - def delAllfile(self, ftppath): """ 删除ftp服务器端全部文件 diff --git a/sf_machine_connect/models/py2opcua.py b/sf_machine_connect/models/py2opcua.py index 2b00f394..e7ca2fad 100644 --- a/sf_machine_connect/models/py2opcua.py +++ b/sf_machine_connect/models/py2opcua.py @@ -26,11 +26,11 @@ class Py2opcua: """ # try: self.client.connect() - # print("opcua服务器连接成功,可以写入") - # return self.client + # print("opcua服务器连接成功,可以写入") + # return self.client # except Exception as e: # print("opcua服务器连接失败,请检查" + str(e)) - # temp_dict = temp_dict + # temp_dict = temp_dict temp_list = list(temp_dict.items()) for i in range(len(temp_list)): # 寻找节点上的变量 diff --git a/sf_machine_connect/models/res_config_setting.py b/sf_machine_connect/models/res_config_setting.py index c8257bf8..6d9a6c84 100644 --- a/sf_machine_connect/models/res_config_setting.py +++ b/sf_machine_connect/models/res_config_setting.py @@ -10,7 +10,7 @@ class ResBFMConfigSettings(models.TransientModel): bfm_url = fields.Selection( [("https://bfm.cs.jikimo.com", "开发环境(https://bfm.cs.jikimo.com)"), - ("https://bfm.r.jikimo.com", "测试环境(https://bfm.r.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) diff --git a/sf_machine_connect/static/src/js/barcode_form.js b/sf_machine_connect/static/src/js/barcode_form.js index d8c898ae..f6190918 100644 --- a/sf_machine_connect/static/src/js/barcode_form.js +++ b/sf_machine_connect/static/src/js/barcode_form.js @@ -1,12 +1,12 @@ odoo.define('my_module.barcode_handler', function (require) { "use strict"; - var core = require('web.core'); + // var core = require('web.core'); var registry = require('web.field_registry'); var session = require('web.session'); var FieldChar = require('web.basic_fields').FieldChar; - var _t = core._t; + // var _t = core._t; var BarcodeHandlerField = FieldChar.extend({ init: function () { diff --git a/sf_machine_connect/static/src/js/barcode_handler_field.js b/sf_machine_connect/static/src/js/barcode_handler_field.js index 6d24d4c6..526f28d7 100644 --- a/sf_machine_connect/static/src/js/barcode_handler_field.js +++ b/sf_machine_connect/static/src/js/barcode_handler_field.js @@ -56,7 +56,7 @@ export class BarcodeHandlerField extends Component { // }); await this.actionService.doAction(response.result); } else { - console.error("Barcode not found or RPC call failed."); + // console.error("Barcode not found or RPC call failed."); } } diff --git a/sf_machine_connect/views/machine_monitor.xml b/sf_machine_connect/views/machine_monitor.xml index f07d784a..83b89598 100644 --- a/sf_machine_connect/views/machine_monitor.xml +++ b/sf_machine_connect/views/machine_monitor.xml @@ -2,14 +2,14 @@ sf_base_extension - sf.machine_tool - + maintenance.equipment + - + - + @@ -256,49 +256,51 @@ - + - - sf_cutting_tool_extension - sf.cutting_tool.type - - - - - - - - - - + + + + + + + + + + + - + + + -
+ -
- -
+ -
-
-
-
-
+ + + + +
diff --git a/sf_maintenance/models/sf_equipment_maintenance_standards.py b/sf_maintenance/models/sf_equipment_maintenance_standards.py index 80ec2ba3..2892cac4 100644 --- a/sf_maintenance/models/sf_equipment_maintenance_standards.py +++ b/sf_maintenance/models/sf_equipment_maintenance_standards.py @@ -2,6 +2,7 @@ from odoo import api, fields, models, SUPERUSER_ID, _ from odoo.exceptions import UserError + class SfEquipmentSaintenanceStandards(models.Model): _name = 'equipment.maintenance.standards' _description = '设备维保标准' @@ -18,6 +19,7 @@ class SfEquipmentSaintenanceStandards(models.Model): m = int(partner.code[-4:]) + 1 num = "%04d" % m return num + code = fields.Char(string='编码') remark = fields.Char('备注') maintenance_type = fields.Selection([('保养', '保养'), ("检修", "检修")], string='类型', default='保养') @@ -69,6 +71,7 @@ class SfEquipmentSaintenanceStandards(models.Model): # work.sequence = current_sequence # current_sequence += 1 + class SfSaintenanceStandards(models.Model): _name = 'maintenance.standards' _description = '维保项目' @@ -92,7 +95,3 @@ class MaintenanceStandardImage(models.Model): image = fields.Binary(string='维保图片') standard_id = fields.Many2one('maintenance.standards', string='Standard') - - - - diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index bf58c8f2..8078913a 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -12,7 +12,8 @@ class SfMaintenanceEquipmentCategory(models.Model): _inherit = 'maintenance.equipment.category' _description = '设备类别' - equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], string='类型', default='机床') + equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), + ('检测设备', '检测设备')], string='类型', default='机床') class SfMaintenanceEquipment(models.Model): @@ -62,9 +63,10 @@ class SfMaintenanceEquipment(models.Model): else: record.equipment_maintenance_standards_ids = False - MTcode = fields.Char("编码", default=get_no) + MTcode = fields.Char("机台编码", default=get_no) created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) - equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')], compute='_compute_category_id') + equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), ('检测设备', '检测设备')] + , compute='_compute_category_id') @api.depends('category_id') def _compute_category_id(self): @@ -72,8 +74,8 @@ class SfMaintenanceEquipment(models.Model): if record: record.equipment_type = record.category_id.equipment_type - code = fields.Char('机台号') - name = fields.Char('名称') + code = fields.Char('行业编码') + name = fields.Char('机台号') knife_type = fields.Selection( [("BT40", "BT40"), ("BT30", "BT30"), ("BT50", "BT50")], default="", string="刀把类型") @@ -152,6 +154,18 @@ class SfMaintenanceEquipment(models.Model): result.append((parameter.id, name)) return result + @api.model + def create(self, vals): + # 在创建设备之前执行一些自定义逻辑 + + equipment = super(SfMaintenanceEquipment, self).create(vals) + equipment.name = equipment.MTcode + '#' + equipment.category_id.name + + # 在创建设备之后执行一些自定义逻辑 + # ... + + return equipment + # @api.constrains('rotate_speed') # def _check_rotate_speed(self): # if self.rotate_speed <= 0: @@ -278,7 +292,8 @@ class SfMaintenanceEquipment(models.Model): detect_y_axis = fields.Char('检测Y轴') detect_z_axis = fields.Char('检测Z轴') detect_precision = fields.Char('测量精度') - detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), ('激光干涉仪', '激光干涉仪')], string='测量方式') + detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), + ('激光干涉仪', '激光干涉仪')], string='测量方式') detect_resolution = fields.Char('分辨率') detect_load_weight_max = fields.Char('最大负载重量') detect_weight = fields.Char('本体总重量') @@ -304,13 +319,15 @@ class SfMaintenanceEquipment(models.Model): robot_load_weight_max = fields.Char('最大负载重量') robot_weight = fields.Char('本体总重量') robot_repeatable_positioning_accuracy = fields.Char('重复定位精度') - robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'), ('7轴', '7轴'), ('8轴', '8轴')], string='轴数') + robot_axis_num = fields.Selection([('2轴', '2轴'), ('3轴', '3轴'), ('4轴', '4轴'), ('5轴', '5轴'), ('6轴', '6轴'), + ('7轴', '7轴'), ('8轴', '8轴')], string='轴数') axis_ids = fields.One2many('sf.robot.axis.num', 'equipment_id', string='动作范围') robot_track_dimensions_L = fields.Char('轨道尺寸(长)') robot_track_dimensions_W = fields.Char('轨道尺寸(宽)') robot_track_dimensions_H = fields.Char('轨道尺寸(高)') robot_drive_mode = fields.Char('驱动方式') - robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], string='安装方式') + robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], + string='安装方式') robot_operating_temperature = fields.Char('机器人环境温度') robot_operating_humidity = fields.Char('机器人环境湿度') @@ -347,7 +364,7 @@ class SfMaintenanceEquipment(models.Model): images_ids_names = [] for a in self.env['maintenance.equipment.image'].search([('id', 'in', item.image_id.ids)]): images_ids_names.append(a.name) - if item.machine_tool_picture != False: + if item.machine_tool_picture: image = base64.b64encode(item.machine_tool_picture).decode('utf-8') else: image = False @@ -433,7 +450,8 @@ class SfMaintenanceEquipment(models.Model): if next_maintenance_todo and last_maintenance_done: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date - # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future + # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than + # 2 times the period and next request is in the future # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta( days=equipment.period) * 2 and next_maintenance_todo.request_date > date_now: @@ -445,7 +463,8 @@ class SfMaintenanceEquipment(models.Model): elif next_maintenance_todo: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - date_now - # If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request + # If next maintenance to do is in the future, and in more than 2 times the period, we insert + # an new request # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.period) * 2: next_date = date_now + timedelta(days=equipment.period) @@ -475,7 +494,8 @@ class SfMaintenanceEquipment(models.Model): if next_maintenance_todo and last_maintenance_done: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - last_maintenance_done.close_date - # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 times the period and next request is in the future + # If the gap between the last_maintenance_done and the next_maintenance_todo one is bigger than 2 + # times the period and next request is in the future # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta( days=equipment.overhaul_period) * 2 and next_maintenance_todo.request_date > date_now: @@ -487,7 +507,8 @@ class SfMaintenanceEquipment(models.Model): elif next_maintenance_todo: next_date = next_maintenance_todo.request_date date_gap = next_maintenance_todo.request_date - date_now - # If next maintenance to do is in the future, and in more than 2 times the period, we insert an new request + # If next maintenance to do is in the future, and in more than 2 times the period, we insert + # an new request # We use 2 times the period to avoid creation too closed request from a manually one created if date_gap > timedelta(0) and date_gap > timedelta(days=equipment.overhaul_period) * 2: next_date = date_now + timedelta(days=equipment.overhaul_period) @@ -577,7 +598,8 @@ class SfMaintenanceEquipment(models.Model): if not next_requests: equipment._create_new_request1(equipment.overhaul_date) - image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', domain="[('type', '=', '加工能力')]") + image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='加工能力', + domain="[('type', '=', '加工能力')]") class SfRobotAxisNum(models.Model): diff --git a/sf_maintenance/models/sf_maintenance_logs.py b/sf_maintenance/models/sf_maintenance_logs.py index 9adf5be7..5c798754 100644 --- a/sf_maintenance/models/sf_maintenance_logs.py +++ b/sf_maintenance/models/sf_maintenance_logs.py @@ -1,6 +1,7 @@ # -*-coding:utf-8-*- from odoo import fields, models + class SfMaintenanceLogs(models.Model): _name = 'sf.maintenance.logs' _description = '设备故障日志' @@ -11,16 +12,17 @@ class SfMaintenanceLogs(models.Model): brand = fields.Many2one('sf.machine.brand', related='maintenance_equipment_id.brand_id', string='品牌') maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='设备') code_location = fields.Char(string='编码位置') - fault_type = fields.Selection([('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='故障类型') + fault_type = fields.Selection( + [('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='故障类型') fault_code = fields.Char(string='故障代码') fault_alarm_info = fields.Char(string='故障报警信息') - alarm_level = fields.Selection([('一级', '一级(严重)'), ('二级', '二级(中等)'), ('三级', '三级(轻微)')], string='报警级别') + alarm_level = fields.Selection([('一级', '一级(严重)'), ('二级', '二级(中等)'), ('三级', '三级(轻微)')], + string='报警级别') alarm_time = fields.Datetime(string='报警时间') - alarm_way = fields.Selection([('文本提示报警', '文本提示报警'), ('声光报警', '声光报警'), ('图文报警', '图文报警')], string='报警方式') + alarm_way = fields.Selection([('文本提示报警', '文本提示报警'), ('声光报警', '声光报警'), ('图文报警', '图文报警')], + string='报警方式') fault_process = fields.Text(string='故障处理方法') operator = fields.Many2one('res.users', string='处理人') recovery_time = fields.Datetime(string='复原时间') fault_duration = fields.Float(string='故障时长') note = fields.Text(string='备注') - - diff --git a/sf_maintenance/models/sf_maintenance_requests.py b/sf_maintenance/models/sf_maintenance_requests.py index 330c1ece..4c9e8fde 100644 --- a/sf_maintenance/models/sf_maintenance_requests.py +++ b/sf_maintenance/models/sf_maintenance_requests.py @@ -12,7 +12,7 @@ class SfMaintenanceEquipmentCategory(models.Model): sf_maintenance_type = fields.Selection([('保养', '保养'), ('检修', '检修')], string='维保类别', default='保养') equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准', - domain="[('maintenance_type','=',sf_maintenance_type)]") + domain="[('maintenance_type','=',sf_maintenance_type)]") @api.onchange('sf_maintenance_type') def _compute_equipment_maintenance_request_id(self): @@ -38,8 +38,3 @@ class SfMaintenanceEquipmentCategory(models.Model): def confirm_maintenance_done(self): self.write({'stage_id': 3}) - - - - - diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 435e291c..ff0b6e73 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -52,11 +52,13 @@ + +

@@ -34,8 +69,9 @@

- - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -122,18 +129,24 @@ - - - - - + + + + + + + + - - - - - + + + + + + + + @@ -148,23 +161,36 @@ sf.functional.cutting.tool.entity - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + + +
- + 功能刀具列表 ir.actions.act_window sf.functional.cutting.tool.entity @@ -172,152 +198,59 @@ - + sf.functional.tool.warning.tree sf.functional.tool.warning - - + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - sf.functional.tool.warning.form - sf.functional.tool.warning - - - -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- sf.functional.tool.warning.search sf.functional.tool.warning - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + + @@ -327,16 +260,16 @@ 功能刀具预警 ir.actions.act_window sf.functional.tool.warning - tree,form,search + tree,search - + 功能刀具实时分布 sf.real.time.distribution.of.functional.tools - + @@ -365,7 +298,7 @@ 功能刀具实时分布 sf.real.time.distribution.of.functional.tools -
+

@@ -487,140 +420,47 @@ - + 功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools + stock.move.line - - - - - - - - - - - - - + + + + + + + + + + + - - 功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools - - - -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
功能刀具出入库记录 - sf.inbound.and.outbound.records.of.functional.tools + stock.move.line - + + - - - - - - - - - - - + + + + + + + + - + @@ -629,113 +469,109 @@ 功能刀具出入库记录 ir.actions.act_window - sf.inbound.and.outbound.records.of.functional.tools - tree,form,search + stock.move.line + tree,search + + + [('functional_tool_name_id', '!=', False)] - - - 出入库记录 - sf.inbound.and.outbound.records - - - - - - - - - - - - - - - - - 出入库记录 - sf.inbound.and.outbound.records - -
- - - - - - - - - - - - - - - - - - -
-
-
- - - 出入库记录 - ir.actions.act_window - sf.inbound.and.outbound.records - tree,form - - - - + 机床换刀申请 sf.machine.table.tool.changing.apply - - - - - + + + + + - - - + + + + + + + - - - + + + + + + + + +

+ - - - + + + - - - - - - - + - + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +
- +
- +
- +
- +
@@ -1164,7 +1059,7 @@
- +
@@ -1178,7 +1073,7 @@
- +
@@ -1191,34 +1086,36 @@
-
+
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - @@ -1236,24 +1133,31 @@
- + sf.functional.tool.assembly - - - - - - - + + + + + + + + + + - - - + + + + + + + diff --git a/sf_tool_management/wizard/__init__.py b/sf_tool_management/wizard/__init__.py index 20a7f5c4..40272379 100644 --- a/sf_tool_management/wizard/__init__.py +++ b/sf_tool_management/wizard/__init__.py @@ -1 +1 @@ -from . import wizard \ No newline at end of file +from . import wizard diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 53d7f28a..d667ba33 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -1,3 +1,5 @@ +from datetime import timedelta + from odoo import fields, models, api from odoo.exceptions import ValidationError @@ -6,75 +8,90 @@ class ToolChangeRequirementInformation(models.TransientModel): _name = 'sf.tool.change.requirement.information' _description = '换刀需求信息' - # tool_change_to_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', string='机床换刀申请') + name = fields.Char('名称', related='maintenance_equipment_id.name', store=True, readonly=True) + maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', readonly=True) + production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=True) + machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True) + machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True) - name = fields.Many2one('maintenance.equipment', string='CNC机床', readonly=True) - machine_tool_code = fields.Char(string='机台号', readonly=True) - cutter_spacing_code = fields.Char(string='刀位号', readonly=True) - # functional_tool_code = fields.Char(string='功能刀具编码', readonly=True) barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) + functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True) + tool_position_interface_type = fields.Selection( + [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), + ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), + ('直装固定式', '直装固定式')], string='刀位接口型号', readonly=True) + diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) + max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) + alarm_value = fields.Integer(string='报警值(min)', readonly=True) + used_value = fields.Integer(string='已使用值(min)', readonly=True) + whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True) + extension_length = fields.Float(string='伸出长(mm)', readonly=True) + effective_length = fields.Float(string='有效长(mm)', readonly=True) - # replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True) - replacement_tool_name_id = fields.Many2one('product.product', string='待换功能刀具名称', - domain=[('name', '=', '功能刀具')]) + # 待换功能刀具信息 + replacement_tool_name = fields.Char(string='待换功能刀具名称', required=True) replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型') + replacement_diameter = fields.Integer(string='待换刀具直径(mm)') + replacement_knife_tip_r_angle = fields.Float(string='待换刀具刀尖R角(mm)') + replacement_tool_setting_length = fields.Float(string='待换刀具装刀长(mm)') + replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)') + replacement_effective_length = fields.Float(string='待换刀具有效长(mm)') replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], - string='粗/中/精') - new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧') - applicant = fields.Char(string='申请人', default=lambda self: self.env.user.name, readonly=True) - used_tool_time = fields.Datetime(string='用刀时间') - reason_for_applying = fields.Char(string='申请原因') - remark = fields.Char(string='备注说明') + string='待换刀具粗/中/精', default='3') + replacement_max_lifetime_value = fields.Integer(string='待换刀具最大寿命值(min)') + replacement_alarm_value = fields.Integer(string='待换刀具报警值(min)') + replacement_used_value = fields.Integer(string='待换刀具已使用值(min)') + new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', default='0') + replacement_whether_standard_knife = fields.Boolean(string='待换刀具是否标准刀', default=True) + used_tool_time = fields.Datetime(string='用刀时间', + default=lambda self: fields.Datetime.now() + timedelta(hours=4)) + applicant = fields.Char(string='申请人', default=lambda self: self.env.user.name, readonly=True) + reason_for_applying = fields.Char(string='申请原因') def tool_changing_apply(self): """ 确认换刀申请(按键) :return: """ - # 将数据更新到机台换刀申请界面 print('已运行') record = self.env['sf.machine.table.tool.changing.apply'].search( - [('name', '=', self.name.id), - ('machine_tool_code', '=', self.machine_tool_code), - ('cutter_spacing_code', '=', self.cutter_spacing_code), + [('maintenance_equipment_id', '=', self.maintenance_equipment_id.id), + ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id) ]) print('运行record_1') + # 功能刀具组装创建新任务(new_assembly_task) - record_1 = self.env['sf.functional.tool.assembly'].sudo().create({ - 'functional_tool_name_id': self.replacement_tool_name_id.id, + sf_functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().create({ + 'functional_tool_name': self.replacement_tool_name, 'functional_tool_type_id': self.replacement_tool_type_id.id, - 'loading_task_source': '1', - 'applicant': self.applicant, - 'reason_for_applying': self.reason_for_applying, - 'use_tool_time': self.used_tool_time, - 'machine_tool_name_id': self.name.id, - 'machine_tool_code': self.machine_tool_code, - 'cutter_spacing_code': self.cutter_spacing_code, - 'sf_machine_table_tool_changing_apply_id': record.id, - }) - print('record_1:', record_1) - # 封装数据 - desc = { - 'name': self.name.id, - 'assembly_order_code': record_1.assembly_order_code, - 'machine_tool_code': self.machine_tool_code, - 'cutter_spacing_code': self.cutter_spacing_code, - 'replacement_tool_name_id': self.replacement_tool_name_id.id, - 'replacement_tool_type_id': self.replacement_tool_type_id.id, - 'replacement_tool_coarse_middle_thin': self.replacement_tool_coarse_middle_thin, + 'functional_tool_diameter': self.replacement_diameter, + 'knife_tip_r_angle': self.replacement_knife_tip_r_angle, + 'coarse_middle_thin': self.replacement_tool_coarse_middle_thin, 'new_former': self.new_former, + 'tool_loading_length': self.replacement_tool_setting_length, + 'functional_tool_length': self.replacement_extension_length, + 'effective_length': self.replacement_effective_length, + 'loading_task_source': '1', + 'use_tool_time': self.used_tool_time, + 'production_line_name_id': self.production_line_id.id, + 'machine_tool_name_id': self.maintenance_equipment_id.id, 'applicant': self.applicant, - 'used_tool_time': self.used_tool_time, + 'apply_time': fields.Datetime.now(), + 'cutter_spacing_code_id': self.cutter_spacing_code_id.id, + 'whether_standard_knife': self.whether_standard_knife, 'reason_for_applying': self.reason_for_applying, - 'remark': self.new_former, + 'sf_machine_table_tool_changing_apply_id': record.id + }) + print('sf_functional_tool_assembly:', sf_functional_tool_assembly) + # 修改机床换刀申请状态 + record.write({ 'status': '1', - 'sf_functional_tool_assembly_id': record_1.id, - } - print('运行record.write(desc):') - record.write(desc) + 'sf_functional_tool_assembly_id': sf_functional_tool_assembly + }) print('运行成功') # 关闭弹出窗口 @@ -85,18 +102,35 @@ class ToolTransferRequestInformation(models.TransientModel): _name = 'sf.tool.transfer.request.information' _description = '刀具转移申请信息' - CNC_machine_table_id = fields.Many2one('sf.machine_tool', string='CNC机床', readonly=True) - machine_tool_code = fields.Char(string='机台号', readonly=True) - cutter_spacing_code = fields.Char(string='刀位号', readonly=True) - # functional_tool_code = fields.Char(string='功能刀具编码', readonly=True) + name = fields.Char('名称', related='maintenance_equipment_id.name', store=True, readonly=True) + maintenance_equipment_id = fields.Many2one('maintenance.equipment', string='CNC机床', readonly=True) + production_line_id = fields.Many2one('sf.production.line', string='生产线', readonly=True) + machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True) + machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True) + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) + functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True) + tool_position_interface_type = fields.Selection( + [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), + ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), + ('直装固定式', '直装固定式')], string='刀位接口型号', readonly=True) + diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) + max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) + alarm_value = fields.Integer(string='报警值(min)', readonly=True) + used_value = fields.Integer(string='已使用值(min)', readonly=True) + whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True) + extension_length = fields.Float(string='伸出长(mm)', readonly=True) + effective_length = fields.Float(string='有效长(mm)', readonly=True) + + # 转移刀具信息 transfer_target = fields.Selection([('机台', '机台'), ('线边刀库', '线边刀库'), ('刀具房', '刀具房')], string='转移到:', default='线边刀库') - new_cnc_machine_table_id = fields.Many2one('sf.machine_tool', string='机床名称') + new_production_line_id = fields.Many2one('sf.production.line', string='目标生产线') new_machine_tool_code = fields.Char(string='机床号') new_cutter_spacing_code = fields.Char(string='目标刀位号') @@ -120,27 +154,41 @@ class FunctionalToolAssemblyOrder(models.TransientModel): _inherit = ["barcodes.barcode_events_mixin"] _description = '功能刀具组装单' - # 功能刀具申请信息 - machine_tool_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=True) + assembly_order_code = fields.Char(string='编码', readonly=True) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具', readonly=True) + functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, + group_expand='_read_group_functional_tool_type_ids') + functional_tool_diameter = fields.Integer(string='功能刀具直径(mm)', readonly=True) + knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) + new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) + tool_loading_length = fields.Float(string='装刀长(mm)', readonly=True) + functional_tool_length = fields.Float(string='伸出长(mm)', readonly=True) + effective_length = fields.Float(string='有效长(mm)', readonly=True) + loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')], + string='装刀任务来源', readonly=True) + use_tool_time = fields.Datetime(string='用刀时间', readonly=True) + production_line_name_id = fields.Many2one('sf.production.line', string='申请产线', readonly=True) + machine_tool_name_id = fields.Many2one('maintenance.equipment', string='申请机台', readonly=True) machine_tool_code = fields.Char(string='机台号', readonly=True) - cutter_spacing_code = fields.Char(string='刀位号', readonly=True) - # code = fields.Char(string='功能刀具编码', readonly=True) - barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) - functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) - functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True) - functional_tool_length = fields.Char(string='功能刀具伸出长(mm)', readonly=True) - effective_length = fields.Char(string='有效长(mm)', readonly=True) - functional_tool_diameter = fields.Char(string='功能刀具直径(mm)', readonly=True) - tool_included_angle = fields.Char(string='刀尖角(R角)', readonly=True) - functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=True) - required_cutting_time = fields.Char(string='需切削时长', readonly=True) - whether_standard_tool = fields.Boolean(string='是否标准刀', readonly=True) + applicant = fields.Char(string='申请人', readonly=True) + apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True) + assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0', + readonly=True) + cutter_spacing_code_id = fields.Many2one('maintenance.equipment.tool', string='刀位号', readonly=True) + whether_standard_knife = fields.Boolean(string='是否标准刀', default=True, readonly=True) + reason_for_applying = fields.Char(string='申请原因', readonly=True) + max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) + alarm_value = fields.Integer(string='报警值(min)', readonly=True) + used_value = fields.Integer(string='已使用值(min)', readonly=True) # 功能刀具组装信息 # 整体式刀具型号 integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具')]) - cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', readonly=True) + cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', + readonly=True) integral_name = fields.Char('整体式刀具名称', readonly=True) sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True) @@ -154,28 +202,32 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 刀杆型号 bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆')]) - cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', readonly=True) + cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', + readonly=True) bar_name = fields.Char('刀杆名称', readonly=True) sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True) # 刀盘型号 pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘')]) - cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', readonly=True) + cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', + readonly=True) pad_name = fields.Char('刀盘名称', readonly=True) sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True) # 刀柄型号 - handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', + handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', required=True, domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄')]) - cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', readonly=True) + cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', + readonly=True) handle_name = fields.Char('刀柄名称', readonly=True) sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True) # 夹头型号 - chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', + chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', required=True, domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')]) - cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', readonly=True) + cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', + readonly=True) chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill') sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) @@ -256,86 +308,67 @@ class FunctionalToolAssemblyOrder(models.TransientModel): record.chuck_name = None record.sf_tool_brand_id_6 = None - coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', default='1') - tool_loading_length = fields.Char(string='装刀长') - new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', required=True, default='0') - reference_length = fields.Char(string='参考伸出长') - cut_time = fields.Char(string='已切削时间') - cut_length = fields.Char(string='已切削长度') - cut_number = fields.Char(string='已切削次数') + # 组装功能刀具参数信息 + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号') + after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', required=True) + after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', + string='组装后功能刀具类型') + after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)') + after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)') + after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧') + cut_time = fields.Integer(string='已切削时间(min)') + cut_length = fields.Float(string='已切削长度(mm)') + cut_number = fields.Integer(string='已切削次数') + + after_assembly_whether_standard_knife = fields.Boolean(string='组装后是否标准刀', default=True) + after_assembly_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], + string='组装后粗/中/精') + after_assembly_max_lifetime_value = fields.Integer(string='组装后最大寿命值(min)') + after_assembly_alarm_value = fields.Integer(string='组装后报警值(min)') + after_assembly_used_value = fields.Integer(string='组装后已使用值(min)') + after_assembly_tool_loading_length = fields.Float(string='组装后装刀长(mm)') + after_assembly_functional_tool_length = fields.Float(string='组装后伸出长(mm)') + after_assembly_effective_length = fields.Float(string='组装后有效长(mm)') + L_D_number = fields.Float(string='L/D值(mm)') + hiding_length = fields.Float(string='避空长(mm)') + + functional_tool_cutting_type = fields.Char(string='功能刀具切削类型', readonly=False) def functional_tool_assembly(self): """ 功能刀具组装 :return: """ - # 创建组装入库单 - # 创建功能刀具批次/序列号记录 - stock_lot = self.create_assemble_warehouse_receipt() - # 创建刀具组装入库单 - self.create_stocking_picking(stock_lot) - desc_1 = { - 'barcode_id': stock_lot.id, - 'integral_code_id': self.integral_code_id.id, - 'blade_code_id': self.blade_code_id.id, - 'bar_code_id': self.bar_code_id.id, - 'pad_code_id': self.pad_code_id.id, - 'handle_code_id': self.handle_code_id.id, - 'chuck_code_id': self.chuck_code_id.id, - 'coarse_middle_thin': self.coarse_middle_thin, - 'tool_loading_length': self.tool_loading_length, - 'new_former': self.new_former, - 'reference_length': self.reference_length, - 'cut_time': self.cut_time, - 'cut_length': self.cut_length, - 'cut_number': self.cut_number, - 'assemble_status': '1', - 'tool_loading_person': self.env.user.name, - 'tool_loading_time': fields.Datetime.now() - } functional_tool_assembly = self.env['sf.functional.tool.assembly'].search([ + ('assembly_order_code', '=', self.assembly_order_code), ('machine_tool_name_id', '=', self.machine_tool_name_id.id), - ('cutter_spacing_code', '=', self.cutter_spacing_code), + ('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id), ('assemble_status', '=', '0'), ]) + # 对物料做必填判断 + self.materials_must_be_judged() + + # 创建组装入库单 + # 创建功能刀具批次/序列号记录 + stock_lot = self.create_assemble_warehouse_receipt(functional_tool_assembly) + # 创建刀具组装入库单 + self.create_stocking_picking(stock_lot) # 封装功能刀具数据 - desc_2 = { - 'barcode_id': stock_lot.id, - 'functional_tool_name_id': self.functional_tool_name_id.id, - 'mrs_cutting_tool_type_id': self.functional_tool_type_id.id, - 'cutting_tool_integral_model_id': self.integral_code_id.product_id.id, - 'cutting_tool_blade_model_id': self.blade_code_id.product_id.id, - 'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id, - 'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id, - 'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id, - 'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id, - 'diameter': self.functional_tool_diameter, - 'tool_grade': None, - 'machining_accuracy': None, - 'tool_length': self.tool_loading_length, - 'blade_number': None, - 'integral_blade_length': None, - 'effective_blade_length': self.effective_length, - 'max_life': None, - 'is_standard': self.whether_standard_tool, - 'applicable_range': None, - 'image': None, - } + desc_1 = self.get_desc_1(stock_lot) + + # 创建功能刀具列表记录 + # 封装功能刀具数据 + desc_2 = self.get_desc_2(stock_lot, functional_tool_assembly) # 创建功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录 record_1 = self.env['sf.functional.cutting.tool.entity'].create(desc_2) - self.env['sf.functional.tool.warning'].create({ - 'functional_cutting_tool_id': record_1.id, - 'functional_tool_assembly_id': functional_tool_assembly.id, - 'machine_table_name_id': self.machine_tool_name_id.id, - }) - self.env['sf.real.time.distribution.of.functional.tools'].create({ - 'functional_cutting_tool_id': record_1.id - }) - self.env['sf.inbound.and.outbound.records.of.functional.tools'].create({ - 'functional_cutting_tool_id': record_1.id - }) + # self.env['sf.real.time.distribution.of.functional.tools'].create({ + # 'functional_cutting_tool_id': record_1.id + # }) + # self.env['sf.inbound.and.outbound.records.of.functional.tools'].create({ + # 'functional_cutting_tool_id': record_1.id + # }) - # 修改功能刀具组装信息 + # 修改功能刀具组装单信息 functional_tool_assembly.write(desc_1) if functional_tool_assembly.sf_machine_table_tool_changing_apply_id: @@ -352,6 +385,16 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 关闭弹出窗口 return {'type': 'ir.actions.act_window_close'} + def materials_must_be_judged(self): + """ + 功能刀具组装物料必填判断 + """ + if not self.integral_code_id and not self.blade_code_id: + raise ValidationError('【整体式刀具】和【刀片】必须填写一个!') + if self.blade_code_id: + if not self.bar_code_id and not self.pad_code_id: + raise ValidationError('【刀盘】和【刀杆】必须填写一个!') + def create_stocking_picking(self, stock_lot): """ 创建刀具组装入库单 @@ -371,7 +414,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 将刀具组装入库单的状态更改为就绪 picking_id.action_confirm() - def create_assemble_warehouse_receipt(self): + def create_assemble_warehouse_receipt(self, functional_tool_assembly): """ 创建功能刀具批次/序列号记录 """ @@ -383,11 +426,11 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'company_id': self.env.company.id }) # 创建功能刀具该批次/序列号 库存移动和移动历史 - self.create_stock_quant(product_id, stock_lot) + self.create_stock_quant(product_id, stock_lot, functional_tool_assembly) return stock_lot - def create_stock_quant(self, product_id, stock_lot): + def create_stock_quant(self, product_id, stock_lot, functional_tool_assembly): """ 创建功能刀具该批次/序列号 库存移动和移动历史 """ @@ -397,7 +440,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 创建库存移动 stock_move_id = self.env['stock.move'].create({ - 'name': '更新的产品数量', + 'name': '功能刀具组装出库', 'product_id': product_id.id, 'location_id': location_inventory_id.id, 'location_dest_id': stock_location_id.id, @@ -408,12 +451,13 @@ class FunctionalToolAssemblyOrder(models.TransientModel): # 创建移动历史 stock_move_line_id = self.env['stock.move.line'].create({ 'product_id': product_id.id, + 'functional_tool_name_id': functional_tool_assembly.id, 'lot_id': stock_lot.id, 'move_id': stock_move_id.id, + 'install_tool_time': fields.Datetime.now(), 'qty_done': 1.0, 'state': 'done' }) - return stock_move_id, stock_move_line_id def get_stock_lot_name(self): @@ -433,4 +477,69 @@ class FunctionalToolAssemblyOrder(models.TransientModel): else: m = int(stock_lot_id.name[-3:]) + 1 num = "%03d" % m - return code + str(num) \ No newline at end of file + return code + str(num) + + def get_desc_1(self, stock_lot): + return { + 'barcode_id': stock_lot.id, + 'integral_code_id': self.integral_code_id.id, + 'blade_code_id': self.blade_code_id.id, + 'bar_code_id': self.bar_code_id.id, + 'pad_code_id': self.pad_code_id.id, + 'handle_code_id': self.handle_code_id.id, + 'chuck_code_id': self.chuck_code_id.id, + + 'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name, + 'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id, + 'after_assembly_functional_tool_diameter': self.after_assembly_functional_tool_diameter, + 'after_assembly_knife_tip_r_angle': self.after_assembly_knife_tip_r_angle, + 'after_assembly_new_former': self.after_assembly_new_former, + 'cut_time': self.cut_time, + 'cut_length': self.cut_length, + 'cut_number': self.cut_number, + 'after_assembly_whether_standard_knife': self.after_assembly_whether_standard_knife, + 'after_assembly_coarse_middle_thin': self.after_assembly_coarse_middle_thin, + 'after_assembly_max_lifetime_value': self.after_assembly_max_lifetime_value, + 'after_assembly_alarm_value': self.after_assembly_alarm_value, + 'after_assembly_used_value': self.after_assembly_used_value, + 'after_assembly_tool_loading_length': self.after_assembly_tool_loading_length, + 'after_assembly_functional_tool_length': self.after_assembly_functional_tool_length, + 'after_assembly_effective_length': self.after_assembly_effective_length, + 'L_D_number': self.L_D_number, + 'hiding_length': self.hiding_length, + 'assemble_status': '1', + 'tool_loading_person': self.env.user.name, + 'tool_loading_time': fields.Datetime.now() + } + + def get_desc_2(self, stock_lot, functional_tool_assembly_id): + return { + 'barcode_id': stock_lot.id, + 'functional_tool_name_id': functional_tool_assembly_id.id, + 'sf_cutting_tool_type_id': self.after_assembly_functional_tool_type_id.id, + 'cutting_tool_integral_model_id': self.integral_code_id.product_id.id, + 'cutting_tool_blade_model_id': self.blade_code_id.product_id.id, + 'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id, + 'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id, + 'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id, + 'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id, + + 'functional_tool_diameter': self.after_assembly_functional_tool_diameter, + 'knife_tip_r_angle': self.after_assembly_knife_tip_r_angle, + 'coarse_middle_thin': self.after_assembly_coarse_middle_thin, + 'new_former': self.after_assembly_new_former, + 'tool_loading_length': self.after_assembly_tool_loading_length, + 'functional_tool_length': self.after_assembly_functional_tool_length, + 'effective_length': self.after_assembly_effective_length, + + 'max_lifetime_value': self.after_assembly_max_lifetime_value, + 'alarm_value': self.after_assembly_alarm_value, + 'used_value': self.after_assembly_used_value, + 'whether_standard_knife': self.after_assembly_whether_standard_knife, + 'L_D_number': self.L_D_number, + 'hiding_length': self.hiding_length, + 'cut_time': self.cut_time, + 'cut_length': self.cut_length, + 'cut_number': self.cut_number, + 'current_location_id': stock_lot.quant_ids.location_id.ids[-1], + } diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index a6c6ec7b..35db780f 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -1,46 +1,68 @@ - + - 换刀需求信息 - sf.tool.change.requirement.information - - - - - - - - - - - - - - - - + 换刀需求信息 + sf.tool.change.requirement.information + + + +
+

+ +

+
+ + + + + + + + + + - - - - - - - - - - - - + + + + + + + + -
-
-
- -
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
@@ -53,54 +75,71 @@ - + - 刀具转移申请信息 - sf.tool.transfer.request.information - -
- - - - - - - - - - - - - - - - - - - - - - - + 刀具转移申请信息 + sf.tool.transfer.request.information + + + +
+

+ +

+
+ + + + + + + + + + - - - - - - - - - + + + + + + + -
-
-
- -
+
+ + + + + + + + + + + + + + + + + +
+
+
+ +
@@ -113,187 +152,215 @@ - + - 功能刀具组装单 - sf.functional.tool.assembly.order - -
- - + 功能刀具组装单 + sf.functional.tool.assembly.order + + + +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
- - - - - - + + + - - - - - - - + + + + + + + + + + - - - -
- -
+ +
+ +
+ - - - - - - - - - - - - - - + - -
- -
+ - - - + - - - - - - - - - - + + + + + - -
- -
+
+ +
+ +
+ - - - - - - - - - - - - - - + - -
- -
+ - - - + - - - - - - - - - - + + + + + - -
- -
+
+ +
+ +
+ - - - - - - - - - - - - - - + - -
- -
+ - - - + - - - - - - - - - - + + + + + - +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+
- - - - - - - - - - - - + + + + + + + + + + + -
-
-
- -
+ + + + + + + + + + + + +
+
+
+
+ +
diff --git a/sf_warehouse/static/src/js/cust_char.js b/sf_warehouse/static/src/js/cust_char.js index 5aa43927..3757bfb8 100644 --- a/sf_warehouse/static/src/js/cust_char.js +++ b/sf_warehouse/static/src/js/cust_char.js @@ -16,7 +16,7 @@ class CustomChar extends CharField { onMounted() { super.onMounted(); - console.log('CustomChar.onMounted1'); + // console.log('CustomChar.onMounted1'); // 当光标聚焦于输入框时,选中输入框内容 this.input.el.addEventListener('focus', function () { this.select(); diff --git a/sf_warehouse/static/src/js/custom_many2one.js b/sf_warehouse/static/src/js/custom_many2one.js index beb4783e..c6a86af5 100644 --- a/sf_warehouse/static/src/js/custom_many2one.js +++ b/sf_warehouse/static/src/js/custom_many2one.js @@ -14,11 +14,11 @@ class CustomMany2One extends Many2OneField { * @returns {Promise} */ setup() { - console.log('CustomMany2One.setup11111111111111'); + // console.log('CustomMany2One.setup11111111111111'); super.setup(); } onMounted() { - console.log('CustomMany2One.onMounted1'); + // console.log('CustomMany2One.onMounted1'); // 当光标聚焦于输入框时,选中输入框内容 this.input.el.addEventListener('focus', function () { this.select(); diff --git a/web_widget_model_viewer/static/src/js/3d_viewer.js b/web_widget_model_viewer/static/src/js/3d_viewer.js index 9d3afd50..3c66b142 100644 --- a/web_widget_model_viewer/static/src/js/3d_viewer.js +++ b/web_widget_model_viewer/static/src/js/3d_viewer.js @@ -5,10 +5,10 @@ import {_lt} from "@web/core/l10n/translation"; import {standardFieldProps} from "@web/views/fields/standard_field_props"; import {session} from "@web/session"; -import core from 'web.core'; +// import core from 'web.core'; -var QWeb = core.qweb; +// var QWeb = core.qweb; import {Component} from "@odoo/owl"; @@ -42,8 +42,8 @@ export class StepViewer extends Component { // url = "web_widget_model_viewer/static/src/images/not_model.png"; } } else { - var oImg = document.getElementsByClassName('test')[0] - console.log(oImg) + // var oImg = document.getElementsByClassName('test')[0] + // console.log(oImg) } } } diff --git a/yizuo_login_background_and_styles/__manifest__.py b/yizuo_login_background_and_styles/__manifest__.py index 805bb0c8..4f0990bd 100644 --- a/yizuo_login_background_and_styles/__manifest__.py +++ b/yizuo_login_background_and_styles/__manifest__.py @@ -25,4 +25,3 @@ 'application': True, 'images': ['static/description/banner.png'], } - diff --git a/yizuo_login_background_and_styles/models/res_config_settings.py b/yizuo_login_background_and_styles/models/res_config_settings.py index e891ae0e..66394f9e 100644 --- a/yizuo_login_background_and_styles/models/res_config_settings.py +++ b/yizuo_login_background_and_styles/models/res_config_settings.py @@ -5,8 +5,10 @@ from odoo import api, fields, models, modules class ResConfigSettings(models.TransientModel): _inherit = 'res.config.settings' - style = fields.Selection([('default', 'Default'), ('left', 'Left'), ('right', 'Right'), ('middle', 'Middle')], help='Select Background Theme') - background = fields.Selection([('image', 'Image'), ('color', 'Color')], default='color', help='Select Background Theme') + style = fields.Selection([('default', 'Default'), ('left', 'Left'), ('right', 'Right'), ('middle', 'Middle')], + help='Select Background Theme') + background = fields.Selection([('image', 'Image'), ('color', 'Color')], default='color', + help='Select Background Theme') background_image = fields.Many2one('login.image', string="Image", help='Select Background Image For Login Page') color = fields.Char(string="Color", help="Choose your Background color") diff --git a/zpl_print/controllers/__init__.py b/zpl_print/controllers/__init__.py index 7603d325..4258f7c5 100644 --- a/zpl_print/controllers/__init__.py +++ b/zpl_print/controllers/__init__.py @@ -1,2 +1,2 @@ # -*-coding:utf-8-*- -from .import report \ No newline at end of file +from . import report diff --git a/zpl_print/models/__init__.py b/zpl_print/models/__init__.py index fbbb6c49..cb5da77d 100644 --- a/zpl_print/models/__init__.py +++ b/zpl_print/models/__init__.py @@ -1,2 +1,2 @@ # -*-coding:utf-8-*- -from .import common \ No newline at end of file +from . import common diff --git a/zpl_print/models/common.py b/zpl_print/models/common.py index 762af3b0..c10d5a74 100644 --- a/zpl_print/models/common.py +++ b/zpl_print/models/common.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from odoo import models import ctypes +from odoo import models class Common(models.Model): @@ -19,6 +19,3 @@ class Common(models.Model): tsclibrary.closeport(); except Exception as e: raise UserWarning("错误警告") - - -