From 39feda07e59bed58355848f40b5f6f7e76dfc797 Mon Sep 17 00:00:00 2001 From: yuxianghui <1608204036@qq.com> Date: Mon, 28 Aug 2023 17:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=BB=BA=E6=A8=A1=E5=9D=97=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AD=A6=E5=91=8A=E4=BF=A1=E6=81=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/base.py | 4 +- sf_base/models/fixture.py | 24 ++-- sf_base/models/functional_fixture.py | 2 +- sf_base/models/tool_base_new.py | 10 +- sf_base/security/ir.model.access.csv | 1 + .../sf_equipment_maintenance_standards.py | 1 + sf_maintenance/models/sf_maintenance.py | 11 +- sf_maintenance/models/sf_maintenance_logs.py | 2 +- sf_manufacturing/models/model_type.py | 30 ++++- sf_manufacturing/models/mrp_workcenter.py | 10 +- sf_manufacturing/models/mrp_workorder.py | 10 +- sf_manufacturing/models/product_template.py | 114 +++++++++++++----- sf_plan_management/models/calendar_base.py | 6 +- sf_sale/models/quick_easy_order.py | 36 +++--- sf_tool_management/models/base.py | 63 ++++++---- .../models/tool_material_search.py | 4 +- web_widget_model_viewer/__manifest__.py | 1 + zpl_print/__manifest__.py | 1 + 18 files changed, 224 insertions(+), 106 deletions(-) diff --git a/sf_base/models/base.py b/sf_base/models/base.py index 042b77f4..480b676e 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -118,7 +118,7 @@ class MachineTool(models.Model): supplier_id = fields.Many2one('res.partner', string='制造商', domain="[('is_vendor', '=', True)]") registration_date = fields.Date('注册日期') - state_zc = fields.Selection([("已注册", "已注册"), ("未注册", "未注册")], string="注册状态", default='未注册', tracking=True) + state_zc = fields.Selection([("已注册", "已注册"), ("未注册", "未注册")], string="注册状态", default='未注册') active = fields.Boolean('有效', default=True) @api.constrains('rotate_speed') @@ -279,7 +279,7 @@ class MachineToolType(models.Model): feed_speed = fields.Char('进给速度(mm/min)') tool_speed = fields.Char('刀具速度(m/min)') distance_min = fields.Char('主轴端面至工作台面距离MIN(mm)') - distance_max = fields.Char('主轴端面至工作台面距离MIN(mm)') + distance_max = fields.Char('主轴端面至工作台面距离MAX(mm)') taper = fields.Char('主轴锥度(°)') torque = fields.Char('主轴电机扭矩(n/m)') motor_power = fields.Char('主轴电机功率(kw)') diff --git a/sf_base/models/fixture.py b/sf_base/models/fixture.py index bbaecb7c..c393237e 100644 --- a/sf_base/models/fixture.py +++ b/sf_base/models/fixture.py @@ -34,22 +34,22 @@ class FixtureModel(models.Model): clamping_way = fields.Char(string="装夹方式") port_type = fields.Char(string="接口类型") model_file = fields.Binary(string="3D模型图") - length = fields.Char(string="长度[mm]", size=6) - width = fields.Char(string="宽度[mm]", size=6) - height = fields.Char(string="高度[mm]", size=6) - weight = fields.Char(string="重量[kg]", size=4) - clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX[mm]", size=6) - clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX[mm]", size=6) - clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX[mm]", size=6) - clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX[mm]", size=6) - maximum_carrying_weight = fields.Float(string="最大承载重量[kg]", size=4) - maximum_clamping_force = fields.Integer(string="最大夹持力[n]", size=8) + length = fields.Char(string="长度[mm]") + width = fields.Char(string="宽度[mm]") + height = fields.Char(string="高度[mm]") + weight = fields.Char(string="重量[kg]") + clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX[mm]") + clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX[mm]") + clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX[mm]") + clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX[mm]") + maximum_carrying_weight = fields.Float(string="最大承载重量[kg]") + maximum_clamping_force = fields.Integer(string="最大夹持力[n]") materials_model_id = fields.Many2one('sf.materials.model', string="材料型号") driving_way = fields.Selection([('气动', '气动'), ('液压', '液压'), ('机械', '机械')], string="驱动方式") apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_fixture_model_machine_tool_type', string="适用机床型号") - through_hole_size = fields.Integer(string="过孔大小[mm]", size=6) - screw_size = fields.Integer(string="螺牙大小[mm]", size=6) + through_hole_size = fields.Integer(string="过孔大小[mm]") + screw_size = fields.Integer(string="螺牙大小[mm]") active = fields.Boolean('有效', default=True) def _get_code(self, fixture_model_type_code): diff --git a/sf_base/models/functional_fixture.py b/sf_base/models/functional_fixture.py index 5a769757..c96466c1 100644 --- a/sf_base/models/functional_fixture.py +++ b/sf_base/models/functional_fixture.py @@ -36,7 +36,7 @@ class FunctionalFixture(models.Model): domain=[('fixture_material_type', '=', '磁吸托盘')]) vice_tray_model_ids = fields.Many2many('sf.fixture.model', 'rel_fixture_model_vice_tray', string="虎钳托盘型号", domain=[('fixture_material_type', '=', '虎钳托盘')]) - registration_status = fields.Selection([("已注册", "已注册"), ("未注册", "未注册")], string="注册状态", default='未注册', tracking=True) + registration_status = fields.Selection([("已注册", "已注册"), ("未注册", "未注册")], string="注册状态", default='未注册') active = fields.Boolean('有效', default=True) @api.onchange('type_id') diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 2891da17..0a94430e 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -102,11 +102,11 @@ class CuttingToolModel(models.Model): cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='刀具类型', ) brand_id = fields.Many2one('sf.machine.brand', '品牌') - tool_length = fields.Integer('长度(mm)', size=6) - tool_width = fields.Integer('宽度(mm)', size=6) - tool_height = fields.Integer('高度(mm)', size=6) - tool_thickness = fields.Integer('厚度(mm)', size=6) - tool_weight = fields.Float('重量(kg)', size=4) + tool_length = fields.Integer('长度(mm)') + tool_width = fields.Integer('宽度(mm)') + tool_height = fields.Integer('高度(mm)') + tool_thickness = fields.Integer('厚度(mm)') + tool_weight = fields.Float('重量(kg)') coating_material = fields.Char('涂层材质') # 整体式刀具参数 total_length = fields.Float('总长度(mm)') diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 03e2a81b..2cb14006 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -23,6 +23,7 @@ access_sf_multi_mounting_type,sf_multi_mounting_type,model_sf_multi_mounting_typ access_sf_fixture_model,sf_fixture_model,model_sf_fixture_model,base.group_user,1,1,1,1 access_sf_functional_fixture_type,sf_functional_fixture_type,model_sf_functional_fixture_type,base.group_user,1,1,1,1 access_sf_functional_fixture,sf_functional_fixture,model_sf_functional_fixture,base.group_user,1,1,1,1 +access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,1,1,1 diff --git a/sf_maintenance/models/sf_equipment_maintenance_standards.py b/sf_maintenance/models/sf_equipment_maintenance_standards.py index 6e47a548..5bdc7956 100644 --- a/sf_maintenance/models/sf_equipment_maintenance_standards.py +++ b/sf_maintenance/models/sf_equipment_maintenance_standards.py @@ -63,6 +63,7 @@ class SfSaintenanceStandards(models.Model): class MaintenanceStandardImage(models.Model): _name = 'maintenance.standard.image' + _description = 'maintenance.standard.image' 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 37da5a68..98a508eb 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -66,7 +66,14 @@ class SfMaintenanceEquipment(models.Model): MTcode = fields.Char("编码", default=get_no) created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) - equipment_type = fields.Selection([('机床', '机床')], related='category_id.equipment_type') + equipment_type = fields.Selection([('机床', '机床')], compute='_compute_category_id') + + @api.depends('category_id') + def _compute_category_id(self): + for record in self: + if record: + record.equipment_type = record.category_id.equipment_type + code = fields.Char('机台号') name = fields.Char('名称') knife_type = fields.Selection( @@ -114,7 +121,7 @@ class SfMaintenanceEquipment(models.Model): feed_speed = fields.Char('进给速度(mm/min)') tool_speed = fields.Char('刀具速度(m/min)') distance_min = fields.Char('主轴端面至工作台面距离MIN(mm)') - distance_max = fields.Char('主轴端面至工作台面距离MIN(mm)') + distance_max = fields.Char('主轴端面至工作台面距离MAX(mm)') taper = fields.Char('主轴锥度(°)') torque = fields.Char('主轴电机扭矩(n/m)') motor_power = fields.Char('主轴电机功率(kw)') diff --git a/sf_maintenance/models/sf_maintenance_logs.py b/sf_maintenance/models/sf_maintenance_logs.py index 05ce3fd9..0204e676 100644 --- a/sf_maintenance/models/sf_maintenance_logs.py +++ b/sf_maintenance/models/sf_maintenance_logs.py @@ -8,7 +8,7 @@ class SfMaintenanceLogs(models.Model): code = fields.Char(string='编码') name = fields.Char(string='名称') type = fields.Selection([('type1', '类型1'), ('type2', '类型2')], string='类型') - brand = fields.Many2one('sf.machine.brand', relared='model.brand_id', string='品牌') + 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='故障类型') diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index 075937fd..8d011446 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import fields, models,api class ResProductCategory(models.Model): @@ -39,7 +39,15 @@ class ProductModelTypeRoutingSort(models.Model): ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺') - ], string="工序类型", related='route_workcenter_id.routing_type') + ], string="工序类型", compute='_compute_route_workcenter_id') + + @api.depends('route_workcenter_id') + def _compute_route_workcenter_id(self): + for record in self: + if record: + record.routing_type = record.route_workcenter_id.routing_type + + workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') product_model_type_id = fields.Many2one('sf.model.type') @@ -62,7 +70,14 @@ class EmbryoModelTypeRoutingSort(models.Model): ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺') - ], string="工序类型", related='route_workcenter_id.routing_type') + ], string="工序类型", compute='_compute_route_workcenter_id') + + @api.depends('route_workcenter_id') + def _compute_route_workcenter_id(self): + for record in self: + if record: + record.routing_type = record.route_workcenter_id.routing_type + workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') embryo_model_type_id = fields.Many2one('sf.model.type') @@ -85,7 +100,14 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model): ('CNC加工', 'CNC加工'), ('后置三元质量检测', '后置三元质量检测'), ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺') - ], string="工序类型", related='route_workcenter_id.routing_type') + ], string="工序类型", compute='_compute_route_workcenter_id') + + @api.depends('route_workcenter_id') + def _compute_route_workcenter_id(self): + for record in self: + if record: + record.routing_type = record.route_workcenter_id.routing_type + workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids') surface_technics_model_type_id = fields.Many2one('sf.model.type') diff --git a/sf_manufacturing/models/mrp_workcenter.py b/sf_manufacturing/models/mrp_workcenter.py index 3bc3aa17..be898837 100644 --- a/sf_manufacturing/models/mrp_workcenter.py +++ b/sf_manufacturing/models/mrp_workcenter.py @@ -8,7 +8,7 @@ class ResWorkcenter(models.Model): _inherit = "mrp.workcenter" # 生产线显示 - production_line_show = fields.Char(string='生产线') + production_line_show = fields.Char(string='生产线名称') machine_tool_id = fields.Many2one('sf.machine_tool', string='机床') production_line_id = fields.Many2one('sf.production.line', string='生产线') is_process_outsourcing = fields.Boolean('工艺外协') @@ -20,7 +20,13 @@ class ResWorkcenter(models.Model): equipment_status = fields.Selection( [("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")], - string="设备状态", related='equipment_id.state') + string="设备状态", compute='_compute_equipment_id') + + @api.depends('equipment_id') + def _compute_equipment_id(self): + for record in self: + if record: + record.equipment_status = record.equipment_id.state equipment_image = fields.Binary('设备图片', related='equipment_id.machine_tool_picture') diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index b81e6d1e..739af005 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -19,11 +19,11 @@ class ResMrpWorkOrder(models.Model): _order = 'sequence asc,create_date desc' product_tmpl_id_length = fields.Float(related='production_id.product_tmpl_id.length', readonly=True, store=True, - check_company=True, string="坯料长度(mm)") + string="坯料长度(mm)") product_tmpl_id_width = fields.Float(related='production_id.product_tmpl_id.width', readonly=True, store=True, - check_company=True, string="坯料宽度(mm)") + string="坯料宽度(mm)") product_tmpl_id_height = fields.Float(related='production_id.product_tmpl_id.height', readonly=True, store=True, - check_company=True, string="坯料高度(mm)") + string="坯料高度(mm)") product_tmpl_id_materials_id = fields.Many2one(related='production_id.product_tmpl_id.materials_id', readonly=True, store=True, check_company=True, string="材料") product_tmpl_id_materials_type_id = fields.Many2one(related='production_id.product_tmpl_id.materials_type_id', @@ -41,7 +41,7 @@ class ResMrpWorkOrder(models.Model): ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺') ], string="工序类型") - results = fields.Char('检测结果') + results = fields.Char('结果') @api.onchange('users_ids') def get_user_permissions(self): @@ -118,7 +118,7 @@ class ResMrpWorkOrder(models.Model): chuck_brand_id = fields.Many2one('sf.machine.brand', string="卡盘品牌") chuck_type_id = fields.Char(string="卡盘类型") chuck_model_id = fields.Char(string="卡盘型号") - tray_serial_number = fields.Char(string="卡盘序列号") + tray_serial_number = fields.Char(string="托盘序列号") tray_name = fields.Char(string="托盘名称") tray_brand_id = fields.Many2one('sf.machine.brand', string="托盘品牌") tray_type_id = fields.Char(string="托盘类型") diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index eac02928..a21a4d68 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -1,8 +1,8 @@ from odoo import models, fields, api from odoo.exceptions import ValidationError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file import logging import base64 import hashlib @@ -15,8 +15,15 @@ class ResProductMo(models.Model): categ_type = fields.Selection( [("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"), ("夹具", "夹具")], - string='产品的类别', related='categ_id.type', + string='产品的类别', compute='_compute_categ_id', store=True) + + @api.depends('categ_id') + def _compute_categ_id(self): + for record in self: + if record: + record.categ_type = record.categ_id.type + model_name = fields.Char('模型名称') model_long = fields.Float('模型长(mm)', digits=(16, 3)) model_width = fields.Float('模型宽(mm)', digits=(16, 3)) @@ -56,11 +63,11 @@ class ResProductMo(models.Model): domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]") brand_id = fields.Many2one('sf.machine.brand', '品牌') - tool_length = fields.Integer('长度(mm)', size=6) - tool_width = fields.Integer('宽度(mm)', size=6) - tool_height = fields.Integer('高度(mm)', size=6) - tool_thickness = fields.Integer('厚度(mm)', size=6) - tool_weight = fields.Float('重量(kg)', size=4) + tool_length = fields.Integer('长度(mm)') + tool_width = fields.Integer('宽度(mm)') + tool_height = fields.Integer('高度(mm)') + tool_thickness = fields.Integer('厚度(mm)') + tool_weight = fields.Float('重量(kg)', digits=(16, 3)) coating_material = fields.Char('涂层材质') # 整体式刀具参数 cutting_tool_total_length = fields.Float('总长度(mm)') @@ -138,22 +145,73 @@ class ResProductMo(models.Model): fixture_clamping_way = fields.Char(string="装夹方式") fixture_port_type = fields.Char(string="接口类型") fixture_model_file = fields.Binary(string="3D模型图") - fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX(mm)", size=6) - fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX(mm)", size=6) - fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX(mm)", size=6) + fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX(mm)") + fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX(mm)") + fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX(mm)") fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX(mm)", digits=(16, 6)) fixture_maximum_carrying_weight = fields.Float(string="最大承载重量(kg)", digits=(16, 4)) - fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)", size=8) + fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)") fixture_driving_way = fields.Char(string="驱动方式") fixture_apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_product_machine_tool_type', string="适用机床型号") - fixture_through_hole_size = fields.Integer(string="过孔大小(mm)", size=6) - fixture_screw_size = fields.Integer(string="螺牙大小(mm)", size=6) + fixture_through_hole_size = fields.Integer(string="过孔大小(mm)") + fixture_screw_size = fields.Integer(string="螺牙大小(mm)") + # 注册状态 register_state = fields.Selection([('未注册', '未注册'), ('已注册', '已注册'), ('注册失败', '注册失败')], string='注册状态', default='未注册') industry_code = fields.Char('行业编码', readonly=True) + @api.constrains('tool_length') + def _check_tool_length_size(self): + if self.tool_length > 1000000: + raise ValidationError("长度不能超过1000000") + + @api.constrains('tool_width') + def _check_tool_width_size(self): + if self.tool_width > 1000000: + raise ValidationError("宽度不能超过1000000") + + @api.constrains('tool_height') + def _check_tool_height_size(self): + if self.tool_height > 1000000: + raise ValidationError("高度不能超过1000000") + + @api.constrains('tool_thickness') + def _check_tool_thickness_size(self): + if self.tool_thickness > 1000000: + raise ValidationError("厚度不能超过1000000") + + @api.constrains('fixture_clamp_workpiece_length_max') + def _check_fixture_clamp_workpiece_length_max_size(self): + if self.fixture_clamp_workpiece_length_max > 1000000: + raise ValidationError("夹持工件长度MAX不能超过1000000") + + @api.constrains('fixture_clamp_workpiece_width_max') + def _check_fixture_clamp_workpiece_width_max_size(self): + if self.fixture_clamp_workpiece_width_max > 1000000: + raise ValidationError("夹持工件宽度MAX不能超过1000000") + + @api.constrains('fixture_clamp_workpiece_height_max') + def _check_fixture_clamp_workpiece_height_max_size(self): + if self.fixture_clamp_workpiece_height_max > 1000000: + raise ValidationError("夹持工件高度MAX不能超过1000000") + + @api.constrains('fixture_maximum_clamping_force') + def _check_fixture_maximum_clamping_force_size(self): + if self.fixture_maximum_clamping_force > 100000000: + raise ValidationError("最大夹持力不能超过100000000") + + @api.constrains('fixture_through_hole_size') + def _check_fixture_through_hole_size_size(self): + if self.fixture_through_hole_size > 1000000: + raise ValidationError("过孔大小不能超过1000000") + + @api.constrains('fixture_screw_size') + def _check_fixture_through_hole_size_size(self): + if self.fixture_screw_size > 1000000: + raise ValidationError("螺牙大小不能超过1000000") + def _json_apply_machine_tool_type_item_code(self, item): code_arr = [] for i in item.product_id.fixture_apply_machine_tool_type_ids: @@ -500,20 +558,20 @@ class ResProductMo(models.Model): item.model_file = self.transition_glb_file(report_path, model_code) # 将attach的datas内容转为glb文件 - def transition_glb_file(self, report_path, code): - shapes = read_step_file(report_path) - output_file = os.path.join('/tmp', str(code) + '.stl') - write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) - # 转化为glb - output_glb_file = os.path.join('/tmp', str(code) + '.glb') - util_path = get_resource_path('sf_dlm', 'static/util') - cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file) - os.system(cmd) - # 转base64 - with open(output_glb_file, 'rb') as fileObj: - image_data = fileObj.read() - base64_data = base64.b64encode(image_data) - return base64_data + # def transition_glb_file(self, report_path, code): + # shapes = read_step_file(report_path) + # output_file = os.path.join('/tmp', str(code) + '.stl') + # write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) + # # 转化为glb + # output_glb_file = os.path.join('/tmp', str(code) + '.glb') + # util_path = get_resource_path('sf_dlm', 'static/util') + # cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file) + # os.system(cmd) + # # 转base64 + # with open(output_glb_file, 'rb') as fileObj: + # image_data = fileObj.read() + # base64_data = base64.b64encode(image_data) + # return base64_data class ResMrpBomMo(models.Model): diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index b783f8b7..44e9d85c 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -24,7 +24,7 @@ class WorkLogSetting(models.Model): return num code = fields.Char(string='序号', default=_get_code) - name = fields.Char(string='工作日历名称', required=True, size=15, length=30) + name = fields.Char(string='工作日历名称', required=True, size=15) working_shift_ids = fields.Many2many('sf.working.shift', string='班次', required=True) start_time = fields.Datetime(string='日开始时间', readonly=True, compute='_compute_working_shift_ids') @@ -107,11 +107,11 @@ class WorkLogSetting(models.Model): # 'date_time': target_date}) @api.model - def create(self, vals): + def create(self, vals_list): """ 创建记录时,生成工作日历 """ - record = super(WorkLogSetting, self).create(vals) + record = super(WorkLogSetting, self).create(vals_list) record.generate_work_calendar() return record diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index fe7aa0a4..b84e58b9 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -1,7 +1,7 @@ from odoo import models, fields, api from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo.exceptions import ValidationError, UserError from odoo.addons.sf_base.commons.common import Common from datetime import datetime @@ -80,22 +80,22 @@ class QuickEasyOrder(models.Model): return obj # 将attach的datas内容转为glb文件 - def transition_glb_file(self, report_path, model_code): - shapes = read_step_file(report_path) - #output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl') - output_file = os.path.join('/tmp', str(model_code) + '.stl') - write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) - # 转化为glb - #output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb') - output_glb_file = os.path.join('/tmp', str(model_code) + '.glb') - util_path = get_resource_path('sf_dlm', 'static/util') - cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file) - os.system(cmd) - # 转base64 - with open(output_glb_file, 'rb') as fileObj: - image_data = fileObj.read() - base64_data = base64.b64encode(image_data) - return base64_data + # def transition_glb_file(self, report_path, model_code): + # shapes = read_step_file(report_path) + # #output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl') + # output_file = os.path.join('/tmp', str(model_code) + '.stl') + # write_stl_file(shapes, output_file, 'binary', 0.03, 0.5) + # # 转化为glb + # #output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb') + # output_glb_file = os.path.join('/tmp', str(model_code) + '.glb') + # util_path = get_resource_path('sf_dlm', 'static/util') + # cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file) + # os.system(cmd) + # # 转base64 + # with open(output_glb_file, 'rb') as fileObj: + # image_data = fileObj.read() + # base64_data = base64.b64encode(image_data) + # return base64_data # return False @api.onchange('upload_model_file') diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index d39b92fa..5fdd279c 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -15,7 +15,7 @@ class FunctionalCuttingToolEntity(models.Model): code = fields.Char('编码') name = fields.Char('名称') mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号') - mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', tracking=True, + mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', group_expand='_read_group_mrs_cutting_tool_type_ids') @api.model @@ -218,11 +218,11 @@ class FunctionalToolWarning(models.Model): diameter = fields.Float('直径(mm)', readonly=True, related='functional_cutting_tool_id.diameter') tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级', readonly=True, related='functional_cutting_tool_id.tool_grade') + string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') machining_accuracy = fields.Float('加工精度(mm)', readonly=True, related='functional_cutting_tool_id.machining_accuracy') - tool_length = fields.Float('装刀长', readonly=True, related='functional_cutting_tool_id.tool_length') + # tool_length = fields.Float('装刀长', readonly=True, related='functional_cutting_tool_id.tool_length') tool_length = fields.Float('装刀长(mm)', readonly=True, related='functional_cutting_tool_id.tool_length') blade_number = fields.Integer('刃数', readonly=True, related='functional_cutting_tool_id.blade_number') @@ -231,16 +231,24 @@ class FunctionalToolWarning(models.Model): effective_blade_length = fields.Float('有效刃长(mm)', readonly=True, related='functional_cutting_tool_id.effective_blade_length') max_life = fields.Float('最大寿命值', readonly=True, related='functional_cutting_tool_id.max_life') - is_standard = fields.Selection([('1', '是'), ('0', '否')],'是否标准刀', readonly=True, related='functional_cutting_tool_id.is_standard') + is_standard = fields.Selection([('1', '是'), ('0', '否')],'是否标准刀', readonly=True, + compute='_compute_functional_cutting_tool_id') applicable_range = fields.Char('适用范围', readonly=True, related='functional_cutting_tool_id.applicable_range') - image = fields.Binary('图片', readonly=True, related='functional_cutting_tool_id.image') - # 功能刀具预警 特有字段 + image = fields.Binary('图片', readonly=True, related='functional_cutting_tool_id.image') install_tool_time = fields.Datetime("装刀时间", readonly=True, related='functional_tool_assembly_id.tool_loading_time') + + @api.depends('functional_cutting_tool_id') + def _compute_functional_cutting_tool_id(self): + if self.functional_cutting_tool_id: + self.tool_grade = self.functional_cutting_tool_id.tool_grade + self.is_standard = self.functional_cutting_tool_id.is_standard + + # 功能刀具预警 特有字段 outbound_time = fields.Datetime('出库时间', readonly=True, related='functional_tool_assembly_id.receive_time') on_board_time = fields.Datetime('上机时间', readonly=False) - machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=True, tracking=True, + machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=True, group_expand='_read_group_machine_table_name_ids') @api.model @@ -250,7 +258,7 @@ class FunctionalToolWarning(models.Model): machine_tool_code = fields.Char('机台号', readonly=True, related='functional_tool_assembly_id.machine_tool_code') cutting_tool_code = fields.Char('刀位号', readonly=True, related='functional_tool_assembly_id.cutter_spacing_code') - idle_time = fields.Char('闲置时长', readonly=False) + # idle_time = fields.Char('闲置时长', readonly=False) idle_time = fields.Char('闲置时长(h)', readonly=False) alarm_value = fields.Char('报警值', readonly=False) used_value = fields.Char('已使用值', readonly=False) @@ -272,7 +280,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model): functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - tracking=True, group_expand='_read_mrs_cutting_tool_type_ids', + group_expand='_read_mrs_cutting_tool_type_ids', store=True, compute='_compute_functional_cutting_tool_id') @@ -344,7 +352,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model): diameter = fields.Float('直径(mm)', readonly=True, related='functional_cutting_tool_id.diameter') tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级', readonly=True, related='functional_cutting_tool_id.tool_grade') + string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') machining_accuracy = fields.Float('加工精度(mm)', readonly=True, related='functional_cutting_tool_id.machining_accuracy') tool_length = fields.Float('装刀长(mm)', readonly=True, related='functional_cutting_tool_id.tool_length') @@ -354,10 +362,17 @@ class RealTimeDistributionOfFunctionalTools(models.Model): effective_blade_length = fields.Float('有效刃长(mm)', readonly=True, related='functional_cutting_tool_id.effective_blade_length') max_life = fields.Float('最大寿命值', readonly=True, related='functional_cutting_tool_id.max_life') - is_standard = fields.Selection([('1', '是'), ('0', '否')],'是否标准刀', readonly=True, related='functional_cutting_tool_id.is_standard') + is_standard = fields.Selection([('1', '是'), ('0', '否')],'是否标准刀', readonly=True, + compute='_compute_functional_cutting_tool_id') applicable_range = fields.Char('适用范围', readonly=True, related='functional_cutting_tool_id.applicable_range') image = fields.Binary('图片', readonly=True, related='functional_cutting_tool_id.image') + @api.depends('functional_cutting_tool_id') + def _compute_functional_cutting_tool_id(self): + if self.functional_cutting_tool_id: + self.tool_grade = self.functional_cutting_tool_id.tool_grade + self.is_standard = self.functional_cutting_tool_id.is_standard + # 功能刀具实时分布 tool_stock_num = fields.Integer(string='刀具房库存数量', readonly=False) side_shelf_num = fields.Integer(string='线边货架货架数量', readonly=False) @@ -395,7 +410,7 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model): functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - tracking=True, group_expand='_read_mrs_cutting_tool_type_ids', + group_expand='_read_mrs_cutting_tool_type_ids', store=True, compute='_compute_functional_cutting_tool_id') @@ -465,7 +480,7 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model): diameter = fields.Float('直径(mm)', readonly=True, related='functional_cutting_tool_id.diameter') tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级', readonly=True, related='functional_cutting_tool_id.tool_grade') + string='刀具等级', readonly=True, compute='_compute_functional_cutting_tool_id') machining_accuracy = fields.Float('加工精度(mm)', readonly=True, related='functional_cutting_tool_id.machining_accuracy') tool_length = fields.Float('装刀长(mm)', readonly=True, related='functional_cutting_tool_id.tool_length') @@ -475,10 +490,17 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model): effective_blade_length = fields.Float('有效刃长(mm)', readonly=True, related='functional_cutting_tool_id.effective_blade_length') max_life = fields.Float('最大寿命值', readonly=True, related='functional_cutting_tool_id.max_life') - is_standard = fields.Selection([('1', '是'), ('0', '否')],'是否标准刀', readonly=True, related='functional_cutting_tool_id.is_standard') + is_standard = fields.Selection([('1', '是'), ('0', '否')],'是否标准刀', readonly=True, + compute='_compute_functional_cutting_tool_id') applicable_range = fields.Char('适用范围', readonly=True, related='functional_cutting_tool_id.applicable_range') image = fields.Binary('图片', readonly=True, related='functional_cutting_tool_id.image') + @api.depends('functional_cutting_tool_id') + def _compute_functional_cutting_tool_id(self): + if self.functional_cutting_tool_id: + self.tool_grade = self.functional_cutting_tool_id.tool_grade + self.is_standard = self.functional_cutting_tool_id.is_standard + # 功能刀具出入库记录 特有字段 current_state = fields.Char(string='当前状态', readonly=False) current_store_area = fields.Char(string='当前库区', readonly=False) @@ -486,7 +508,7 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model): tool_install_staff = fields.Char(string='装刀人', readonly=False) tool_install_time = fields.Datetime(string='装刀时间', readonly=False) thickness = fields.Selection([('1', '粗'), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False) - max_life_span = fields.Char(string='最大寿命值', readonly=False) + # max_life_span = fields.Char(string='最大寿命值', readonly=False) alarm_value = fields.Char(string='报警值', readonly=False) used_value = fields.Char(string='已使用值', readonly=False) reason_application = fields.Char(string='申请原因', readonly=False) @@ -528,12 +550,11 @@ class MachineTableToolChangingApply(models.Model): # string='换刀需求信息', # attrs="{'invisible': 1}") - - name = fields.Many2one('maintenance.equipment', string='CNC机床',required=True, readonly=False, tracking=True, + name = fields.Many2one('maintenance.equipment', string='CNC机床',required=True, readonly=False, group_expand='_read_group_names') machine_table_type_id = fields.Many2one('sf.machine_tool.category', string='机床类型', readonly=True, compute='_compute_name') - machine_tool_code = fields.Char(string='机台号', attrs="{'invisible': 1}", readonly=True, compute='_compute_name') + machine_tool_code = fields.Char(string='机台号', invisible=True, readonly=True, compute='_compute_name') cutter_spacing_code = fields.Char(string='刀位号', readonly=False) functional_tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_functional_tool_name_id') functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=False) @@ -555,7 +576,7 @@ class MachineTableToolChangingApply(models.Model): replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型', readonly=True) replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], - string='粗/中/精', readonly=True) + string='粗/中/精(待换)', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) applicant = fields.Char(string='申请人', readonly=True) used_tool_time = fields.Datetime(string='用刀时间', readonly=True) @@ -692,7 +713,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): functional_tool_code = fields.Char(string='功能刀具编码', readonly=False) functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=False) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False) - machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=False, tracking=True, + machine_table_name_id = fields.Many2one('maintenance.equipment', string='机床名称', readonly=False, group_expand='_read_group_machine_table_name_ids') @api.model @@ -786,7 +807,7 @@ class FunctionalToolAssembly(models.Model): functional_tool_code = fields.Char(string='功能刀具编码', readonly=True) name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - tracking=True, group_expand='_read_group_functional_tool_type_ids') + group_expand='_read_group_functional_tool_type_ids') @api.model def _read_group_functional_tool_type_ids(self, categories, domain, order): diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py index e85ffb69..cfbe489d 100644 --- a/sf_tool_management/models/tool_material_search.py +++ b/sf_tool_management/models/tool_material_search.py @@ -23,9 +23,9 @@ class SfToolMaterialSearch(models.Model): # mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', '刀具型号') # 关联刀具物料模型 - mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料',tracking=True, + mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料', group_expand='_read_group_mrs_cutting_tool_material_ids') - cutting_tool_material_name = fields.Char(string='物料名称',invisible=True) + cutting_tool_material_name = fields.Char(string='物料名称', invisible=True) @api.onchange('mrs_cutting_tool_material_id') def _onchange_mrs_cutting_tool_material_id(self): diff --git a/web_widget_model_viewer/__manifest__.py b/web_widget_model_viewer/__manifest__.py index 52ed13b1..84c4006b 100644 --- a/web_widget_model_viewer/__manifest__.py +++ b/web_widget_model_viewer/__manifest__.py @@ -4,6 +4,7 @@ "description": "3D模型展示模块(限odoo16)", "author": "Van", "website": "https://jikimo.com", + "license": "LGPL-3", "category": "Tutorials", "version": "16.0.0.1", "depends": ['web'], diff --git a/zpl_print/__manifest__.py b/zpl_print/__manifest__.py index 7956cac5..c74dc79e 100644 --- a/zpl_print/__manifest__.py +++ b/zpl_print/__manifest__.py @@ -22,6 +22,7 @@ 'jikimo_sfs/zpl_print/static/src/scss/changes.scss' ] }, + 'license': 'LGPL-3', 'installable': True, 'application': False, 'auto_install': False,