diff --git a/sf_base/models/base.py b/sf_base/models/base.py index f6a945aa..c679ac74 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -267,7 +267,7 @@ class MachineToolType(models.Model): ('youyagang', '油压缸驱动'), ('chilunjia', '齿轮架驱动') ], string="主轴加高方式", default='sifudianji') - workpiece_load = fields.Char('工件负载') + workpiece_load = fields.Char('工件最大负载(kg)') lead_screw = fields.Char('丝杆') workbench_L = fields.Char('工作台长度(mm)') workbench_W = fields.Char('工作台宽度(mm)') @@ -276,14 +276,16 @@ class MachineToolType(models.Model): machine_tool_W = fields.Char('机床宽度(mm)') machine_tool_H = fields.Char('机床高度(mm)') feed_speed = fields.Char('进给速度(mm/min)') - tool_speed = fields.Char('刀具速度') - distance = fields.Char('主轴端面至工作台面距离(mm)') + tool_speed = fields.Char('刀具速度(m/min)') + distance_min = fields.Char('主轴端面至工作台面距离MIN(mm)') + distance_max = fields.Char('主轴端面至工作台面距离MIN(mm)') taper = fields.Char('主轴锥度(°)') torque = fields.Char('主轴点击扭矩(n/m)') motor_power = fields.Char('主轴电机功率(kw)') - tool_quality_max = fields.Char('刀具最大质量') - tool_long_max = fields.Char('刀具最大长度') - tool_diameter_max = fields.Char('刀具最大刀径') + tool_quality_max = fields.Char('刀具最大质量(kg)') + tool_long_max = fields.Char('刀具最大长度(mm)') + tool_diameter_max = fields.Char('刀具刀径max(mm)') + tool_diameter_min = fields.Char('刀具刀径min(mm)') machine_tool_category = fields.Many2one('sf.machine_tool.category', string='机床类型') # 多个型号对应一个机床 @@ -298,7 +300,8 @@ class MachineToolType(models.Model): b_axis = fields.Integer('B轴') c_axis = fields.Integer('C轴') remark = fields.Char('备注') - precision = fields.Float('加工精度') + precision_min = fields.Float('X轴定位精度min(mm)', digits=(12, 3)) + precision_max = fields.Float('X轴定位精度max(mm)', digits=(12, 3)) control_system_id = fields.Many2one('sf.machine.control_system', string="控制系统") active = fields.Boolean('有效', default=True) diff --git a/sf_base/static/src/scss/test.scss b/sf_base/static/src/scss/test.scss index 32aba96d..bb7d8929 100644 --- a/sf_base/static/src/scss/test.scss +++ b/sf_base/static/src/scss/test.scss @@ -4,4 +4,5 @@ .test_model>.o_form_label { margin-left: 20px; margin-right: 0px !important; + white-space: nowrap; } \ No newline at end of file diff --git a/sf_base/views/base_view.xml b/sf_base/views/base_view.xml index eadd81f2..6d10b4e9 100644 --- a/sf_base/views/base_view.xml +++ b/sf_base/views/base_view.xml @@ -87,7 +87,7 @@ tree.sf.machine_tool.type sf.machine_tool.type - + @@ -116,10 +116,10 @@ - + - + @@ -145,7 +145,16 @@ options="{'format': false}"/> - + + + + + + + + @@ -187,16 +196,32 @@ - - - + + + + + + + + - + + + + + + + + diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index a541185a..6b1d76f4 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -85,7 +85,8 @@ class SfMaintenanceEquipment(models.Model): c_axis = fields.Integer('C轴') remark = fields.Char('备注') is_binding = fields.Boolean('是否绑定机床', default=False) - precision = fields.Float('加工精度') + precision_min = fields.Float('X轴定位精度min(mm)', digits=(12, 3)) + precision_max = fields.Float('X轴定位精度max(mm)', digits=(12, 3)) control_system_id = fields.Many2one('sf.machine.control_system', string="控制系统") # 多个机床型号对应一个机床 @@ -102,7 +103,7 @@ class SfMaintenanceEquipment(models.Model): ('youyagang', '油压缸驱动'), ('chilunjia', '齿轮架驱动') ], string="主轴加高方式", default='sifudianji') - workpiece_load = fields.Char('工件负载') + workpiece_load = fields.Char('工件最大负载(kg)') lead_screw = fields.Char('丝杆') workbench_L = fields.Char('工作台长度(mm)') workbench_W = fields.Char('工作台宽度(mm)') @@ -111,14 +112,16 @@ class SfMaintenanceEquipment(models.Model): machine_tool_W = fields.Char('机床宽度(mm)') machine_tool_H = fields.Char('机床高度(mm)') feed_speed = fields.Char('进给速度(mm/min)') - tool_speed = fields.Char('刀具速度') - distance = fields.Char('主轴端面至工作台面距离(mm)') + tool_speed = fields.Char('刀具速度(m/min)') + distance_min = fields.Char('主轴端面至工作台面距离MIN(mm)') + distance_max = fields.Char('主轴端面至工作台面距离MIN(mm)') taper = fields.Char('主轴锥度(°)') torque = fields.Char('主轴点击扭矩(n/m)') motor_power = fields.Char('主轴电机功率(kw)') - tool_quality_max = fields.Char('刀具最大质量') - tool_long_max = fields.Char('刀具最大长度') - tool_diameter_max = fields.Char('刀具最大刀径') + tool_quality_max = fields.Char('刀具最大质量(kg)') + tool_long_max = fields.Char('刀具最大长度(mm)') + tool_diameter_max = fields.Char('刀具刀径max(mm)') + tool_diameter_min = fields.Char('刀具刀径min(mm)') machine_tool_category = fields.Many2one('sf.machine_tool.category', string='机床类型') # 一个机床对应一個加工工厂,一个加工工厂对应多个机床 factory_id = fields.Many2one('res.partner', string='所属工厂', @@ -132,20 +135,7 @@ class SfMaintenanceEquipment(models.Model): active = fields.Boolean('有效', default=True) # 多个型号对应一个机床 machine_tool_id = fields.Many2one('sf.machine_tool', '机床') - number_of_axles = fields.Selection( - [("三轴", "三轴"), ("四轴", "四轴"), ("五轴", "五轴")], - default="", string="轴数") - # 加工进程 - x_axis = fields.Integer('X轴') - y_axis = fields.Integer('Y轴') - z_axis = fields.Integer('Z轴') - b_axis = fields.Integer('B轴') - c_axis = fields.Integer('C轴') - remark = fields.Char('备注') - precision = fields.Float('加工精度') - control_system_id = fields.Many2one('sf.machine.control_system', - string="控制系统") - active = fields.Boolean('有效', default=True) + def name_get(self): result = [] @@ -208,7 +198,8 @@ class SfMaintenanceEquipment(models.Model): item.number_of_knife_library = item.type_id.number_of_knife_library item.number_of_axles = item.type_id.number_of_axles item.rotate_speed = item.type_id.rotate_speed - item.precision = item.type_id.precision + item.precision_min = item.type_id.precision_min + item.precision_max = item.type_id.precision_max item.control_system_id = item.type_id.control_system_id item.x_axis = item.type_id.x_axis item.y_axis = item.type_id.y_axis @@ -227,13 +218,15 @@ class SfMaintenanceEquipment(models.Model): item.machine_tool_H = item.type_id.machine_tool_H item.feed_speed = item.type_id.feed_speed item.tool_speed = item.type_id.tool_speed - item.distance = item.type_id.distance + item.distance_min = item.type_id.distance_min + item.distance_max = item.type_id.distance_max item.taper = item.type_id.taper item.torque = item.type_id.torque item.motor_power = item.type_id.motor_power item.tool_quality_max = item.type_id.tool_quality_max item.tool_long_max = item.type_id.tool_long_max item.tool_diameter_max = item.type_id.tool_diameter_max + item.tool_diameter_min = item.type_id.tool_diameter_min item.machine_tool_category = item.type_id.machine_tool_category.id item.brand_id = item.type_id.brand_id.id diff --git a/sf_maintenance/models/sf_maintenance_logs.py b/sf_maintenance/models/sf_maintenance_logs.py index f9a514f5..8c12529f 100644 --- a/sf_maintenance/models/sf_maintenance_logs.py +++ b/sf_maintenance/models/sf_maintenance_logs.py @@ -8,8 +8,8 @@ class SfMaintenanceLogs(models.Model): code = fields.Char(string='编码') name = fields.Char(string='名称') type = fields.Selection([('type1', '类型1'), ('type2', '类型2')], string='类型') - brand = fields.Char(string='品牌') - model = fields.Char(string='型号') + brand = fields.Many2one('sf.machine.brand', relared='model.brand_id', string='品牌') + model = fields.Many2one('maintenance.equipment', string='设备') code_location = fields.Char(string='编码位置') fault_type = fields.Selection([('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='故障类型') fault_code = fields.Char(string='故障代码') diff --git a/sf_maintenance/views/maintenance_logs_views.xml b/sf_maintenance/views/maintenance_logs_views.xml index d5cffdae..14ddd9e0 100644 --- a/sf_maintenance/views/maintenance_logs_views.xml +++ b/sf_maintenance/views/maintenance_logs_views.xml @@ -63,6 +63,9 @@ sf.maintenance.logs + + + diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index 3f23cd24..508325f1 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -38,107 +38,114 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 24a400a6..a3c2c70c 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -24,12 +24,33 @@ 'views/production_line_view.xml', 'views/tray_view.xml', 'views/model_type_view.xml', + # 'views/kanban_change.xml' ], + 'assets': { + + 'web.assets_qweb': [ + ], + + 'web.assets_backend': [ + 'sf_manufacturing/static/src/xml/kanban_change.xml', + 'sf_manufacturing/static/src/js/kanban_change.js', + 'sf_manufacturing/static/src/scss/kanban_change.scss' + ] + + }, 'demo': [ ], 'qweb': [ ], + 'assets': { + 'web.assets_backend': [ + 'sf_manufacturing/static/src/js/kanban_change.js', + 'sf_manufacturing/static/src/scss/kanban_change.scss', + 'sf_manufacturing/static/src/xml/kanban_change.xml', + ], + + }, 'license': 'LGPL-3', 'installable': True, 'application': False, diff --git a/sf_manufacturing/models/mrp_workcenter.py b/sf_manufacturing/models/mrp_workcenter.py index 7483d188..525c2f54 100644 --- a/sf_manufacturing/models/mrp_workcenter.py +++ b/sf_manufacturing/models/mrp_workcenter.py @@ -6,6 +6,9 @@ from odoo.addons.resource.models.resource import Intervals class ResWorkcenter(models.Model): _inherit = "mrp.workcenter" + + # 生产线显示 + production_line_show = fields.Char(string='生产线') equipment_id = fields.Many2one('maintenance.equipment', string='设备') machine_tool_id = fields.Many2one('sf.machine_tool', string='机床') production_line_id = fields.Many2one('sf.production.line', string='生产线') diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index b913ef78..7a61eb0d 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -154,6 +154,12 @@ class ResProductMo(models.Model): fixture_screw_size = fields.Integer(string="螺牙大小(mm)", size=6) # 注册状态 register_state = fields.Selection([('未注册', '未注册'), ('已注册', '已注册'),('注册失败','注册失败')], string='注册状态', default='未注册') + industry_code = fields.Char('行业编码', readonly=True) + + @api.onchange('brand_id') + def _onchange_brand_id(self): + if self.brand_id: + self.manufacturer_model_number = self.brand_id.manufacturer_model_number def _json_apply_machine_tool_type_item_code(self, item): code_arr = [] diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index bcf352c1..5ecd9146 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import base64 from collections import defaultdict, namedtuple from odoo.addons.stock.models.stock_rule import ProcurementException from odoo.addons.sf_base.commons.common import Common @@ -280,57 +281,14 @@ class StockPicking(models.Model): if picking_out.state != 'done': raise UserError( _('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % picking_out.name)) - # 采购单验证(夹具和刀具) - if self.product_id.categ_type in ['刀具', '夹具']: - self._register_fixture() - res = super().button_validate() - return res - # 将采购到的夹具注册到Cloud - def _register_fixture(self): - create_url = '/api/fixture/create' - config = self.env['res.config.settings'].get_values() - headers = Common.get_headers(self, config['token'], config['sf_secret_key']) - strurl = config['sf_url'] + create_url - for item in self: - val = { - 'token': config['token'], - 'name': item.name, - 'brand_code': self.env['sf.machine.brand'].search([('id', '=', item.product_id.brand_id.id)]).code, - 'manufacturer_model_number': item.product_id.manufacturer_model_number, - 'fixture_material_code': self.env['sf.fixture.material'].search( - [('id', '=', item.product_id.fixture_material_id.id)]).code, - 'fixture_multi_mounting_type_code': self.env['sf.multi_mounting.type'].search( - [('id', '=', item.product_id.fixture_multi_mounting_type_id.id)]).code, - 'fixture_materials_type_code': self.env['sf.materials.model'].search( - [('id', '=', item.product_id.materials_type_id.id)]).materials_no, - 'fixture_clamping_way': item.product_id.fixture_clamping_way, - 'fixture_port_type': item.product_id.fixture_port_type, - 'fixture_length': item.product_id.tool_length, - 'fixture_width': item.product_id.tool_width, - 'fixture_height': item.product_id.tool_height, - 'fixture_weight': item.product_id.tool_weight, - 'fixture_clamp_workpiece_length_max': item.product_id.fixture_clamp_workpiece_length_max, - 'fixture_clamp_workpiece_width_max': item.product_id.fixture_clamp_workpiece_width_max, - 'fixture_clamp_workpiece_height_max': item.product_id.fixture_clamp_workpiece_height_max, - 'fixture_clamp_workpiece_diameter_max': item.product_id.fixture_clamp_workpiece_diameter_max, - 'fixture_maximum_carrying_weight': item.product_id.fixture_maximum_carrying_weight, - 'fixture_maximum_clamping_force': item.product_id.fixture_maximum_clamping_force, - 'fixture_driving_way': item.product_id.fixture_driving_way, - 'fixture_apply_machine_tool_type_codes': self.env[ - 'product.template']._json_apply_machine_tool_type_item_code(item), - 'fixture_through_hole_size': item.product_id.fixture_through_hole_size, - 'fixture_screw_size': item.product_id.fixture_screw_size, - } - try: - ret = requests.post(strurl, json={}, data=val, headers=headers) - ret = ret.json() - if ret['status'] == 200: - item.product_id.write({'register_state': '已注册'}) - else: - item.product_id.write({'register_state': '注册失败'}) - except Exception as e: - raise UserError("注册夹具到云端失败,请联系管理员!") + res = super().button_validate() + # 采购单验证(夹具和刀具) + for item in self.move_ids_without_package: + if item.product_id.categ_type in ['刀具', '夹具']: + if item.quantity_done > 0: + item._register_fixture() + return res # 创建 外协出库入单 def create_outcontract_picking(self, sorted_workorders_arr, item): @@ -388,3 +346,58 @@ class ReStockMove(models.Model): 'location_dest_id': self.mapped('location_dest_id').id, 'state': 'confirmed', } + + # 将采购到的夹具注册到Cloud + def _register_fixture(self): + create_url = '/api/fixture/create' + config = self.env['res.config.settings'].get_values() + headers = Common.get_headers(self, config['token'], config['sf_secret_key']) + strurl = config['sf_url'] + create_url + for item in self: + val = { + 'token': config['token'], + 'name': item.product_id.name, + 'brand_code': self.env['sf.machine.brand'].search([('id', '=', item.product_id.brand_id.id)]).code, + 'manufacturer_model_number': item.product_id.manufacturer_model_number, + 'fixture_material_code': self.env['sf.fixture.material'].search( + [('id', '=', item.product_id.fixture_material_id.id)]).code, + 'fixture_multi_mounting_type_code': self.env['sf.multi_mounting.type'].search( + [('id', '=', item.product_id.fixture_multi_mounting_type_id.id)]).code, + 'fixture_materials_type_code': self.env['sf.materials.model'].search( + [('id', '=', item.product_id.materials_type_id.id)]).materials_no, + 'fixture_clamping_way': item.product_id.fixture_clamping_way, + 'fixture_port_type': item.product_id.fixture_port_type, + 'fixture_length': item.product_id.tool_length, + 'fixture_width': item.product_id.tool_width, + 'fixture_height': item.product_id.tool_height, + 'fixture_weight': item.product_id.tool_weight, + 'fixture_amount': int(item.quantity_done), + 'fixture_model_file': '' if not item.product_id.fixture_model_file else base64.b64encode( + item.product_id.fixture_model_file).decode( + 'utf-8'), + 'fixture_clamp_workpiece_length_max': item.product_id.fixture_clamp_workpiece_length_max, + 'fixture_clamp_workpiece_width_max': item.product_id.fixture_clamp_workpiece_width_max, + 'fixture_clamp_workpiece_height_max': item.product_id.fixture_clamp_workpiece_height_max, + 'fixture_clamp_workpiece_diameter_max': item.product_id.fixture_clamp_workpiece_diameter_max, + 'fixture_maximum_carrying_weight': item.product_id.fixture_maximum_carrying_weight, + 'fixture_maximum_clamping_force': item.product_id.fixture_maximum_clamping_force, + 'fixture_driving_way': '' if not item.product_id.fixture_driving_way else item.product_id.fixture_driving_way, + 'fixture_apply_machine_tool_type_codes': self.env[ + 'product.template']._json_apply_machine_tool_type_item_code(item), + 'fixture_through_hole_size': item.product_id.fixture_through_hole_size, + 'fixture_screw_size': item.product_id.fixture_screw_size, + } + try: + if item.product_id.industry_code: + val['industry_code'] = item.product_id.industry_code + ret = requests.post(strurl, json={}, data=val, headers=headers) + ret = ret.json() + if ret['status'] == 200: + if not item.product_id.industry_code: + item.product_id.write({'register_state': '已注册', 'industry_code': ret['industry_code']}) + else: + item.product_id.write({'register_state': '已注册'}) + else: + item.product_id.write({'register_state': '注册失败'}) + except Exception as e: + raise UserError("注册夹具到云端失败,请联系管理员!") diff --git a/sf_manufacturing/static/src/js/kanban_change.js b/sf_manufacturing/static/src/js/kanban_change.js new file mode 100644 index 00000000..b4f35051 --- /dev/null +++ b/sf_manufacturing/static/src/js/kanban_change.js @@ -0,0 +1,78 @@ +/** @odoo-module */ + +import { KanbanController } from "@web/views/kanban/kanban_controller"; +import { kanbanView } from "@web/views/kanban/kanban_view"; +import { registry } from "@web/core/registry"; + +// the controller usually contains the Layout and the renderer. +class CustomKanbanController extends KanbanController { + // Your logic here, override or insert new methods... + // if you override setup(), don't forget to call super.setup() + + async setup() { + super.setup(); + console.log('99999999111'); + this.workOrders = await this.getAllWorkOrders(); + console.log('lines', this.workOrders); +} + buttonClick(ev) { + const button = ev.currentTarget; + const id = button.getAttribute('data-id'); + + console.log('true_id', id); + const context = {production_line_show: 'shengchanxian1'} + this.env.services.rpc('/web/dataset/call_kw', { + model: 'mrp.workcenter', + method: 'search_read', + args: [[], ['id']], + kwargs: {} + }).then((records) => { + console.log(records) + const ids = records.map(record => record.id); + const context = {production_line_show: id}; + this.env.services.rpc('/web/dataset/call_kw', { + model: 'mrp.workcenter', + method: 'write', + args: [ids, context], + kwargs: {} + }).then((response) => { + console.log('response', response); + setTimeout(function () { + location.reload(); + },2000) + }); + }); + + + } + async getAllWorkOrders() { + const response = await this.env.services.rpc('/web/dataset/call_kw',{ + model: 'sf.production.line', + method: 'search_read', + args: [], + kwargs: {}, + }); + // const response1 = await this.env.services.rpc('/web/dataset/call_kw',{ + // model: 'mrp.workcenter', + // method: 'search_read', + // args: [], + // kwargs: {}, + // }); + console.log('response', response); + // console.log('response1', response1); + // 你可以在这里处理响应,例如将其存储在控制器的状态中 + return response; + } + + +} + +CustomKanbanController.template = "sf_manufacturing.CustomKanbanView1"; + +export const customKanbanView = { + ...kanbanView, // contains the default Renderer/Controller/Model + Controller: CustomKanbanController, +}; + +// Register it to the views registry +registry.category("views").add("custom_kanban1", customKanbanView); \ No newline at end of file diff --git a/sf_manufacturing/static/src/scss/kanban_change.scss b/sf_manufacturing/static/src/scss/kanban_change.scss new file mode 100644 index 00000000..97f610e1 --- /dev/null +++ b/sf_manufacturing/static/src/scss/kanban_change.scss @@ -0,0 +1,22 @@ +.choosekanban { + display: flex; + justify-content: flex-start; + align-items: center; + margin-left: 16px !important; +} + + +.choosekanban > button { + padding: 0 2vw !important; + height: 2vw !important; + border: none !important; + border-right: 1px solid #ccc !important; + background-color: #EEEEEE; + color: #989799; + font-weight: bold; +} + +.o_content > .d-flex { + display: block !important; +} + diff --git a/sf_manufacturing/static/src/xml/kanban_change.xml b/sf_manufacturing/static/src/xml/kanban_change.xml new file mode 100644 index 00000000..b3718059 --- /dev/null +++ b/sf_manufacturing/static/src/xml/kanban_change.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sf_manufacturing/views/mrp_workcenter_views.xml b/sf_manufacturing/views/mrp_workcenter_views.xml index 8e360993..cc3f6015 100644 --- a/sf_manufacturing/views/mrp_workcenter_views.xml +++ b/sf_manufacturing/views/mrp_workcenter_views.xml @@ -94,6 +94,7 @@ + @@ -101,15 +102,194 @@ - - mrp.workcenter.view.kanban.inherit.maintenance + + + + + + + + + + + + + + + mrp.workcenter.kanban.inherit mrp.workcenter - - - Maintenance - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WORK ORDERS + + + + + PLAN ORDERS + + + + + + + + + To Launch + + + + + + + + + + In Progress + + + + + + + + + + Late + + + + + + + + + + OEE + + + + + + % + + + + + + + + + + + + + + + + + + + Actions + + + Plan Orders + + + + Maintenance + + + + + + Reporting + + + + OEE + + + + + Performance + + + + Waiting Availability + + + + + + + + + + + Settings + + + + + + + @@ -141,5 +321,22 @@ + + + + + + + + + + + + + + + + ======= + >>>>>>> develop diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index 12ba5b31..c67e9c82 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -36,8 +36,7 @@ class ResConfigSettings(models.TransientModel): _logger.info("同步资源库品牌") self.env['sf.machine.control_system'].sync_all_machine_tool_type_control_system() _logger.info("同步资源库控制系统") - self.env['sf.machine_tool.type'].sync_all_machine_tool_type() - _logger.info("同步资源库机床型号") + self.env['sf.machine_tool.category'].sync_all_machine_tool_category() _logger.info("同步资源库机床类型") # self.env['sf.production.process.parameter'].sync_all_production_process_parameter() @@ -66,7 +65,16 @@ class ResConfigSettings(models.TransientModel): self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type() _logger.info("同步功能夹具类型") # self.env['sf.functional.fixture'].sync_all_functional_fixture() + # self.env['sf.multi_mounting.type'].sync_all_multi_mounting_type() + # _logger.info("同步联装类型") + # self.env['sf.fixture.model'].sync_all_fixture_model() + # _logger.info("同步夹具型号") + # self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type() + # _logger.info("同步功能夹具类型") + # self.env['sf.functional.fixture'].sync_all_functional_fixture() # _logger.info("同步功能夹具") + self.env['sf.machine_tool.type'].sync_all_machine_tool_type() + _logger.info("同步资源库机床型号") except Exception as e: _logger.info("捕获错误信息:%s" % e) raise ValidationError("数据错误导致同步失败,请联系管理员") diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index 29628856..a4aca06a 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -708,9 +708,11 @@ class MachineToolType(models.Model): [("code", '=', item['code'])]) if brand: brand.id = item['id'], + brand.knife_type = item['knife_type'], brand.name = item['name'], brand.code = item['code'], - brand.precision = item['precision'], + brand.precision_min = item['precision_min'], + brand.precision_max = item['precision_max'], brand.number_of_knife_library = item['number_of_knife_library'], brand.rotate_speed = item['rotate_speed'], brand.number_of_axles = item['number_of_axles'], @@ -734,6 +736,7 @@ class MachineToolType(models.Model): "id": item['id'], "name": item['name'], "code": item['code'], + "knife_type": item['knife_type'], "number_of_knife_library": item['number_of_knife_library'], "rotate_speed": item['rotate_speed'], @@ -746,7 +749,8 @@ class MachineToolType(models.Model): "b_axis": item['b_axis'], "c_axis": item['c_axis'], "remark": item['remark'], - "precision": item['precision'], + "precision_min": item['precision_min'], + "precision_max": item['precision_max'], 'control_system_id': self.env['sf.machine.control_system'].search( [('code', '=', item['control_system_id'])]).id, "active": item['active'], @@ -763,13 +767,15 @@ class MachineToolType(models.Model): "machine_tool_H": item['machine_tool_H'], "feed_speed": item['feed_speed'], "tool_speed": item['tool_speed'], - "distance": item['distance'], + "distance_min": item['distance_min'], + "distance_max": item['distance_max'], "taper": item['taper'], "torque": item['torque'], "motor_power": item['motor_power'], "tool_quality_max": item['tool_quality_max'], "tool_long_max": item['tool_long_max'], "tool_diameter_max": item['tool_diameter_max'], + "tool_diameter_min": item['tool_diameter_min'], "machine_tool_category": self.env['sf.machine_tool.category'].search( [('code', '=', item['machine_tool_category'])]).id, @@ -812,8 +818,10 @@ class MachineToolType(models.Model): "z_axis": item['z_axis'], "b_axis": item['b_axis'], "c_axis": item['c_axis'], + "knife_type": item['knife_type'], "remark": item['remark'], - "precision": item['precision'], + "precision_min": item['precision_min'], + "precision_max": item['precision_max'], 'control_system_id': self.env['sf.machine.control_system'].search( [('code', '=', item['control_system_id'])]).id, "active": item['active'], @@ -830,13 +838,15 @@ class MachineToolType(models.Model): "machine_tool_H": item['machine_tool_H'], "feed_speed": item['feed_speed'], "tool_speed": item['tool_speed'], - "distance": item['distance'], + "distance_min": item['distance_min'], + "distance_max": item['distance_max'], "taper": item['taper'], "torque": item['torque'], "motor_power": item['motor_power'], "tool_quality_max": item['tool_quality_max'], "tool_long_max": item['tool_long_max'], "tool_diameter_max": item['tool_diameter_max'], + "tool_diameter_min": item['tool_diameter_min'], "machine_tool_category": self.env['sf.machine_tool.category'].search( [('code', '=', item['machine_tool_category'])]).id, @@ -856,9 +866,11 @@ class MachineToolType(models.Model): "y_axis": item['y_axis'], "z_axis": item['z_axis'], "b_axis": item['b_axis'], + "knife_type": item['knife_type'], "c_axis": item['c_axis'], "remark": item['remark'], - "precision": item['precision'], + "precision_min": item['precision_min'], + "precision_max": item['precision_max'], 'control_system_id': self.env['sf.machine.control_system'].search( [('code', '=', item['control_system_id'])]).id, "active": item['active'], @@ -875,13 +887,15 @@ class MachineToolType(models.Model): "machine_tool_H": item['machine_tool_H'], "feed_speed": item['feed_speed'], "tool_speed": item['tool_speed'], - "distance": item['distance'], + "distance_min": item['distance_min'], + "distance_max": item['distance_max'], "taper": item['taper'], "torque": item['torque'], "motor_power": item['motor_power'], "tool_quality_max": item['tool_quality_max'], "tool_long_max": item['tool_long_max'], "tool_diameter_max": item['tool_diameter_max'], + "tool_diameter_min": item['tool_diameter_min'], "machine_tool_category": self.env['sf.machine_tool.category'].search( [('code', '=', item['machine_tool_category'])]).id, diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 7f8b9323..2abcc2e7 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -68,6 +68,59 @@ class FunctionalCuttingToolEntity(models.Model): return [(6, 0, functional_tool_model_ids)] +class FunctionalCuttingToolEntityCache(models.Model): + _name = 'sf.functional.cutting.tool.entity.cache' + _description = '功能刀具列表缓存' + + code = fields.Char('编码') + name = fields.Char('名称') + mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') + mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号') + + # 整体式刀具型号 + mrs_cutting_tool_integral_model_ids = fields.Many2many('sf.cutting.tool.model', + 'sf_functional_cutting_tool_entity_cache_id', + string='整体式刀具型号', domain= + [('mrs_cutting_tool_material_name', '=', '整体式刀具')]) + # 刀片型号 + mrs_cutting_tool_blade_model_ids = fields.Many2many('sf.cutting.tool.model', 'sf_functional_cutting_tool_entity_cache_id', + string='刀片型号', domain= + [('mrs_cutting_tool_material_name', '=', '刀片')]) + # 刀杆型号 + mrs_cutting_tool_cutterbar_model_ids = fields.Many2many('sf.cutting.tool.model', + 'sf_functional_cutting_tool_entity_cache_id', + string='刀杆型号', domain= + [('mrs_cutting_tool_material_name', '=', '刀杆')]) + # 刀盘型号 + mrs_cutting_tool_cutterpad_model_ids = fields.Many2many('sf.cutting.tool.model', + 'sf_functional_cutting_tool_entity_cache_id', + string='刀盘型号', domain= + [('mrs_cutting_tool_material_name', '=', '刀盘')]) + # 刀柄型号 + mrs_cutting_tool_cutterhandle_model_ids = fields.Many2many('sf.cutting.tool.model', + 'sf_functional_cutting_tool_entity_cache_id', + string='刀柄型号', domain= + [('mrs_cutting_tool_material_name', '=', '刀柄')]) + # 夹头型号 + mrs_cutting_tool_cutterhead_model_ids = fields.Many2many('sf.cutting.tool.model', + 'sf_functional_cutting_tool_entity_cache_id', + string='夹头型号', domain= + [('mrs_cutting_tool_material_name', '=', '夹头')]) + + diameter = fields.Float('直径(mm)') + tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], + string='刀具等级') + machining_accuracy = fields.Float('加工精度(mm)') + tool_length = fields.Float('装刀长') + blade_number = fields.Integer('刃数') + integral_blade_length = fields.Float('整体刃长(mm)') + effective_blade_length = fields.Float('有效刃长(mm)') + max_life = fields.Float('最大寿命值') + is_standard = fields.Boolean('是否标准刀') + applicable_range = fields.Char('适用范围') + image = fields.Binary('图片') + + class FunctionalToolWarning(models.Model): _name = 'sf.functional.tool.warning' _description = '功能刀具预警' @@ -591,9 +644,59 @@ class FunctionalToolAssembly(models.Model): 取消功能刀具组装 :return: """ + if self.new_former == '0': + # 如果是新刀,则删除功能刀具列表、 + self.env['sf.functional.cutting.tool.entity'].search([ + ('code', '=', self.functional_tool_code)]).unlink() + else: + # 获取功能刀具缓存信息 + record = self.env['sf.functional.cutting.tool.entity.cache'].search([ + ('code', '=', self.functional_tool_code)], limit=1) + # 删除现有功能刀具列表记录 + self.env['sf.functional.cutting.tool.entity'].search([ + ('code', '=', self.functional_tool_code)]).unlink() + # 创建新的功能刀具列表信息 + self.env['sf.functional.cutting.tool.entity'].create({ + 'code': record.code, + 'name': record.name, + 'mrs_cutting_tool_type_id': record.mrs_cutting_tool_type_id.id, + 'mrs_cutting_tool_model_id': record.mrs_cutting_tool_model_id.id, + 'mrs_cutting_tool_integral_model_ids': record.mrs_cutting_tool_integral_model_ids.ids, + 'mrs_cutting_tool_blade_model_ids': record.mrs_cutting_tool_blade_model_ids.ids, + 'mrs_cutting_tool_cutterbar_model_ids': record.mrs_cutting_tool_cutterbar_model_ids.ids, + 'mrs_cutting_tool_cutterpad_model_ids': record.mrs_cutting_tool_cutterpad_model_ids.ids, + 'mrs_cutting_tool_cutterhandle_model_ids': record.mrs_cutting_tool_cutterhandle_model_ids.ids, + 'mrs_cutting_tool_cutterhead_model_ids': record.mrs_cutting_tool_cutterhead_model_ids.ids, + 'diameter': record.diameter, + 'tool_grade': record.tool_grade, + 'machining_accuracy': record.machining_accuracy, + 'tool_length': record.tool_length, + 'blade_number': record.blade_number, + 'integral_blade_length': record.integral_blade_length, + 'effective_blade_length': record.effective_blade_length, + 'max_life': record.max_life, + 'is_standard': record.is_standard, + 'applicable_range': record.applicable_range, + 'image': record.image, + }) + # 删除缓存信息 + self.env['sf.functional.cutting.tool.entity.cache'].search([ + ('code', '=', self.functional_tool_code)]).unlink() + + + # # 删除功能刀具预警、实时分布、出入库记录的新记录 + # self.env['sf.functional.tool.warning'].search([ + # ('code', '=', self.functional_tool_code)]).unlink() + # self.env['sf.real.time.distribution.of.functional.tools'].search([ + # ('code', '=', self.functional_tool_code)]).unlink() + # self.env['sf.inbound.and.outbound.records.of.functional.tools'].search([ + # ('code', '=', self.functional_tool_code)]).unlink() + + # 修改功能刀具组装的组装信息 self.env['sf.functional.tool.assembly'].search([ ('machine_tool_name_id', '=', self.machine_tool_name_id.id), - ('cutter_spacing_code', '=', self.cutter_spacing_code) + ('cutter_spacing_code', '=', self.cutter_spacing_code), + ('assemble_status', '=', '1') ]).write({ 'mrs_cutting_tool_integral_model_ids': None, 'integral_code': None, @@ -643,24 +746,22 @@ class FunctionalToolAssembly(models.Model): if vals: for val in vals: self.env['sf.delivery.of.cargo.from.storage'].create({ - 'functional_tool_code': val.functional_tool_code, - 'name': val.name.id, - 'functional_tool_type_id': val.functional_tool_type_id.id, - 'production_line_name_id': val.production_line_name_id.id, - 'machine_tool_code': val.machine_tool_code, - 'receive_person': val.receive_person, - 'receive_time': val.receive_time - }) + 'functional_tool_code': val.functional_tool_code, + 'name': val.name.id, + 'functional_tool_type_id': val.functional_tool_type_id.id, + 'production_line_name_id': val.production_line_name_id.id, + 'machine_tool_code': val.machine_tool_code, + 'receive_person': val.receive_person, + 'receive_time': val.receive_time}) else: self.env['sf.delivery.of.cargo.from.storage'].create({ - 'functional_tool_code': self.functional_tool_code, - 'name': self.name.id, - 'functional_tool_type_id': self.functional_tool_type_id.id, - 'production_line_name_id': self.production_line_name_id.id, - 'machine_tool_code': self.machine_tool_code, - 'receive_person': self.receive_person, - 'receive_time': self.receive_time - }) + 'functional_tool_code': self.functional_tool_code, + 'name': self.name.id, + 'functional_tool_type_id': self.functional_tool_type_id.id, + 'production_line_name_id': self.production_line_name_id.id, + 'machine_tool_code': self.machine_tool_code, + 'receive_person': self.receive_person, + 'receive_time': self.receive_time}) return { 'type': 'ir.actions.act_window', diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index 1cb5d1a0..d95ad4c5 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -1,8 +1,9 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1 -access_sf.functional.tool.warning,sf.functional.tool.warning,model_sf_functional_tool_warning,base.group_user,1,0,1,0 -access_sf.real.time.distribution.of.functional.tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,base.group_user,1,0,1,0 -access_sf.inbound.and.outbound.records.of.functional.tools,sf.inbound.and.outbound.records.of.functional.tools,model_sf_inbound_and_outbound_records_of_functional_tools,base.group_user,1,0,1,0 +access_sf_functional_cutting_tool_entity_cache,sf.functional.cutting.tool.entity.cache,model_sf_functional_cutting_tool_entity_cache,base.group_user,1,1,1,1 +access_sf.functional.tool.warning,sf.functional.tool.warning,model_sf_functional_tool_warning,base.group_user,1,1,1,1 +access_sf.real.time.distribution.of.functional.tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,base.group_user,1,1,1,1 +access_sf.inbound.and.outbound.records.of.functional.tools,sf.inbound.and.outbound.records.of.functional.tools,model_sf_inbound_and_outbound_records_of_functional_tools,base.group_user,1,1,1,1 access_sf_cam_work_order_program_knife_plan,sf.cam.work.order.program.knife.plan,model_sf_cam_work_order_program_knife_plan,base.group_user,1,1,1,1 access_sf_machine_table_tool_changing_apply,sf.machine.table.tool.changing.apply,model_sf_machine_table_tool_changing_apply,base.group_user,1,1,1,1 diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 7afdd536..a4ebf243 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -176,10 +176,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 功能刀具组装 :return: """ - self.env['sf.functional.tool.assembly'].search([ - ('machine_tool_name_id', '=', self.machine_tool_name_id.id), - ('cutter_spacing_code', '=', self.cutter_spacing_code) - ]).write({ + desc_1 = { 'mrs_cutting_tool_integral_model_ids': self.mrs_cutting_tool_integral_model_ids.ids, 'integral_code': self.integral_code, 'integral_name': self.integral_name, @@ -214,10 +211,15 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'assemble_status': '1', 'tool_loading_person': self.env.user.name, 'tool_loading_time': fields.Datetime.now() - }) + } + self.env['sf.functional.tool.assembly'].search([ + ('machine_tool_name_id', '=', self.machine_tool_name_id.id), + ('cutter_spacing_code', '=', self.cutter_spacing_code), + ('assemble_status', '=', '0'), + ]).write(desc_1) # 封装功能刀具数据 - desc = { + desc_2 = { 'code': self.code, 'name': self.functional_tool_name_id.name, 'mrs_cutting_tool_type_id': self.functional_tool_type_id.id, @@ -239,14 +241,43 @@ class FunctionalToolAssemblyOrder(models.TransientModel): 'applicable_range': None, 'image': None, } - if self.new_former == '0': # 如果是新刀,则创建功能刀具列表、 - self.env['sf.functional.cutting.tool.entity'].create(desc) - # 创建功能刀具预警、实时分布、出入库记录的新记录 - self.env['sf.functional.tool.warning'].create(desc) - self.env['sf.real.time.distribution.of.functional.tools'].create(desc) - self.env['sf.inbound.and.outbound.records.of.functional.tools'].create(desc) + self.env['sf.functional.cutting.tool.entity'].create(desc_2) + else: + record = self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]) + # 创建功能刀具缓存信息 + self.env['sf.functional.cutting.tool.entity.cache'].create({ + 'code': record.code, + 'name': record.name, + 'mrs_cutting_tool_type_id': record.mrs_cutting_tool_type_id.id, + 'mrs_cutting_tool_model_id': record.mrs_cutting_tool_model_id.id, + 'mrs_cutting_tool_integral_model_ids': record.mrs_cutting_tool_integral_model_ids.ids, + 'mrs_cutting_tool_blade_model_ids': record.mrs_cutting_tool_blade_model_ids.ids, + 'mrs_cutting_tool_cutterbar_model_ids': record.mrs_cutting_tool_cutterbar_model_ids.ids, + 'mrs_cutting_tool_cutterpad_model_ids': record.mrs_cutting_tool_cutterpad_model_ids.ids, + 'mrs_cutting_tool_cutterhandle_model_ids': record.mrs_cutting_tool_cutterhandle_model_ids.ids, + 'mrs_cutting_tool_cutterhead_model_ids': record.mrs_cutting_tool_cutterhead_model_ids.ids, + 'diameter': record.diameter, + 'tool_grade': record.tool_grade, + 'machining_accuracy': record.machining_accuracy, + 'tool_length': record.tool_length, + 'blade_number': record.blade_number, + 'integral_blade_length': record.integral_blade_length, + 'effective_blade_length': record.effective_blade_length, + 'max_life': record.max_life, + 'is_standard': record.is_standard, + 'applicable_range': record.applicable_range, + 'image': record.image, + }) + # 删除功能刀具列表信息 + self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).unlink() + # 创建功能刀具列表信息 + self.env['sf.functional.cutting.tool.entity'].search([('code', '=', self.code)]).create(desc_2) + # # 创建功能刀具预警、实时分布、出入库记录的新记录 + # self.env['sf.functional.tool.warning'].create(desc) + # self.env['sf.real.time.distribution.of.functional.tools'].create(desc) + # self.env['sf.inbound.and.outbound.records.of.functional.tools'].create(desc) # 关闭弹出窗口 return {'type': 'ir.actions.act_window_close'} @@ -271,29 +302,30 @@ class DeliveryOfCargoFromStorage(models.TransientModel): :return: """ vals = self.env['sf.delivery.of.cargo.from.storage'].search([]) - print(vals) if vals: for val in vals: - self.env['sf.functional.tool.assembly'].search([ - ('functional_tool_code', '=', val.functional_tool_code), - ('machine_tool_code', '=', val.machine_tool_code), - ('name', '=', val.name.id), - ('production_line_name_id', '=', val.production_line_name_id.id) - ]).write({ - 'assemble_status': '2', - 'receive_person': self.env.user.name, - 'receive_time': fields.Datetime.now() - }) + # 删除功能刀具列表缓存的数据 + self.env['sf.functional.cutting.tool.entity.cache'].search([ + ('code', '=', self.functional_tool_code)]).unlink() - tool_assembly = self.env['sf.functional.tool.assembly'].search([ + record = self.env['sf.functional.tool.assembly'].search([ ('functional_tool_code', '=', val.functional_tool_code), - ('name', '=', val.name.id) + ('assemble_status', '=', '1') ]) # 判断装刀任务来源,如果来源于CAM装刀,则修改CAM装刀的计划执行状态 - if tool_assembly.loading_task_source == '0': + if record.loading_task_source == '0': self.env['sf.cam.work.order.program.knife.plan'].search([ ('functional_tool_code', '=', val.functional_tool_code), ('functional_tool_name_id', '=', val.name.id) ]).write({ 'plan_execute_status': '2' }) + + record.write({ + 'assemble_status': '2', + 'receive_person': self.env.user.name, + 'receive_time': fields.Datetime.now() + }) + + + diff --git a/sf_tool_management/wizard/wizard_view.xml b/sf_tool_management/wizard/wizard_view.xml index 5f156eae..a8101f6d 100644 --- a/sf_tool_management/wizard/wizard_view.xml +++ b/sf_tool_management/wizard/wizard_view.xml @@ -189,7 +189,8 @@ - + diff --git a/stock_barcode/static/tests/tours/tour_test_barcode_flows_picking.js b/stock_barcode/static/tests/tours/tour_test_barcode_flows_picking.js index 0c1c0c12..fd6e424d 100644 --- a/stock_barcode/static/tests/tours/tour_test_barcode_flows_picking.js +++ b/stock_barcode/static/tests/tours/tour_test_barcode_flows_picking.js @@ -466,6 +466,7 @@ tour.register('test_receipt_reserved_1', {test: true}, [ trigger: '.o_field_widget[name="product_id"]', run: function() { helper.assertFormLocationDest('WH/Stock'); + console.log('123') }, }, ...tour.stepUtils.discardBarcodeForm(),