diff --git a/jikimo_frontend/__init__.py b/jikimo_frontend/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/jikimo_frontend/__manifest__.py b/jikimo_frontend/__manifest__.py new file mode 100644 index 00000000..716bc918 --- /dev/null +++ b/jikimo_frontend/__manifest__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +{ + 'name': '机企猫智能工厂 样式调整', + 'version': '1.0', + 'summary': '机企猫智能工厂 样式调整', + 'sequence': 1, + 'description': """ +在本模块,定义了样式的修改 + """, + 'category': 'sf', + 'website': 'https://www.sf.jikimo.com', + 'depends': [], + 'data': [ + + ], + 'demo': [ + ], + 'assets': { + + 'web.assets_qweb': [ + ], + 'web.assets_backend': [ + 'jikimo_frontend/static/src/fields/custom_many2many_checkboxes/*', + 'jikimo_frontend/static/src/scss/custom_style.scss', + ], + + }, + 'license': 'LGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.css b/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.css new file mode 100644 index 00000000..df6cdfb6 --- /dev/null +++ b/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.css @@ -0,0 +1,41 @@ +.zoomed { + position: fixed !important; + top: 50%; + left: 50%; + transform: translate(-50%, -50%) scale(10); +} + +.many2many_flex { + display: flex; +} + +.many2many_flex>div { + margin-right: 15px; + display: flex; + flex-direction: column; + align-items: center; +} + +.many2many_flex>div>:nth-child(2) { + position: relative; +} + +.close { + width: 20px; + height: 20px; + position: absolute; + top: -8.8px; + right: -8.8px; + color: #fff; + background-color: #000; + opacity: 0; + text-align: center; + line-height: 20px; + font-size: 18px; +} + +.img_close { + opacity: 1; + transform: scale(0.1); + cursor: pointer; +} \ No newline at end of file diff --git a/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.js b/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.js new file mode 100644 index 00000000..5845dbae --- /dev/null +++ b/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.js @@ -0,0 +1,37 @@ +/** @odoo-module **/ + +import {Many2ManyCheckboxesField} from "@web/views/fields/many2many_checkboxes/many2many_checkboxes_field"; +import {registry} from "@web/core/registry"; + +export class MyCustomWidget extends Many2ManyCheckboxesField { + // 你可以重写或者添加一些方法和属性 + // 例如,你可以重写setup方法来添加一些事件监听器或者初始化一些变量 + setup() { + super.setup(); // 调用父类的setup方法 + // 你自己的代码 + } + + onImageClick(event) { + // 放大图片逻辑 + // 获取图片元素 + const img = event.target; + const close = img.nextSibling + + // 实现放大图片逻辑 + // 比如使用 CSS 放大 + img.parentElement.classList.add('zoomed'); + close.classList.add('img_close') + } + + onCloseClick(event) { + const close = event.target; + const img = close.previousSibling + img.parentElement.classList.remove('zoomed') + close.classList.remove('img_close') + } +} + +MyCustomWidget.template = "jikimo_frontend.MyCustomWidget" +// MyCustomWidget.supportedTypes = ['many2many']; + +registry.category("fields").add("custom_many2many_checkboxes", MyCustomWidget); diff --git a/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.xml b/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.xml new file mode 100644 index 00000000..bebae03b --- /dev/null +++ b/jikimo_frontend/static/src/fields/custom_many2many_checkboxes/custom_many2many_checkboxes.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + × + + + + + + + + + diff --git a/jikimo_frontend/static/src/scss/custom_style.scss b/jikimo_frontend/static/src/scss/custom_style.scss new file mode 100644 index 00000000..a9f2cee8 --- /dev/null +++ b/jikimo_frontend/static/src/scss/custom_style.scss @@ -0,0 +1,151 @@ +.test_model { + display: flex !important; +} + +.test_model > .o_form_label { + margin-left: 20px; + margin-right: 0px !important; + white-space: nowrap; +} + +div:has(.o_required_modifier) > label::before { + content: '*' !important; + color: red !important; + padding: 0 4px !important; + vertical-align: top !important; + font-size: 1.5rem !important; +} + +.my-image div { + width: 110px !important; + height: 110px !important; +} + +.add_flex { + padding: 5px 0; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.maintenance_name { + font-weight: bold; +} + +.o_kanban_renderer .o_kanban_record .o_kanban_record_has_image_fill .o_kanban_image_fill_left { + flex: unset !important; +} + +.o_kanban_renderer .o_kanban_record .o_kanban_record_bottom { + margin-top: 5px; + display: inline !important; +} + +td.o_required_modifier { + display: table-cell !important; +} + +.show_state { + display: flex; + flex-direction: column; + position: absolute; + top: 0; + bottom: 0; + right: 8px; + margin: auto; + height: 34px; +} + +.show_state > div { + width: 12px; + height: 12px; + border: 1px solid #000 +} + +.show_state > div:nth-child(2) { + border-top: none; + border-bottom: none; +} + +.oe_kanban_card.kanban_color_2 { + background-color: #FF4343 !important; + color: #fff; +} + +.oe_kanban_card.kanban_color_1 { + background-color: #27FEA9 !important; + opacity: 0.7; + color: #fff; +} + +.oe_kanban_card.kanban_color_3 { + background-color: rgb(255, 150, 0) !important; + color: #fff; +} + +.my-image img { + width: 100%; + height: 100%; +} + +.color_1 { + background-color: #27FEA9; +} + +.color_2 { + background-color: #FF4343; +} + +.color_3 { + background-color: rgb(255, 150, 0); +} + +.font_color_1 { + color: rgb(0, 183, 0); +} + +.font_color_2 { + color: #FF4343; +} + +.font_color_3 { + color: rgb(255, 150, 0); +} + +.o_kanban_card_header_title { + font-size: 15px; +} + +.o_kanban_record_bottom { + font-family: '华文中宋'; + //font-weight: bold; +} + +.text-truncate { + overflow: unset !important; + text-overflow: unset !important; + white-space: unset !important; +} + +.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) { + white-space: nowrap !important; +} + +.o_status { + width: 18px; + height: 18px; +} + +.czyg { + font-size: 12px; + margin-right: 10px; + color: #aaa; +} + +.o_kanban_primary_left { + display: flex; + flex-direction: row-reverse; + justify-content: flex-start; +} + +//----------------------------------------------------------- \ No newline at end of file diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 04b8338a..fc62074e 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -108,6 +108,7 @@ class CuttingToolModel(models.Model): tool_thickness = fields.Integer('厚度(mm)') tool_weight = fields.Float('重量(kg)') coating_material = fields.Char('涂层材质') + # 整体式刀具参数 total_length = fields.Float('总长度(mm)') shank_length = fields.Float('柄部长度(mm)') diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index 2cb14006..fefaeb1b 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -32,3 +32,4 @@ access_sf_sync_common,sf_sync_common,model_sf_sync_common,base.group_user,1,1,1, + diff --git a/sf_base/static/src/scss/test.scss b/sf_base/static/src/scss/test.scss index 8495e5cd..a54eb808 100644 --- a/sf_base/static/src/scss/test.scss +++ b/sf_base/static/src/scss/test.scss @@ -130,3 +130,35 @@ td.o_required_modifier { .o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) { white-space: nowrap !important; } + +.o_status { + width: 18px; + height: 18px; +} + +.czyg { + font-size: 12px; + margin-right: 10px; + color: #aaa; +} + +.o_kanban_primary_left { + display: flex; + flex-direction: row-reverse; + justify-content: flex-start; +} + +.diameter:before { + content:"Ф"; + display:inline; +} +.diameter{ + display: flex !important; + justify-content: flex-start !important; + align-items: center !important; +} +.o_address_format { + display: flex !important; + justify-content: flex-start !important; + align-items: center !important; +} \ No newline at end of file diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index bfc405f9..ee5546a8 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -243,6 +243,7 @@ attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')]}"/> + @@ -288,7 +289,7 @@ + attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀杆','刀盘','刀柄'))]}"/> @@ -306,7 +307,7 @@ + attrs="{'invisible': [('cutting_tool_type', 'in', ('刀柄'))]}"/> diff --git a/sf_dlm/views/product_template_view.xml b/sf_dlm/views/product_template_view.xml index 10eef5d6..19327a82 100644 --- a/sf_dlm/views/product_template_view.xml +++ b/sf_dlm/views/product_template_view.xml @@ -1,47 +1,68 @@ + + product.template.only.form.inherit.sf + product.template + + + + + + + + + + + product.template.form.inherit.sf product.template - + + + + + + + + - + - - - - + - - + - - - + @@ -84,17 +105,46 @@ - - - - - + + + + - + + + + + + + + + + + + + + + + @@ -110,28 +160,159 @@ - - + - - - + attrs="{'invisible': [('cutting_tool_type', 'not in', ('刀片','刀杆','刀盘'))]}"/> - + - - + + + + + (mm) + + + (mm) + + + + + + + + + + + + + + + + + + + + + + + + + (mm) + + + (mm) + + + - + + + + + + (mm) + + + (mm) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -141,37 +322,79 @@ + - - - - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sf_machine_connect/views/compensation.xml b/sf_machine_connect/views/compensation.xml index 5ec6f382..f79c539e 100644 --- a/sf_machine_connect/views/compensation.xml +++ b/sf_machine_connect/views/compensation.xml @@ -6,7 +6,8 @@ - + diff --git a/sf_maintenance/models/sf_equipment_maintenance_standards.py b/sf_maintenance/models/sf_equipment_maintenance_standards.py index 5bdc7956..47e7ddaf 100644 --- a/sf_maintenance/models/sf_equipment_maintenance_standards.py +++ b/sf_maintenance/models/sf_equipment_maintenance_standards.py @@ -19,6 +19,7 @@ class SfEquipmentSaintenanceStandards(models.Model): num = "%04d" % m return num code = fields.Char(string='编码', default=get_no) + remark = fields.Char('备注') maintenance_type = fields.Selection([('保养', '保养'), ("检修", "检修")], string='类型', default='保养') name = fields.Char(string='名称') created_user_id = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) @@ -26,7 +27,7 @@ class SfEquipmentSaintenanceStandards(models.Model): maintenance_equipment_ids = fields.Many2many( 'maintenance.equipment', 'sf_maintenance_equipment_ids', - string='设备', + string='适用设备', domain="[('category_id', '=', maintenance_equipment_category_id)]" ) @@ -42,23 +43,29 @@ class SfEquipmentSaintenanceStandards(models.Model): if record.maintenance_type == '检修': record.write({'overhaul_ids': [(6, 0, record.maintenance_equipment_ids.ids)]}) - @api.onchange("maintenance_standards_ids") - def _reset_work_order_sequence(self): - for rec in self: - current_sequence = 1 - for work in rec.maintenance_standards_ids: - work.sequence = current_sequence - current_sequence += 1 + # @api.onchange("maintenance_standards_ids") + # def _reset_work_order_sequence(self): + # for rec in self: + # current_sequence = 1 + # for work in rec.maintenance_standards_ids: + # work.sequence = current_sequence + # current_sequence += 1 class SfSaintenanceStandards(models.Model): _name = 'maintenance.standards' _description = '维保项目' + _order = 'sequence' + sequence = fields.Integer('序号') name = fields.Char('维保项目') maintenance_standards = fields.Char('维保标准') + fault_type = fields.Selection( + [('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='类别') equipment_maintenance_standards_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准') maintenance_request_id = fields.Many2one('maintenance.request', string='设备维保计划') images = fields.One2many('maintenance.standard.image', 'standard_id', string='反馈图片') + Period = fields.Integer('周期/频次(天)') + remark = fields.Char('备注说明') class MaintenanceStandardImage(models.Model): diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index 98a508eb..d66de31e 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -44,6 +44,7 @@ class SfMaintenanceEquipment(models.Model): overhaul_period = fields.Integer(string='预防检修频次') overhaul_duration = fields.Float(string='检修时长') + overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准', domain="[('maintenance_type','=','检修')]") @@ -142,7 +143,7 @@ class SfMaintenanceEquipment(models.Model): active = fields.Boolean('有效', default=True) # 多个型号对应一个机床 machine_tool_id = fields.Many2one('sf.machine_tool', '机床') - sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs','maintenance_equipment_id', '设备故障日志') + sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_id', '设备故障日志') def name_get(self): @@ -474,3 +475,49 @@ class SfMaintenanceEquipment(models.Model): ('sf_maintenance_type', '=', '检修')]) if not next_requests: equipment._create_new_request1(equipment.overhaul_date) + + image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='设备图文') + +class MaintenanceStandardImage(models.Model): + _name = 'maintenance.equipment.image' + _description = '设备图文展示' + + + active = fields.Boolean('有效', default=True) + name = fields.Char('加工能力') + image = fields.Binary(string='设备图文') + equipment_id = fields.Many2many('maintenance.equipment', 'image_id', string='设备') + + @api.model + def name_search(self, name='', args=None, operator='ilike', limit=100): + # 调用父类的name_search方法,获取原始的结果列表 + res = super().name_search(name, args, operator, limit) + # 定义一个空字典用来存储id和name的映射关系 + name_dict = {} + # 遍历结果列表,将id和name存入字典中 + for item in res: + id = item[0] + name = item[1] + name_dict[id] = name + # 根据id列表搜索符合条件的记录 + records = self.browse(name_dict.keys()) + # 定义一个新的结果列表用来存储修改后的结果 + new_res = [] + # 遍历每条记录 + for record in records: + # 获取记录的id,name和image属性 + id = record.id + name = name_dict[id] + image = record.image + # 如果image不为空,将其转换为data URI scheme + if image: + data_uri = f"data:image/png;base64,{image.decode('utf-8')}" + else: + data_uri = "" + # 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result + new_res.append([id, name, data_uri]) + # 返回新的结果列表 + return new_res + + + diff --git a/sf_maintenance/models/sf_maintenance_logs.py b/sf_maintenance/models/sf_maintenance_logs.py index 0204e676..9adf5be7 100644 --- a/sf_maintenance/models/sf_maintenance_logs.py +++ b/sf_maintenance/models/sf_maintenance_logs.py @@ -22,3 +22,5 @@ class SfMaintenanceLogs(models.Model): recovery_time = fields.Datetime(string='复原时间') fault_duration = fields.Float(string='故障时长') note = fields.Text(string='备注') + + diff --git a/sf_maintenance/security/ir.model.access.csv b/sf_maintenance/security/ir.model.access.csv index 039583ce..f5517576 100644 --- a/sf_maintenance/security/ir.model.access.csv +++ b/sf_maintenance/security/ir.model.access.csv @@ -4,6 +4,7 @@ access_sf_maintenance_logs,sf_maintenance_logs,model_sf_maintenance_logs,base.gr access_maintenance_equipment,maintenance_equipment,model_maintenance_equipment,base.group_user,1,1,1,1 access_maintenance_standards,maintenance_standards,model_maintenance_standards,base.group_user,1,1,1,1 access_maintenance_standard_image,maintenance_standard_image,model_maintenance_standard_image,base.group_user,1,1,1,1 +access_maintenance_equipment_image,maintenance_equipment_image,model_maintenance_equipment_image,base.group_user,1,1,1,1 diff --git a/sf_maintenance/views/equipment_maintenance_standards_views.xml b/sf_maintenance/views/equipment_maintenance_standards_views.xml index 82fbf15b..1b30b68f 100644 --- a/sf_maintenance/views/equipment_maintenance_standards_views.xml +++ b/sf_maintenance/views/equipment_maintenance_standards_views.xml @@ -21,14 +21,26 @@ - - + + + + + + + + + + + + + + @@ -46,6 +58,7 @@ + diff --git a/sf_maintenance/views/maintenance_logs_views.xml b/sf_maintenance/views/maintenance_logs_views.xml index 33e22bf2..f226349f 100644 --- a/sf_maintenance/views/maintenance_logs_views.xml +++ b/sf_maintenance/views/maintenance_logs_views.xml @@ -34,25 +34,39 @@ sf.maintenance.logs - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -64,8 +78,8 @@ - - + + @@ -90,28 +104,28 @@ - - 设备故障日志 - ir.actions.act_window - sf.maintenance.logs - tree,form - - - - 设备故障日志 - - - + + 设备故障日志 + ir.actions.act_window + sf.maintenance.logs + tree,form + + + + 设备故障日志 + + + - - - - - - - + + + + + + + - + diff --git a/sf_maintenance/views/maintenance_request_views.xml b/sf_maintenance/views/maintenance_request_views.xml index 9c5ae694..83bd6e44 100644 --- a/sf_maintenance/views/maintenance_request_views.xml +++ b/sf_maintenance/views/maintenance_request_views.xml @@ -24,9 +24,11 @@ + + @@ -78,8 +80,16 @@ - - + + + + + + + + + + diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index b3d0a207..5c699af0 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -34,6 +34,7 @@ + + + + + @@ -172,6 +177,16 @@ + + + + + + + + + @@ -210,11 +225,11 @@ - + - + @@ -360,7 +375,51 @@ - + + + + maintenance.equipment.image.tree + maintenance.equipment.image + + + + + + + + + + + + maintenance.equipment.image.form + maintenance.equipment.image + + + + + + + + + + + + + + + + 设备图文图文 + maintenance.equipment.image + tree,form + [] + + \ No newline at end of file diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index be18f685..b7fa686a 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -22,6 +22,7 @@ 'views/mrp_workcenter_views.xml', 'views/mrp_workorder_view.xml', 'views/production_line_view.xml', + 'views/tool_other_features_view.xml', # 'views/tray_view.xml', 'views/model_type_view.xml', # 'views/kanban_change.xml' diff --git a/sf_manufacturing/models/__init__.py b/sf_manufacturing/models/__init__.py index 2d7d2f1e..96accf78 100644 --- a/sf_manufacturing/models/__init__.py +++ b/sf_manufacturing/models/__init__.py @@ -9,6 +9,7 @@ from . import mrp_routing_workcenter from . import stock from . import res_user from . import production_line_base +from . import tool_other_features diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 67c1f14c..b6d774a3 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -339,7 +339,7 @@ class MrpProduction(models.Model): current_sequence += 1 if work.name == '获取CNC加工程序': work.button_start() - #work.fetchCNC() + # work.fetchCNC() # 创建工单并进行排序 def _create_workorder(self): diff --git a/sf_manufacturing/models/mrp_workcenter.py b/sf_manufacturing/models/mrp_workcenter.py index be898837..c42e9cec 100644 --- a/sf_manufacturing/models/mrp_workcenter.py +++ b/sf_manufacturing/models/mrp_workcenter.py @@ -11,13 +11,18 @@ class ResWorkcenter(models.Model): 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('工艺外协') - users_ids = fields.Many2many("res.users", 'users_workcenter') - equipment_id = fields.Many2one( 'maintenance.equipment', string="设备", check_company=True) + + + is_process_outsourcing = fields.Boolean('工艺外协') + users_ids = fields.Many2many("res.users", 'users_workcenter') + + + + equipment_status = fields.Selection( [("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")], string="设备状态", compute='_compute_equipment_id') diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index dbeb7814..6f50425f 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -25,7 +25,6 @@ class ResProductMo(models.Model): # if record: # record.categ_type = record.categ_id.type - categ_type = fields.Selection(string='产品的类别', related='categ_id.type', store=True) model_name = fields.Char('模型名称') @@ -63,26 +62,132 @@ class ResProductMo(models.Model): cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='型号', ) - cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='刀具类型', + cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型', domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]") brand_id = fields.Many2one('sf.machine.brand', '品牌') - tool_length = fields.Integer('长度(mm)') - tool_width = fields.Integer('宽度(mm)') - tool_height = fields.Integer('高度(mm)') + tool_length = fields.Float('长度(mm)') + tool_width = fields.Float('宽度(mm)') + tool_height = fields.Float('高度(mm)') tool_thickness = fields.Integer('厚度(mm)') tool_weight = fields.Float('重量(kg)') + tool_hardness = fields.Integer('硬度(hrc)') coating_material = fields.Char('涂层材质') - # 整体式刀具参数 - cutting_tool_total_length = fields.Float('总长度(mm)') - cutting_tool_shank_length = fields.Float('柄部长度(mm)') - cutting_tool_blade_length = fields.Float('刃部长度(mm)') + # 整体式刀具特有字段 + cutting_tool_total_length = fields.Float('总长度(mm)', digits=(6, 1)) + cutting_tool_shank_length = fields.Float('柄部长度(mm)', digits=(6, 1)) + cutting_tool_blade_length = fields.Float('刃部长度(mm)', digits=(6, 1)) + cutting_tool_blade_number = fields.Selection( + [('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')], '刃数(个)') + # 整体式刀具新增字段 + cutting_tool_neck_length = fields.Float('颈部长度(mm)', digits=(6, 1)) + cutting_tool_neck_diameter = fields.Float('颈部直径(mm)', digits=(6, 1)) + cutting_tool_shank_diameter = fields.Float('柄部直径(mm)', digits=(6, 1)) + cutting_tool_blade_tip_diameter = fields.Float('刀尖直径(mm)', digits=(6, 1)) + cutting_tool_blade_tip_taper = fields.Integer('刀尖锥度(°)') + cutting_tool_blade_helix_angle = fields.Integer('刃部螺旋角(°)') + cutting_tool_blade_type = fields.Char('刃部类型') + cutting_tool_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '粗/中/精') + cutting_tool_run_out_accuracy_max = fields.Float('端跳精度max', digits=(6, 1)) + cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1)) + suitable_machining_method_ids = fields.Many2many('sf.suitable.machining.method', + 'rel_suitable_machining_method_product_template', '适合加工方式') + blade_tip_characteristics_ids = fields.Many2many('sf.blade.tip.characteristics', + 'rel_blade_tip_characteristics_product_template', '刀尖特征') + handle_type_ids = fields.Many2many('sf.handle.type', 'rel_handle_type_product_template', '柄部类型') + cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction_product_template', + '走刀方向') + suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant_product_template', + '适合冷却液') + + # @api.constrains('suitable_machining_method_ids') + # def _check_suitable_machining_method_ids(self): + # for record in self: + # if len(record.suitable_machining_method_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("适合加工方式不能为空!") + # + # @api.constrains('blade_tip_characteristics_ids') + # def _check_blade_tip_characteristics_ids(self): + # for record in self: + # if len(record.blade_tip_characteristics_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刀尖特征不能为空!") + # if len(record.blade_tip_characteristics_ids) > 1 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刀尖特征只能单选!") + # + # @api.constrains('handle_type_ids') + # def _check_handle_type_ids(self): + # for record in self: + # if len(record.handle_type_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部类型不能为空!") + # if len(record.handle_type_ids) > 1 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部类型只能单选!") + # + # @api.constrains('cutting_direction_ids') + # def _check_cutting_direction_ids(self): + # for record in self: + # if len(record.cutting_direction_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("走刀方向不能为空!") + # + # @api.constrains('suitable_coolant_ids') + # def _check_suitable_coolant_ids(self): + # for record in self: + # if not record.suitable_coolant_ids and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("适合冷却液不能为空!") + # + # @api.constrains('cutting_tool_total_length') + # def _check_cutting_tool_total_length(self): + # if self.cutting_tool_total_length <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("总长度不能为0") + # + # @api.constrains('cutting_tool_shank_length') + # def _check_cutting_tool_shank_length(self): + # if self.cutting_tool_shank_length <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部长度不能为0") + # + # @api.constrains('cutting_tool_blade_length') + # def _check_cutting_tool_blade_length(self): + # if self.cutting_tool_blade_length <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刃部长度不能为0") + # + # @api.constrains('cutting_tool_blade_number') + # def _check_cutting_tool_blade_number(self): + # if self.cutting_tool_blade_number <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刃数不能为0") + # + # @api.constrains('integral_shank_diameter') + # def _check_integral_shank_diameter(self): + # if self.integral_shank_diameter <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部直径不能为0") + # + # @api.constrains('integral_blade_diameter') + # def _check_integral_blade_diameter(self): + # if self.integral_blade_diameter <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刃部直径不能为0") + # + # @api.constrains('integral_run_out_accuracy_min') + # def _check_integral_blade_diameter(self): + # if self.integral_run_out_accuracy_min <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("端跳精度最小(min)不能为0") + + cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度Vc') + feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz') + + # @api.constrains('suitable_machining_method_ids') + # def _check_suitable_machining_method_ids(self): + # for record in self: + # if len(record.suitable_machining_method_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("适合加工方式不能为空!") + + # @api.constrains('integral_run_out_accuracy_max') + # def _check_integral_run_out_accuracy_max(self): + # if self.integral_run_out_accuracy_max <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("端跳精度最大(max)不能为0") + cutting_tool_diameter = fields.Float('直径(mm)') - cutting_tool_blade_number = fields.Integer('刃数') - cutting_tool_front_angle = fields.Float('前角(°)') - cutting_tool_rear_angle = fields.Float('后角(°)') - cutting_tool_main_included_angle = fields.Float('主偏角(°)') + cutting_tool_front_angle = fields.Integer('前角(°)') + cutting_tool_rear_angle = fields.Integer('后角(°)') + cutting_tool_main_included_angle = fields.Integer('主偏角(°)') # cutting_tool_material_model_id = fields.Many2one('sf.materials.model', '材料型号') cutting_tool_nut = fields.Float('配对螺母(mm)') # 适用夹头型号可以多选 @@ -94,8 +199,8 @@ class ResProductMo(models.Model): domain="[('cutting_tool_type', '=', '夹头')]", string='适用夹头型号') # 刀片参数 - cutting_tool_top_angle = fields.Float('顶角(°)') - cutting_tool_jump_accuracy = fields.Float('径跳精度(um)') + cutting_tool_top_angle = fields.Integer('顶角(°)') + cutting_tool_jump_accuracy = fields.Float('径跳精度(mm)') cutting_tool_working_hardness = fields.Char('加工硬度(hrc)') cutting_tool_cutter_bar_ids = fields.Many2many( 'sf.cutting.tool.model', @@ -114,7 +219,7 @@ class ResProductMo(models.Model): string='适用刀盘型号' # 使用空列表作为默认值 ) # 刀杆/参数 - cutting_tool_blade_diameter = fields.Float('刃径(mm)') + cutting_tool_blade_diameter = fields.Float('刃径/刃部直径(mm)') cutting_tool_blade_ids = fields.Many2many( 'sf.cutting.tool.model', relation='product_cutting_tool_model_pad_blade_rel', @@ -124,16 +229,41 @@ class ResProductMo(models.Model): string='适用刀片型号' # 使用空列表作为默认值 ) cutting_tool_wrench = fields.Float('配对扳手(mm)') - cutting_tool_screw = fields.Float('配备螺丝(mm)') + # cutting_tool_screw = fields.Float('配备螺丝(mm)') cutting_tool_accuracy_level = fields.Char('精度等级') # 刀柄参数 + cutting_tool_head_diameter = fields.Float('头部直径') cutting_tool_diameter_max = fields.Float('最大直径(mm)') cutting_tool_clamping_diameter = fields.Float('夹持直径(mm)') - cutting_tool_flange_length = fields.Float('法兰柄长度(mm)') + cutting_tool_clamping_length = fields.Float('夹持长度(mm)') + cutting_tool_clamping_tolerance = fields.Float('夹持公差(mm)') + cutting_tool_clamping_diameter_max = fields.Float('最大夹持直径') + cutting_tool_clamping_diameter_min = fields.Float('最小夹持直径') + cutting_tool_flange_length = fields.Float('法兰柄长(mm)') cutting_tool_flange_diameter = fields.Float('法兰直径(mm)') + cutting_tool_is_rough_finish = fields.Boolean('可粗加工', default=False) + cutting_tool_is_finish = fields.Boolean('可精加工', default=False) + cutting_tool_is_drill_hole = fields.Boolean('可钻孔', default=False) + cutting_tool_is_safety_lock = fields.Boolean('安全锁', default=False) + cutting_tool_is_high_speed_cutting = fields.Boolean('可高速切削', default=False) + cutting_tool_dynamic_balance_class = fields.Char('动平衡等级') + cutting_tool_change_time = fields.Integer('换刀时间(s)') + cutting_tool_clamping_way = fields.Char('夹持方式') + cutting_tool_standard_speed = fields.Integer('标准转速(n/min)') + cutting_tool_speed_max = fields.Integer('最大转速(n/min)') + cutting_tool_cooling_type = fields.Char('冷却类型') + cutting_tool_body_accuracy = fields.Float('本体精度(mm)') + apply_lock_nut_model = fields.Char('适用锁紧螺母型号') + apply_lock_wrench_model = fields.Char('适用锁紧扳手型号') + cutting_tool_detection_accuracy_max = fields.Float('最大检测精度(mm)') + cutting_tool_detection_accuracy_min = fields.Float('最小检测精度(mm)') # 夹头参数 + cutting_tool_taper = fields.Integer('锥度(°)') cutting_tool_outer_diameter = fields.Float('外径(mm)') cutting_tool_inner_diameter = fields.Float('内径(mm)') + cooling_suit_type_ids = fields.Char('适用冷却套型号') + # cooling_suit_type_ids = fields.Many2many('冷却类型') + cutting_tool_er_size_model = fields.Char('ER尺寸型号') cutting_tool_handle_ids = fields.Many2many( 'sf.cutting.tool.model', relation='product_cutting_tool_model_chuck_handle_rel', @@ -312,84 +442,119 @@ class ResProductMo(models.Model): item.fixture_apply_machine_tool_type_ids = self._get_ids( item.fixture_model_id.apply_machine_tool_type_ids) - @api.onchange('cutting_tool_model_id') - def _onchange_cutting_tool_model_id(self): - for item in self: - if self.cutting_tool_type is not False: - item.brand_id = item.cutting_tool_model_id.brand_id.id - item.cutting_tool_type_id = item.cutting_tool_model_id.cutting_tool_type_id.id - item.tool_length = item.cutting_tool_model_id.tool_length - item.tool_width = item.cutting_tool_model_id.tool_width - item.tool_height = item.cutting_tool_model_id.tool_height - item.tool_thickness = item.cutting_tool_model_id.tool_thickness - item.tool_weight = item.cutting_tool_model_id.tool_weight - item.coating_material = item.cutting_tool_model_id.coating_material - item.cutting_tool_total_length = item.cutting_tool_model_id.total_length - item.cutting_tool_shank_length = item.cutting_tool_model_id.shank_length - item.cutting_tool_blade_length = item.cutting_tool_model_id.blade_length - item.cutting_tool_diameter = item.cutting_tool_model_id.diameter - item.cutting_tool_blade_number = item.cutting_tool_model_id.blade_number - item.cutting_tool_front_angle = item.cutting_tool_model_id.front_angle - item.cutting_tool_rear_angle = item.cutting_tool_model_id.rear_angle - item.cutting_tool_main_included_angle = item.cutting_tool_model_id.main_included_angle - item.materials_type_id = item.cutting_tool_model_id.material_model_id.id - item.cutting_tool_nut = item.cutting_tool_model_id.nut - item.cutting_tool_top_angle = item.cutting_tool_model_id.top_angle - item.cutting_tool_jump_accuracy = item.cutting_tool_model_id.jump_accuracy - item.cutting_tool_working_hardness = item.cutting_tool_model_id.working_hardness - item.cutting_tool_blade_diameter = item.cutting_tool_model_id.blade_diameter - item.cutting_tool_wrench = item.cutting_tool_model_id.wrench - item.cutting_tool_screw = item.cutting_tool_model_id.screw - item.cutting_tool_accuracy_level = item.cutting_tool_model_id.accuracy_level - item.cutting_tool_diameter_max = item.cutting_tool_model_id.diameter_max - item.cutting_tool_clamping_diameter = item.cutting_tool_model_id.clamping_diameter - item.cutting_tool_flange_length = item.cutting_tool_model_id.flange_length - item.cutting_tool_flange_diameter = item.cutting_tool_model_id.flange_diameter - item.cutting_tool_outer_diameter = item.cutting_tool_model_id.outer_diameter - item.cutting_tool_inner_diameter = item.cutting_tool_model_id.inner_diameter - item.cutting_tool_chuck_ids = self._get_ids(item.cutting_tool_model_id.chuck_ids) - item.cutting_tool_cutter_bar_ids = self._get_ids(item.cutting_tool_model_id.cutter_bar_ids) - item.cutting_tool_cutter_pad_ids = self._get_ids(item.cutting_tool_model_id.cutter_pad_ids) - item.cutting_tool_blade_ids = self._get_ids(item.cutting_tool_model_id.blade_ids) - item.cutting_tool_handle_ids = self._get_ids(item.cutting_tool_model_id.handle_ids) - else: - item.brand_id = False - item.cutting_tool_type_id = False - item.brand_id = False - item.tool_length = False - item.tool_width = False - item.tool_height = False - item.tool_thickness = False - item.tool_weight = False - item.coating_material = False - item.cutting_tool_total_length = False - item.cutting_tool_shank_length = False - item.cutting_tool_blade_length = False - item.cutting_tool_diameter = False - item.cutting_tool_blade_number = False - item.cutting_tool_front_angle = False - item.cutting_tool_rear_angle = False - item.cutting_tool_main_included_angle = False - item.materials_type_id = False - item.cutting_tool_nut = False - item.cutting_tool_top_angle = False - item.cutting_tool_jump_accuracy = False - item.cutting_tool_working_hardness = False - item.cutting_tool_blade_diameter = False - item.cutting_tool_wrench = False - item.cutting_tool_screw = False - item.cutting_tool_accuracy_level = False - item.cutting_tool_diameter_max = False - item.cutting_tool_clamping_diameter = False - item.cutting_tool_flange_length = False - item.cutting_tool_flange_diameter = False - item.cutting_tool_outer_diameter = False - item.cutting_tool_inner_diameter = False - item.cutting_tool_chuck_ids = False - item.cutting_tool_cutter_bar_ids = False - item.cutting_tool_cutter_pad_ids = False - item.cutting_tool_blade_ids = False - item.cutting_tool_handle_ids = False + # @api.onchange('cutting_tool_model_id') + # def _onchange_cutting_tool_model_id(self): + # for item in self: + # if self.cutting_tool_type is not False: + # item.brand_id = item.cutting_tool_model_id.brand_id.id + # item.cutting_tool_type_id = item.cutting_tool_model_id.cutting_tool_type_id.id + # item.tool_length = item.cutting_tool_model_id.tool_length + # item.tool_width = item.cutting_tool_model_id.tool_width + # item.tool_height = item.cutting_tool_model_id.tool_height + # item.tool_thickness = item.cutting_tool_model_id.tool_thickness + # item.tool_weight = item.cutting_tool_model_id.tool_weight + # item.coating_material = item.cutting_tool_model_id.coating_material + # item.cutting_tool_total_length = item.cutting_tool_model_id.total_length + # item.cutting_tool_shank_length = item.cutting_tool_model_id.shank_length + # item.cutting_tool_neck_length = item.cutting_tool_model_id.cutting_tool_neck_length + # item.cutting_tool_shank_diameter = item.cutting_tool_model_id.cutting_tool_shank_diameter + # item.cutting_tool_blade_diameter = item.cutting_tool_model_id.cutting_tool_blade_diameter + # item.cutting_tool_neck_diameter = item.cutting_tool_model_id.cutting_tool_neck_diameter + # item.cutting_tool_blade_tip_diameter = item.cutting_tool_model_id.cutting_tool_blade_tip_diameter + # item.cutting_tool_blade_tip_taper = item.cutting_tool_model_id.cutting_tool_blade_tip_taper + # item.cutting_tool_blade_helix_angle = item.cutting_tool_model_id.cutting_tool_blade_helix_angle + # item.cutting_tool_blade_type = item.cutting_tool_model_id.cutting_tool_blade_type + # item.cutting_tool_coarse_medium_fine = item.cutting_tool_model_id.cutting_tool_coarse_medium_fine + # item.tool_hardness = item.cutting_tool_model_id.tool_hardness + # item.cutting_tool_run_out_accuracy_max = item.cutting_tool_model_id.cutting_tool_run_out_accuracy_max + # item.cutting_tool_run_out_accuracy_min = item.cutting_tool_model_id.cutting_tool_run_out_accuracy_min + # item.suitable_machining_method_ids = self._get_ids( + # item.cutting_tool_model_id.suitable_machining_method_ids) + # item.blade_tip_characteristics_ids = self._get_ids( + # item.cutting_tool_model_id.blade_tip_characteristics_ids) + # item.handle_type_ids = self._get_ids(item.cutting_tool_model_id.handle_type_ids) + # item.cutting_direction_ids = self._get_ids(item.cutting_tool_model_id.cutting_direction_ids) + # item.suitable_coolant_ids = self._get_ids(item.cutting_tool_model_id.suitable_coolant_ids) + # item.cutting_tool_diameter = item.cutting_tool_model_id.diameter + # item.cutting_tool_blade_number = item.cutting_tool_model_id.blade_number + # item.cutting_tool_front_angle = item.cutting_tool_model_id.front_angle + # item.cutting_tool_rear_angle = item.cutting_tool_model_id.rear_angle + # item.cutting_tool_main_included_angle = item.cutting_tool_model_id.main_included_angle + # item.materials_type_id = item.cutting_tool_model_id.material_model_id.id + # item.cutting_tool_nut = item.cutting_tool_model_id.nut + # item.cutting_tool_top_angle = item.cutting_tool_model_id.top_angle + # item.cutting_tool_jump_accuracy = item.cutting_tool_model_id.jump_accuracy + # item.cutting_tool_working_hardness = item.cutting_tool_model_id.working_hardness + # item.cutting_tool_blade_diameter = item.cutting_tool_model_id.blade_diameter + # item.cutting_tool_wrench = item.cutting_tool_model_id.wrench + # # item.cutting_tool_screw = item.cutting_tool_model_id.screw + # item.cutting_tool_accuracy_level = item.cutting_tool_model_id.accuracy_level + # item.cutting_tool_diameter_max = item.cutting_tool_model_id.diameter_max + # item.cutting_tool_clamping_diameter = item.cutting_tool_model_id.clamping_diameter + # item.cutting_tool_flange_length = item.cutting_tool_model_id.flange_length + # item.cutting_tool_flange_diameter = item.cutting_tool_model_id.flange_diameter + # item.cutting_tool_outer_diameter = item.cutting_tool_model_id.outer_diameter + # item.cutting_tool_inner_diameter = item.cutting_tool_model_id.inner_diameter + # item.cutting_tool_chuck_ids = self._get_ids(item.cutting_tool_model_id.chuck_ids) + # item.cutting_tool_cutter_bar_ids = self._get_ids(item.cutting_tool_model_id.cutter_bar_ids) + # item.cutting_tool_cutter_pad_ids = self._get_ids(item.cutting_tool_model_id.cutter_pad_ids) + # item.cutting_tool_blade_ids = self._get_ids(item.cutting_tool_model_id.blade_ids) + # item.cutting_tool_handle_ids = self._get_ids(item.cutting_tool_model_id.handle_ids) + # else: + # item.brand_id = False + # item.cutting_tool_type_id = False + # item.brand_id = False + # item.tool_length = False + # item.tool_width = False + # item.tool_height = False + # item.tool_thickness = False + # item.tool_weight = False + # item.coating_material = False + # item.cutting_tool_total_length = False + # item.cutting_tool_shank_length = False + # item.cutting_tool_blade_length = False + # item.cutting_tool_neck_length = False + # item.cutting_tool_shank_diameter = False + # item.cutting_tool_blade_diameter = False + # item.cutting_tool_neck_diameter = False + # item.cutting_tool_blade_tip_diameter = False + # item.cutting_tool_blade_tip_taper = False + # item.cutting_tool_blade_helix_angle = False + # item.cutting_tool_blade_type = False + # item.cutting_tool_coarse_medium_fine = False + # item.tool_hardness = False + # item.cutting_tool_run_out_accuracy_max = False + # item.cutting_tool_run_out_accuracy_min = False + # item.suitable_machining_method_ids = False + # item.blade_tip_characteristics_ids = False + # item.handle_type_ids = False + # item.cutting_direction_ids = False + # item.suitable_coolant_ids = False + # item.cutting_tool_diameter = False + # item.cutting_tool_blade_number = False + # item.cutting_tool_front_angle = False + # item.cutting_tool_rear_angle = False + # item.cutting_tool_main_included_angle = False + # item.materials_type_id = False + # item.cutting_tool_nut = False + # item.cutting_tool_top_angle = False + # item.cutting_tool_jump_accuracy = False + # item.cutting_tool_working_hardness = False + # item.cutting_tool_blade_diameter = False + # item.cutting_tool_wrench = False + # # item.cutting_tool_screw = False + # item.cutting_tool_accuracy_level = False + # item.cutting_tool_diameter_max = False + # item.cutting_tool_clamping_diameter = False + # item.cutting_tool_flange_length = False + # item.cutting_tool_flange_diameter = False + # item.cutting_tool_outer_diameter = False + # item.cutting_tool_inner_diameter = False + # item.cutting_tool_chuck_ids = False + # item.cutting_tool_cutter_bar_ids = False + # item.cutting_tool_cutter_pad_ids = False + # item.cutting_tool_blade_ids = False + # item.cutting_tool_handle_ids = False def _get_volume_uom_id_from_ir_config_parameter(self): product_length_in_feet_param = self.env['ir.config_parameter'].sudo().get_param('product.volume_in_cubic_feet') @@ -597,8 +762,7 @@ class ResMrpBomMo(models.Model): } return self.env['mrp.bom.line'].create(vals) - # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom - + # 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom def bom_create(self, product, bom_type, product_type): bom_id = self.env['mrp.bom'].create({ 'product_tmpl_id': product.product_tmpl_id.id, @@ -615,16 +779,18 @@ class ResMrpBomMo(models.Model): # 坯料BOM组件:选取当前坯料原材料, # 然后根据当前的坯料的体积得出需要的原材料重量(立方米m³) *材料密度 * 1000 = 所需原材料重量KG(公斤) # 坯料所需原材料公式:当前的坯料的体积(立方米m³) *材料密度 * 1000 = 所需原材料重量KG(公斤) - def bom_create_line(self, embryo): # 选取当前坯料原材料 raw_bom_line = self.get_raw_bom(embryo) if raw_bom_line: + qty = 1 + if round(embryo.volume * raw_bom_line.materials_type_id.density / 1000000) > 1: + qty = round(embryo.volume * raw_bom_line.materials_type_id.density / 1000000) bom_line = self.env['mrp.bom.line'].create({ 'bom_id': self.id, 'product_id': raw_bom_line.id, 'product_tmpl_id': raw_bom_line.product_tmpl_id.id, - 'product_qty': round(embryo.volume * raw_bom_line.materials_type_id.density / 1000000), + 'product_qty': qty, 'product_uom_id': raw_bom_line.uom_id.id, }) return bom_line @@ -659,8 +825,7 @@ class ResMrpBomMo(models.Model): else: return - # 查bom的原材料 - + # 查bom的原材料 def get_raw_bom(self, product): raw_bom = self.env['product.product'].search( [('categ_id.type', '=', '原材料'), ('materials_type_id', '=', product.materials_type_id.id)]) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index c29abbf4..5a4e2ec4 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -7,7 +7,7 @@ from odoo.exceptions import ValidationError, UserError import requests import json from re import findall as regex_findall -from datetime import datetime +from datetime import datetime, timedelta from re import split as regex_split from odoo import SUPERUSER_ID, _, api, fields, models from odoo.tools import float_compare @@ -154,6 +154,7 @@ class StockRule(models.Model): '''创建制造订单''' productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( productions_values) + self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) ''' @@ -188,6 +189,29 @@ class StockRule(models.Model): 'mail.message_origin_link', values={'self': production, 'origin': origin_production}, subtype_id=self.env.ref('mail.mt_note').id) + ''' + 创建生产计划 + ''' + # 工单耗时 + workorder_duration = 0 + for workorder in production.workorder_ids: + workorder_duration += workorder.duration_expected + + sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)]) + if sale_order: + bb = sale_order.deadline_of_delivery + productions = self.env['sf.production.plan'].with_user(SUPERUSER_ID).sudo().with_company(company_id). \ + create({ + 'name': production.name, + 'order_deadline': sale_order.deadline_of_delivery, + 'production_id': production.id, + 'date_planned_start': production.date_planned_start, + 'origin': production.origin, + 'product_qty': production.product_qty, + 'product_id': production.product_id.id, + 'state': 'draft', + }) + return True @@ -425,6 +449,7 @@ class ReStockMove(models.Model): 'tool_height': item.product_id.tool_height, 'tool_thickness': item.product_id.tool_thickness, 'tool_weight': item.product_id.tool_weight, + 'tool_hardness': item.product_id.tool_hardness, 'coating_material': item.product_id.coating_material, 'amount': int(item.quantity_done), # 'model_file': '' if not item.product_id.fixture_model_file else base64.b64encode( @@ -433,8 +458,19 @@ class ReStockMove(models.Model): 'total_length': item.product_id.cutting_tool_total_length, 'shank_length': item.product_id.cutting_tool_shank_length, 'blade_length': item.product_id.cutting_tool_blade_length, + 'neck_length': item.product_id.cutting_tool_neck_length, + 'neck_diameter': item.product_id.cutting_tool_neck_diameter, + 'shank_diameter': item.product_id.cutting_tool_shank_diameter, + 'blade_tip_diameter': item.product_id.cutting_tool_blade_tip_diameter, + 'blade_tip_taper': item.product_id.cutting_tool_blade_tip_taper, + 'blade_helix_angle': item.product_id.cutting_tool_blade_helix_angle, + 'blade_type': item.product_id.cutting_tool_blade_type, + 'coarse_medium_fine': '' if item.product_id.cutting_tool_coarse_medium_fine is False else item.product_id.cutting_tool_coarse_medium_fine, + 'run_out_accuracy_max': item.product_id.cutting_tool_run_out_accuracy_max, + 'run_out_accuracy_min': item.product_id.cutting_tool_run_out_accuracy_min, + 'head_diameter': item.product_id.cutting_tool_head_diameter, 'diameter': item.product_id.cutting_tool_diameter, - 'blade_number': item.product_id.cutting_tool_blade_number, + 'blade_number': '' if item.product_id.cutting_tool_blade_number is False else item.product_id.cutting_tool_blade_number, 'front_angle': item.product_id.cutting_tool_front_angle, 'rear_angle': item.product_id.cutting_tool_rear_angle, 'main_included_angle': item.product_id.cutting_tool_main_included_angle, @@ -449,14 +485,36 @@ class ReStockMove(models.Model): 'working_hardness': item.product_id.cutting_tool_working_hardness, 'blade_diameter': item.product_id.cutting_tool_blade_diameter, 'wrench': item.product_id.cutting_tool_wrench, - 'screw': item.product_id.cutting_tool_screw, 'accuracy_level': item.product_id.cutting_tool_accuracy_level, + 'clamping_way': item.product_id.cutting_tool_clamping_way, + 'clamping_length': item.product_id.cutting_tool_clamping_length, + 'clamping_tolerance': item.product_id.cutting_tool_clamping_tolerance, 'diameter_max': item.product_id.cutting_tool_diameter_max, - 'clamping_diameter': item.product_id.cutting_tool_clamping_diameter, + 'clamping_diameter_min': item.product_id.cutting_tool_clamping_diameter_min, + 'clamping_diameter_max': item.product_id.cutting_tool_clamping_diameter_max, + 'detection_accuracy_max': item.product_id.cutting_tool_detection_accuracy_max, + 'detection_accuracy_min': item.product_id.cutting_tool_detection_accuracy_min, + 'is_rough_finish': item.product_id.cutting_tool_is_rough_finish, + 'is_finish': item.product_id.cutting_tool_is_finish, + 'is_drill_hole': item.product_id.cutting_tool_is_drill_hole, + 'is_safety_lock': item.product_id.cutting_tool_is_safety_lock, + 'is_high_speed_cutting': item.product_id.cutting_tool_is_high_speed_cutting, + 'dynamic_balance_class': item.product_id.cutting_tool_dynamic_balance_class, + 'change_time': item.product_id.cutting_tool_change_time, + 'standard_speed': item.product_id.cutting_tool_standard_speed, + 'speed_max': item.product_id.cutting_tool_speed_max, + 'cooling_type': item.product_id.cutting_tool_cooling_type, + 'body_accuracy': item.product_id.cutting_tool_body_accuracy, + 'apply_lock_nut_model': item.product_id.apply_lock_nut_model, + 'apply_lock_wrench_model': item.product_id.apply_lock_wrench_model, + 'tool_taper': item.product_id.cutting_tool_taper, 'flange_length': item.product_id.cutting_tool_flange_length, 'flange_diameter': item.product_id.cutting_tool_flange_diameter, 'outer_diameter': item.product_id.cutting_tool_outer_diameter, 'inner_diameter': item.product_id.cutting_tool_inner_diameter, + 'cooling_suit_type_ids': item.product_id.cooling_suit_type_ids, + 'er_size_model': item.product_id.cutting_tool_er_size_model, + 'image': '' if not item.product_id.image_1920 else base64.b64encode(item.product_id.image_1920).decode('utf-8'), } try: if item.product_id.industry_code: @@ -489,5 +547,3 @@ class ReStockQuant(models.Model): elif self.product_id.categ_type == '刀具': stock._register_cutting_tool() return True - - diff --git a/sf_manufacturing/models/tool_other_features.py b/sf_manufacturing/models/tool_other_features.py new file mode 100644 index 00000000..ddad9da8 --- /dev/null +++ b/sf_manufacturing/models/tool_other_features.py @@ -0,0 +1,94 @@ +from odoo import fields, models, api + + +class SuitableMachiningMethod(models.Model): + _name = 'sf.suitable.machining.method' + _description = '适合加工方式' + + name = fields.Char('名称') + image = fields.Image('图片') + + +class BladeTipCharacteristics(models.Model): + _name = 'sf.blade.tip.characteristics' + _description = '刀尖特征' + + name = fields.Char('名称') + image = fields.Image('图片') + + +class HandleType(models.Model): + _name = 'sf.handle.type' + _description = '柄部类型' + + name = fields.Char('名称') + image = fields.Image('图片') + + +class CuttingDirection(models.Model): + _name = 'sf.cutting.direction' + _description = '走刀方向' + + name = fields.Char('名称') + image = fields.Image('图片') + + +class SuitableCoolant(models.Model): + _name = 'sf.suitable.coolant' + _description = '适合冷却液' + + name = fields.Char('名称') + image = fields.Image('图片') + + +class CuttingSpeed(models.Model): + _name = 'sf.cutting.speed' + _description = '切削速度Vc' + + # def _get_order(self): + # last_tool = self.search([], order='id desc', limit=1) + # if last_tool: + # last_order = int(last_tool.order) + # new_order = last_order + 1 + # else: + # new_order = '1' + # return new_order + # + # order = fields.Char('序', default=_get_order, readonly=True) + + product_template_id = fields.Many2one('product.template', string='产品') + + execution_standard_id = fields.Char('执行标准') + material_code = fields.Char('材料代号') + material_name = fields.Char('材料名称') + material_grade = fields.Char('材料牌号') + tensile_strength = fields.Float('拉伸强度 (N/mm²)') + hardness = fields.Float('硬度(HRC)') + + cutting_speed_n1 = fields.Char('径向切宽 ae=100%D1 ap=1*D1 切削速度Vc') + cutting_speed_n2 = fields.Char('径向切宽 ae=50%D1 ap=1.5*D1 切削速度Vc') + cutting_speed_n3 = fields.Char('径向切宽 ae=25%D1 ap=L1max 切削速度Vc') + cutting_speed_n4 = fields.Char('径向切宽 ae=15%D1 ap=L1max 切削速度Vc') + cutting_speed_n5 = fields.Char('径向切宽 ae=5%D1 ap=L1max 切削速度Vc') + rough_machining = fields.Char('粗加工 Vc(m/min)') + precision_machining = fields.Char('精加工 Vc(m/min)') + application = fields.Selection([('主应用', '主应用'), ('次应用', '次应用')], '主/次应用') + + +class FeedPerTooth(models.Model): + _name = 'sf.feed.per.tooth' + _description = '每齿走刀量fz' + + product_template_id = fields.Many2one('product.template', string='产品') + + cutting_speed = fields.Char('径向切宽 ae(mm)') + machining_method = fields.Selection([('直铣', '直铣'), ('坡铣', '坡铣')], string='加工方式') + materials_type_id = fields.Many2one('sf.materials.model', string='材料型号') + blade_diameter = fields.Float('刃部直径D1(mm)', readonly=True, related='product_template_id.cutting_tool_blade_diameter') + feed_per_tooth = fields.Char('每齿走刀量 (mm/z)') + unit = fields.Char('单位', default='fz') + + # @api.depends('product_template_id') + # def _compute_product_template_id(self): + # if self.product_template_id is not None: + # self.blade_diameter = self.product_template_id.cutting_tool_blade_diameter diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index e0a78bb6..76812adb 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -7,6 +7,12 @@ access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_typ access_sf_production_line,sf.production.line,model_sf_production_line,base.group_user,1,1,1,1 - +access_sf_suitable_machining_method,sf_suitable_machining_method,model_sf_suitable_machining_method,base.group_user,1,1,1,1 +access_sf_blade_tip_characteristics,sf_blade_tip_characteristics,model_sf_blade_tip_characteristics,base.group_user,1,1,1,1 +access_sf_handle_type,sf_handle_type,model_sf_handle_type,base.group_user,1,1,1,1 +access_sf_cutting_direction,sf_cutting_direction,model_sf_cutting_direction,base.group_user,1,1,1,1 +access_sf_suitable_coolant,sf_suitable_coolant,model_sf_suitable_coolant,base.group_user,1,1,1,1 +access_sf_cutting_speed,sf_cutting_speed,model_sf_cutting_speed,base.group_user,1,1,1,1 +access_sf_feed_per_tooth,sf_feed_per_tooth,model_sf_feed_per_tooth,base.group_user,1,1,1,1 diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 716cdb76..b326f288 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -20,8 +20,10 @@ - - + + + + @@ -40,7 +42,64 @@ decoration-warning="reservation_state != 'assigned' and components_availability_state in ('expected', 'available')" decoration-danger="reservation_state != 'assigned' and components_availability_state == 'late'"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + custom.mrp.production.select + mrp.production + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 cda445ec..48487bfd 100644 --- a/sf_manufacturing/views/mrp_workcenter_views.xml +++ b/sf_manufacturing/views/mrp_workcenter_views.xml @@ -43,6 +43,12 @@ + + + + 绿色:正常,红色:故障,黄色:下线/暂停 + + diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 66afcc56..8066fa41 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -451,11 +451,11 @@ [('schedule_state', '=', '已排')] - + + + + + diff --git a/sf_manufacturing/views/tool_other_features_view.xml b/sf_manufacturing/views/tool_other_features_view.xml new file mode 100644 index 00000000..3af6d0e8 --- /dev/null +++ b/sf_manufacturing/views/tool_other_features_view.xml @@ -0,0 +1,158 @@ + + + + + 适合加工方式 + sf.suitable.machining.method + + + + + + + + + + 适合加工方式 + ir.actions.act_window + sf.suitable.machining.method + tree + + + + + + 刀尖特征 + sf.blade.tip.characteristics + + + + + + + + + + 刀尖特征 + ir.actions.act_window + sf.blade.tip.characteristics + tree + + + + + + 柄部类型 + sf.handle.type + + + + + + + + + + 柄部类型 + ir.actions.act_window + sf.handle.type + tree + + + + + + 走刀方向 + sf.cutting.direction + + + + + + + + + + 走刀方向 + ir.actions.act_window + sf.cutting.direction + tree + + + + + + 适合冷却液 + sf.suitable.coolant + + + + + + + + + + 适合冷却液 + ir.actions.act_window + sf.suitable.coolant + tree + + + + + + 切削速度Vc + sf.cutting.speed + + + + + + + + + + + + + + + + + + + + + + + 切削速度Vc + ir.actions.act_window + sf.cutting.speed + tree + + + + + + 每齿走刀量fz + sf.feed.per.tooth + + + + + + + + + + + + + + 每齿走刀量fz + ir.actions.act_window + sf.feed.per.tooth + tree + + \ No newline at end of file diff --git a/sf_plan/__init__.py b/sf_plan/__init__.py index 8134f974..23795ba3 100644 --- a/sf_plan/__init__.py +++ b/sf_plan/__init__.py @@ -2,3 +2,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import models +from . import controllers diff --git a/sf_plan/__manifest__.py b/sf_plan/__manifest__.py index 80a9d5fb..54f3b064 100644 --- a/sf_plan/__manifest__.py +++ b/sf_plan/__manifest__.py @@ -13,7 +13,7 @@ 'author': 'jikimo', 'website': 'https://sf.cs.jikimo.com', # 此处依赖sf_manufacturing是因为我要重写其中的一个字段operation_id的string,故需要sf_manufacturing先安装 - 'depends': ['mrp', 'mrp_workorder'], + 'depends': ['sf_manufacturing'], 'data': [ 'security/ir.model.access.csv', 'views/view.xml' @@ -24,7 +24,8 @@ 'web.assets_qweb': [ ], 'web.assets_backend': [ - 'sf_plan/static/src/scss/gannt_change.scss' + 'sf_plan/static/src/scss/gannt_change.scss', + 'sf_plan/static/src/css/button_color.css' ], }, diff --git a/sf_plan/controllers/__init__.py b/sf_plan/controllers/__init__.py new file mode 100644 index 00000000..6d07f482 --- /dev/null +++ b/sf_plan/controllers/__init__.py @@ -0,0 +1,2 @@ +from .import controllers + diff --git a/sf_plan/controllers/controllers.py b/sf_plan/controllers/controllers.py new file mode 100644 index 00000000..c600d76a --- /dev/null +++ b/sf_plan/controllers/controllers.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +import json +import logging +from odoo import http +from odoo.http import request + + +class ProductionPlan(http.Controller): + + @http.route('/api/production/plan', type='http', auth='none', methods=['GET', 'POST'], csrf=False, + cors="*") + def schedule_orders(self, **kw): + """ + 排程订单 + """ + logging.info('schedule_orders', kw) + diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index b5dad842..15af211a 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -1,25 +1,109 @@ # -*- coding: utf-8 -*- +import base64 +import json, requests from odoo import models, fields, api, _ from datetime import datetime, timedelta +from odoo.exceptions import UserError, ValidationError -# sf坯料预制排程 -class sf_pl_plan(models.Model): - _name = 'sf.pl.plan' - _description = 'sf_pl_plan' +# sf排程 +class sf_production_plan(models.Model): + _name = 'sf.production.plan' + # _inherit = 'mrp.production' + _description = 'sf_production_plan' + + state = fields.Selection([ + ('draft', '待排程'), + ('done', '已排程'), + ('processing', '已加工'), + ('finished', '已完成') + ], string='工单状态', tracking=True) + name = fields.Char(string='工单编号') + # selected = fields.Boolean(default=False) + # order_number = fields.Char(string='订单号') + order_deadline = fields.Datetime(string='订单交期') + production_id = fields.Many2one('mrp.production', '关联制造订单') + product_qty = fields.Float(string='数量', digits='Product Unit of Measure', required=True, default=0.0) + production_line_id = fields.Many2one('sf.production.line', string='生产线') + date_planned_start = fields.Datetime(string='计划开始时间', required=True, index=True, copy=False, + default=fields.Datetime.now) + date_planned_finished = fields.Datetime(string='计划结束时间') + # 排程设置selection(倒排,顺排,默认倒排) + schedule_setting = fields.Selection([ + ('reverse', '倒排'), ('positive', '顺排')], string='排程设置', default='reverse') + product_id = fields.Many2one('product.product', '关联产品') + origin = fields.Char(string='订单号') + # 加工时长 + process_time = fields.Float(string='加工时长', digits=(16, 2)) + # 实际加工时长、实际开始时间、实际结束时间 + actual_process_time = fields.Float(string='实际加工时长', digits=(16, 2)) + actual_start_time = fields.Datetime(string='实际开始时间') + actual_end_time = fields.Datetime(string='实际结束时间') + shift = fields.Char(string='班次') + - name = fields.Char(string='名称', size=64) # 序号、坯料编号、坯料名称、材质、数量、长度、宽度、厚度、直径、计划开始时间、计划结束时间、状态(已产出与待产出)、操作、创建人、创建时间、客户名称、订单号、行号、长度、宽度、厚度、直径、交货数量、交货日期 # sequence = fields.Integer(string='序号', required=True, copy=False, readonly=True, index=True, # default=lambda self: self.env['ir.sequence'].sudo().next_by_code('sf.pl.plan')) - sequence = fields.Integer(string='序号', required=True, copy=False, readonly=True, index=True) - current_operation_name = fields.Char(string='当前工序名称', size=64, default='坯料预制') + sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True) + current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划') + + + + + + + # state = fields.Selection([ + # ('未排程', '未排程'), ('已排程', '已排程')], string='State', copy=False, index=True, readonly=True, + # store=True, tracking=True) + + # orderpoint_id = fields.Many2one('stock.warehouse.orderpoint', compute='_compute_orderpoint_id') + # location_src_id = fields.Many2one('stock.location', 'Components Location', compute='_compute_orderpoint_id', active=False) + # location_dest_id = fields.Many2one('stock.location', 'Finished Products Location', compute='_compute_orderpoint_id') + # picking_type_id = fields.Many2one('stock.picking.type', 'Operation Type', compute='_compute_orderpoint_id') + # move_dest_ids = fields.One2many('stock.move', 'created_production_id', compute='_compute_orderpoint_id') @api.model - def create(self, vals): - if 'sequence' not in vals: - vals['sequence'] = self.env['sf.pl.plan'].search_count([]) + 1 - return super().create(vals) + def _compute_orderpoint_id(self): + pass + + def test_sale_order(self): + company_id = self.env.ref('base.main_company').sudo() + date = datetime.today() + aaa = self.env['sale.order'].with_user(self.env.ref("base.user_admin")).sale_order_create( + company_id, 'delivery_name', 'delivery_telephone', 'delivery_address', + date) + print('aaa', aaa) + + # 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了 + def action_view_production_schedule(self): + self.ensure_one() + if self.date_planned_start and self.date_planned_finished: + return None + elif self.date_planned_start and not self.date_planned_finished: + # 如果没有给出计划结束时间,则计划结束时间为计划开始时间+采购周期+缓冲期 + # 采购周期 + purchase_cycle = 3 + # 缓冲期 + buffer_period = 1 + # 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期 + self.date_planned_finished = self.date_planned_start + timedelta(days=purchase_cycle) + timedelta( + days=buffer_period) + self.state = '已排程' + return self.date_planned_finished + else: + return None + + def cancel_plan(self): + self.ensure_one() + self.date_planned_finished = None + self.state = 'draft' + + # @api.model + # def create(self, vals): + # if 'sequence' not in vals: + # vals['sequence'] = self.env['sf.production.plan'].search_count([]) + 1 + # return super().create(vals) def unlink(self): sequence_to_reorder = self.mapped('sequence') @@ -31,7 +115,7 @@ class sf_pl_plan(models.Model): # 生成编码 def _get_pl_no(self): - sf_pl_no = self.env['sf.pl.plan'].sudo().search( + sf_pl_no = self.env['sf.production.plan'].sudo().search( [('pl_no', '!=', '')], limit=1, order="id desc") @@ -55,81 +139,161 @@ class sf_pl_plan(models.Model): return num - pl_no = fields.Char(string='坯料编号', required=True, default=_get_pl_no, readonly=True) - pl_name = fields.Char(string='坯料名称', size=64, required=True) - material = fields.Many2one('sf.production.materials', string='材质', required=True) - quantity = fields.Float(string='数量', required=True) - length = fields.Float(string='长度', required=True) - width = fields.Float(string='宽度', required=True) - thickness = fields.Float(string='厚度', required=True) - diameter = fields.Float(string='直径', required=True) - plan_start_time = fields.Datetime(string='计划开始时间') - plan_end_time = fields.Datetime(string='计划结束时间') - state = fields.Selection([ - ('draft', '待产出'), - ('produce', '已产出'), - ], string='状态', copy=False, index=True, default='draft') - customer_name = fields.Char(string='客户名称', size=64) - order_no = fields.Char(string='订单号', size=64) - line_no = fields.Char(string='行号', size=64) - delivery_length = fields.Float(string='交货长度') - delivery_width = fields.Float(string='交货宽度') - delivery_thickness = fields.Float(string='交货厚度') - delivery_diameter = fields.Float(string='交货直径') - delivery_quantity = fields.Float(string='交货数量') - delivery_date = fields.Datetime(string='交货日期', related='plan_end_time', readonly=False, store=True) + # pl_no = fields.Char(string='坯料编号', required=True, default=_get_pl_no, readonly=True) + # pl_name = fields.Char(string='坯料名称', size=64, required=True) + # material = fields.Many2one('sf.production.materials', string='材质', required=True) + # quantity = fields.Float(string='数量', required=True) + # length = fields.Float(string='长度', required=True) + # width = fields.Float(string='宽度', required=True) + # thickness = fields.Float(string='厚度', required=True) + # diameter = fields.Float(string='直径', required=True) + # plan_start_time = fields.Datetime(string='计划开始时间') + # plan_end_time = fields.Datetime(string='计划结束时间') + # state = fields.Selection([ + # ('draft', '待排程'), + # ('produce', '已排程'), + # ('done', '已产出'), + # ], string='状态', copy=False, index=True, default='draft') + # customer_name = fields.Char(string='客户名称', size=64) + # order_no = fields.Char(string='订单号', size=64) + # line_no = fields.Char(string='行号', size=64) + # delivery_length = fields.Float(string='交货长度') + # delivery_width = fields.Float(string='交货宽度') + # delivery_thickness = fields.Float(string='交货厚度') + # delivery_diameter = fields.Float(string='交货直径') + # delivery_quantity = fields.Float(string='交货数量') + # delivery_date = fields.Datetime(string='交货日期', related='plan_end_time', readonly=False, store=True) # 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了 - def get_plan_end_time(self): - if self.plan_start_time and self.plan_end_time: - return None - elif self.plan_start_time and not self.plan_end_time: - # 如果没有给出计划结束时间,则计划结束时间为计划开始时间+采购周期+缓冲期 - # 采购周期 - purchase_cycle = 3 - # 缓冲期 - buffer_period = 1 - # 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期 - self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period) - return self.plan_end_time + def do_production_schedule(self): + if not self.production_line_id: + raise ValidationError("未选择生产线") else: - return None - # 后面要补充计划开始时间的计算方法 - # # 坯料预制时间 - # # pl_time = 0.5 - # # 采购周期 - # purchase_cycle = 3 - # # 缓冲期 - # buffer_period = 1 - # # 计划结束时间 = 计划开始时间 + 坯料预制时间 + 采购周期 + 缓冲期 - # # plan_end_time = plan_start_time + pl_time + purchase_cycle + buffer_period - # # 计划结束时间 = 计划开始时间(是一个datatime) + 采购周期(Float) + 缓冲期(Float) - # self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period) - # return self.plan_end_time + aa = self.env['mrp.production'].sudo().search([('name', '=', self.name)]) + workorder_time = 0 + print(aa.workorder_ids) + print(type(aa.workorder_ids)) + if aa.workorder_ids: + for item in aa.workorder_ids: + current_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', item.id)]) + workorder_time += current_workorder.duration_expected + print(workorder_time) + self.date_planned_finished = self.date_planned_start + timedelta(minutes=workorder_time) + self.state = 'done' + else: + self.date_planned_finished = self.date_planned_start + timedelta(days=3) + self.state = 'done' + return { + 'name': '排程甘特图', + 'type': 'ir.actions.act_window', + 'res_model': 'sf.production.plan', # 要跳转的模型名称 + 'view_mode': 'gantt,tree,form', # 要显示的视图类型,可以是'form', 'tree', 'kanban', 'graph', 'calendar', 'pivot'等 + 'target': 'current', # 跳转的目标窗口,可以是'current'或'new' + } + # if self.production_line_id: + # if self.plan_start_time and self.plan_end_time: + # return None + # elif self.plan_start_time and not self.plan_end_time: + # # 如果没有给出计划结束时间,则计划结束时间为计划开始时间+采购周期+缓冲期 + # # 采购周期 + # purchase_cycle = 3 + # # 缓冲期 + # buffer_period = 1 + # # 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期 + # self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta( + # days=buffer_period) + # self.state = 'produce' + # return self.plan_end_time + # else: + # return None + # # 后面要补充计划开始时间的计算方法 + # # # 坯料预制时间 + # # # pl_time = 0.5 + # # # 采购周期 + # # purchase_cycle = 3 + # # # 缓冲期 + # # buffer_period = 1 + # # # 计划结束时间 = 计划开始时间 + 坯料预制时间 + 采购周期 + 缓冲期 + # # # plan_end_time = plan_start_time + pl_time + purchase_cycle + buffer_period + # # # 计划结束时间 = 计划开始时间(是一个datatime) + 采购周期(Float) + 缓冲期(Float) + # # self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period) + # # return self.plan_end_time + # else: + # raise ValidationError('生产线为空!') + + def cancel_production_schedule(self): + self.date_planned_finished = False + self.state = 'draft' + return self.date_planned_finished + + def liucheng_cs(self): + res = {'order_number': '123', 'delivery_end_date': str(datetime.now()), + 'delivery_name': '机企猫', 'delivery_telephone': '18943919239', + 'delivery_address': '新时空大厦', + 'bfm_process_order_list': []} + aa = self.env['ir.attachment'].search([('id', '=', 631)]) + temp = self.env['product.template'].search([('id', '=', 47)]) + item = aa.datas.decode('utf-8') + val = { + 'model_long': 3, + 'model_width': 1, + 'model_height': 1, + 'model_volume': 3, + 'model_machining_precision': '0.10', + 'model_name': aa.name, + 'model_data': base64.b64encode(aa.datas).decode('utf-8'), + 'model_file': base64.b64encode(temp.model_file).decode('utf-8'), + 'texture_code': '001', + 'texture_type_code': '001001', + # 'surface_process_code': self.env['jikimo.surface.process']._json_surface_process_code(item), + 'process_parameters_code': 'R', + 'price': 20, + 'number': 2, + 'total_amount': 100, + 'remark': '这只是测试', + 'barcode': 123456789, + } + res['bfm_process_order_list'].append(val) + url = '/api/bfm_process_order/list' + res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list']) + try: + ret = requests.post(('http://localhost:1069' + url), json={}, data=res) + # aa = json.loads(ret.text) + print(ret) + except Exception as e: + raise UserError(e) + # # sf生产排程 # class sf_produce_plan(models.Model): # _name = 'sf.produce.plan' # _description = 'sf生产排程' - # # 重写create方法,使得创建坯料预制排程时,如果给出了计划结束时间,则计划开始时间为计划结束时间减去坯料预制时间 - # @api.model - # def create(self, vals): - # # 评估结束时间 - # vals['plan_end_time'] = self._get_plan_end_time(vals['plan_start_time'], vals['quantity']) - # return super(sf_pl_plan, self).create(vals) +# # 重写create方法,使得创建坯料预制排程时,如果给出了计划结束时间,则计划开始时间为计划结束时间减去坯料预制时间 +# @api.model +# def create(self, vals): +# # 评估结束时间 +# vals['plan_end_time'] = self._get_plan_end_time(vals['plan_start_time'], vals['quantity']) +# return super(sf_pl_plan, self).create(vals) - # # 当不设置计划结束时间时,增加计算计划结束时间的方法 - # @api.onchange('plan_start_time', 'quantity') - # def _onchange_plan_start_time(self): - # if self.plan_start_time and self.quantity: - # self.plan_end_time = self._get_plan_end_time(self.plan_start_time, self.quantity) - # - # # 计算计划结束时间 - # def _get_plan_end_time(self, plan_start_time, quantity): - # # 坯料预制时间 - # pl_time = 0.5 - # # 计划结束时间 = 计划开始时间 + 坯料预制时间 - # plan_end_time = plan_start_time + pl_time - # return plan_end_time - # +# # 当不设置计划结束时间时,增加计算计划结束时间的方法 +# @api.onchange('plan_start_time', 'quantity') +# def _onchange_plan_start_time(self): +# if self.plan_start_time and self.quantity: +# self.plan_end_time = self._get_plan_end_time(self.plan_start_time, self.quantity) +# +# # 计算计划结束时间 +# def _get_plan_end_time(self, plan_start_time, quantity): +# # 坯料预制时间 +# pl_time = 0.5 +# # 计划结束时间 = 计划开始时间 + 坯料预制时间 +# plan_end_time = plan_start_time + pl_time +# return plan_end_time +# + +# 机台作业计划 +class machine_work_schedule(models.Model): + _name = 'sf.machine.schedule' + _description = '机台作业计划' + + name = fields.Char(string='机台名') diff --git a/sf_plan/security/ir.model.access.csv b/sf_plan/security/ir.model.access.csv index 7effd7c3..3a1a20c9 100644 --- a/sf_plan/security/ir.model.access.csv +++ b/sf_plan/security/ir.model.access.csv @@ -1,5 +1,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sf_pl_plan,sf.pl.plan,model_sf_pl_plan,base.group_user,1,1,1,1 +access_sf_production_plan,sf.production.plan,model_sf_production_plan,base.group_user,1,1,1,1 +access_sf_machine_schedule,sf.machine.schedule,model_sf_machine_schedule,base.group_user,1,1,1,1 diff --git a/sf_plan/static/src/css/button_color.css b/sf_plan/static/src/css/button_color.css new file mode 100644 index 00000000..496a94fa --- /dev/null +++ b/sf_plan/static/src/css/button_color.css @@ -0,0 +1,8 @@ +.schedule_done { + background-color: #69c17d; + color: white; +} +.schedule_cancel { + background-color: #ffc54d; + color: black; +} \ No newline at end of file diff --git a/sf_plan/views/view.xml b/sf_plan/views/view.xml index 09ba627a..7878fa5f 100644 --- a/sf_plan/views/view.xml +++ b/sf_plan/views/view.xml @@ -1,103 +1,141 @@ - - sf.pl.plan.tree - sf.pl.plan + + sf.production.plan.tree + sf.production.plan - + + - - - - - - - - - + + + + + + + + + + + + - - sf.pl.plan.form - sf.pl.plan + + sf.production.plan.form + sf.production.plan - + - - + + + + + + - + - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - sf.pl.plan.gantt - sf.pl.plan + + + sf.production.plan.search + sf.production.plan - + + + + + + + + + + + + + + sf.production.plan.gantt + sf.production.plan + + - - - - - - + color="production_line_id" + decoration-success="state == 'done'" + progress_bar="name" + form_view_id="sf_production_plan_form" + default_scale="year" + scales="day,week,month,year" + precision="{'day': 'hour:quarter', 'week': 'day:half', 'month': 'day', 'year': 'month:quarter'}"> + + + + + @@ -113,20 +151,12 @@ - 坯料编号: - - - - 坯料名称: - + 名称: + 数量: - - - - 材质: - + 状态: @@ -142,19 +172,170 @@ - - 坯料预制计划 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sf.machine.schedule.tree + sf.machine.schedule + + + + + + + + + + 制造订单生产计划 ir.actions.act_window - sf.pl.plan - tree,form,gantt + sf.production.plan + gantt,tree,form + + + + + 制造订单生产计划 + ir.actions.act_window + sf.production.plan + tree,gantt,form + + + + + + + + + 制造订单 + ir.actions.act_window + mrp.production + tree,form + + + + 报价单 + ir.actions.act_window + sale.order + tree,form + + + + + 机台作业计划 + ir.actions.act_window + sf.machine.schedule + tree + + + 暂无机台作业计划 + + + 跟进请求的处理,并且和合作者沟通。 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sf_plan_management/__manifest__.py b/sf_plan_management/__manifest__.py index 40043146..66f1b72d 100644 --- a/sf_plan_management/__manifest__.py +++ b/sf_plan_management/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_manufacturing'], + 'depends': ['sf_plan'], 'data': [ 'security/ir.model.access.csv', # 'security/ir.model.access.csv', diff --git a/sf_plan_management/i18n/zh_CN.po b/sf_plan_management/i18n/zh_CN.po index 6e87cb88..d92d2937 100644 --- a/sf_plan_management/i18n/zh_CN.po +++ b/sf_plan_management/i18n/zh_CN.po @@ -21623,7 +21623,7 @@ msgstr "无包裹作业" #. module: mrp #: model:ir.ui.menu,name:mrp.menu_mrp_manufacturing msgid "Operations1" -msgstr "计划管理" +msgstr "制造订单" #. module: mrp_workorder #: model_terms:ir.ui.view,arch_db:mrp_workorder.mrp_workorder_view_form_inherit_workorder diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index 6ac7772c..95fb6342 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -135,8 +135,10 @@ class WorkLogSetting(models.Model): # 获取本年第一天和最后一天 start_date = datetime.now().replace(month=1, day=1).date() end_date = datetime.now().replace(month=12, day=31).date() + print(self.day_off_ids.mapped('name')) # 休息日列表 rest_days = self.chinese_weekdays_to_english(self.day_off_ids.mapped('name')) + print(rest_days) for single_date in self.daterange(start_date, end_date): is_workday = self.chinese_weekday_to_english(single_date.strftime("%A")) logging.info(f"每天的星期:{is_workday}") @@ -155,13 +157,13 @@ class WorkLogSetting(models.Model): :return: """ weekdays = { - '星期一': 'Monday', - '星期二': 'Tuesday', - '星期三': 'Wednesday', - '星期四': 'Thursday', - '星期五': 'Friday', - '星期六': 'Saturday', - '星期日': 'Sunday' + '星期一': 'Monday', 'Monday': 'Monday', + '星期二': 'Tuesday', 'Tuesday': 'Tuesday', + '星期三': 'Wednesday', 'Wednesday': 'Wednesday', + '星期四': 'Thursday', 'Thursday': 'Thursday', + '星期五': 'Friday', 'Friday': 'Friday', + '星期六': 'Saturday', 'Saturday': 'Saturday', + '星期日': 'Sunday', 'Sunday': 'Sunday', } english_weekdays = [] for chinese_weekday in chinese_weekdays: @@ -177,13 +179,13 @@ class WorkLogSetting(models.Model): :return: """ weekdays = { - '星期一': 'Monday', - '星期二': 'Tuesday', - '星期三': 'Wednesday', - '星期四': 'Thursday', - '星期五': 'Friday', - '星期六': 'Saturday', - '星期日': 'Sunday' + '星期一': 'Monday', 'Monday': 'Monday', + '星期二': 'Tuesday', 'Tuesday': 'Tuesday', + '星期三': 'Wednesday', 'Wednesday': 'Wednesday', + '星期四': 'Thursday', 'Thursday': 'Thursday', + '星期五': 'Friday', 'Friday': 'Friday', + '星期六': 'Saturday', 'Saturday': 'Saturday', + '星期日': 'Sunday', 'Sunday': 'Sunday', } weekday = weekdays.get(chinese_weekday) if weekday: diff --git a/sf_plan_management/views/menu_view.xml b/sf_plan_management/views/menu_view.xml index 6817e30c..491bb533 100644 --- a/sf_plan_management/views/menu_view.xml +++ b/sf_plan_management/views/menu_view.xml @@ -3,7 +3,7 @@ diff --git a/sf_plan_management/views/operations_rename_menu.xml b/sf_plan_management/views/operations_rename_menu.xml index 2bafbdc9..b7d41013 100644 --- a/sf_plan_management/views/operations_rename_menu.xml +++ b/sf_plan_management/views/operations_rename_menu.xml @@ -8,16 +8,26 @@ Process + + + + + + - 工单计划 - - + + + + + + + diff --git a/sf_sale/models/auto_quatotion_common.py b/sf_sale/models/auto_quatotion_common.py index 09ea3f0f..d1bdb65a 100644 --- a/sf_sale/models/auto_quatotion_common.py +++ b/sf_sale/models/auto_quatotion_common.py @@ -2,7 +2,7 @@ import logging from odoo.modules import get_resource_path from odoo import fields, models, api -from quatotion import readSql, feature_recognize, auto_quatotion +# from quatotion import readSql, feature_recognize, auto_quatotion __author__ = 'jinling.yang' _logger = logging.getLogger(__name__) @@ -24,14 +24,14 @@ class AutoQuatotion(models.Model): def get_process_time_db_path(self): return get_resource_path('sf_sale', 'models', 'process_time.db') - def get_auto_quatotion(self, stp_url, feature_full_path, process_time_db_path, model_code): - ''' - 通过打包好的.so库, - 以调用autoQuatotion库中Quatotion类, - 初始化后调用类的analyseShape方法对模型文件进行价格预测 - ''' - # 初始化自动报价类(输入特征数据库和加工时间数据库) - reader = auto_quatotion.Quatotion(feature_full_path, process_time_db_path) - # 获取价格、加工时间、尺寸、XYZ、翻面次数 - feature_info = reader.analyseShape(stp_url, InfoJson={}) - return feature_info + # def get_auto_quatotion(self, stp_url, feature_full_path, process_time_db_path, model_code): + # ''' + # 通过打包好的.so库, + # 以调用autoQuatotion库中Quatotion类, + # 初始化后调用类的analyseShape方法对模型文件进行价格预测 + # ''' + # # 初始化自动报价类(输入特征数据库和加工时间数据库) + # reader = auto_quatotion.Quatotion(feature_full_path, process_time_db_path) + # # 获取价格、加工时间、尺寸、XYZ、翻面次数 + # feature_info = reader.analyseShape(stp_url, InfoJson={}) + # return feature_info diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py index 84044f1c..5917a097 100644 --- a/sf_tool_management/models/tool_material_search.py +++ b/sf_tool_management/models/tool_material_search.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from odoo import fields, models, api, SUPERUSER_ID +from odoo.exceptions import ValidationError # 刀具物料搜索 @@ -9,22 +10,22 @@ class SfToolMaterialSearch(models.Model): sequence = fields.Integer('序号') code = fields.Char('编码') - name = fields.Char('名称') + name = fields.Char('名称', required=True) # 关联刀具类型 mrs_cutting_tool_type_id = fields.Many2one( 'sf.cutting.tool.type', '刀具类型', - domain="[('cutting_tool_material_id.name', '=', cutting_tool_material_name)]") + domain="[('cutting_tool_material_id.name', '=', cutting_tool_material_name)]", required=True) # 关联刀具物料名称 mrs_cutting_tool_material_name = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料名称', store=True) cutting_tool_type = fields.Char(related='mrs_cutting_tool_material_id.name', string='刀具物料类型', store=True) - mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌') + mrs_machine_brand_id = fields.Many2one('sf.machine.brand', '品牌', required=True) # 关联刀具型号 # mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', '刀具型号') # 关联刀具物料模型 mrs_cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', '刀具物料', - group_expand='_read_group_mrs_cutting_tool_material_ids') + group_expand='_read_group_mrs_cutting_tool_material_ids', required=True) cutting_tool_material_name = fields.Char(string='物料名称', invisible=True) @api.onchange('mrs_cutting_tool_material_id') @@ -74,19 +75,118 @@ class SfToolMaterialSearch(models.Model): # 整体式刀具特有字段 integral_code = fields.Char('整体式刀具编码', readonly=True) - integral_total_length = fields.Float('整体式刀具总长度(mm)') - integral_shank_length = fields.Float('整体式刀具柄部长度(mm)') - integral_blade_length = fields.Float('整体式刀具刃部长度(mm)') - integral_diameter = fields.Float('整体式刀具直径(mm)') - integral_blade_number = fields.Integer('整体式刀具刃数') - integral_front_angle = fields.Float('整体式刀具前角(°)') - integral_rear_angle = fields.Float('整体式刀具后角(°)') - integral_main_included_angle = fields.Float('整体式刀具主偏角(°)') - integral_accuracy = fields.Float('整体式刀具精度等级') - integral_hardness = fields.Float('整体式刀具加工硬度(HRC)') + integral_total_length = fields.Float('整体式刀具总长度(mm)', digits=(6, 1)) + integral_shank_length = fields.Float('整体式刀具柄部长度(mm)', digits=(6, 1)) + integral_blade_length = fields.Float('整体式刀具刃部长度(mm)', digits=(6, 1)) + integral_neck_length = fields.Float('整体式刀具颈部长度(mm)', digits=(6, 1)) + integral_shank_diameter = fields.Float('整体式刀具柄部直径(mm)', digits=(6, 1)) + integral_blade_diameter = fields.Float('整体式刀具刃部直径(mm)', digits=(6, 1)) + integral_neck_diameter = fields.Float('整体式刀具颈部直径(mm)', digits=(6, 1)) + integral_blade_number = fields.Integer('整体式刀具刃数(个)') + integral_blade_tip_diameter = fields.Float('整体式刀具刀尖直径(mm)', digits=(6, 1)) + integral_blade_tip_taper = fields.Float('整体式刀具刀尖锥度(°)', digits=(6, 1)) + integral_blade_helix_angle = fields.Float('整体式刀具刃部螺旋角(°)', digits=(6, 1)) + integral_blade_type = fields.Char('整体式刀具刃部类型') + integral_coarse_medium_fine = fields.Selection([('粗', '粗'), ('中', '中'), ('精', '精')], '整体式刀具粗/中/精') + # integral_blade_material = fields.Selection([('碳素钢', '碳素钢'), ('硬质合金', '硬质合金')], '整体式刀具刀具材质') + integral_hardness = fields.Integer('整体式刀具硬度(HRC)') integral_coating_material = fields.Char('整体式刀具涂层材质') - integral_nut = fields.Float('整体式刀具配对螺母(mm)') - integral_scope = fields.Char('整体式刀具适用范围') + integral_run_out_accuracy_max = fields.Float('整体式刀具端跳精度max', digits=(6,1)) + integral_run_out_accuracy_min = fields.Float('整体式刀具端跳精度min', digits=(6, 1)) + + suitable_machining_method_ids = fields.Many2many('sf.suitable.machining.method', + 'rel_suitable_machining_method', '适合加工方式') + blade_tip_characteristics_ids = fields.Many2many('sf.blade.tip.characteristics', + 'rel_blade_tip_characteristics', '刀尖特征') + handle_type_ids = fields.Many2many('sf.handle.type', 'rel_handle_type', '柄部类型') + cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction', '走刀方向') + suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant', '适合冷却液') + + cutting_speed_ids = fields.Many2many('sf.cutting.speed', string='切削速度Vc') + feed_per_tooth_ids = fields.Many2many('sf.feed.per.tooth', 'rel_feed_per_tooth_ids', '每齿走刀量fz') + + # @api.constrains('suitable_machining_method_ids') + # def _check_suitable_machining_method_ids(self): + # for record in self: + # if len(record.suitable_machining_method_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("适合加工方式不能为空!") + # + # @api.constrains('blade_tip_characteristics_ids') + # def _check_blade_tip_characteristics_ids(self): + # for record in self: + # if len(record.blade_tip_characteristics_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刀尖特征不能为空!") + # if len(record.blade_tip_characteristics_ids) > 1 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刀尖特征只能单选!") + # + # @api.constrains('handle_type_ids') + # def _check_handle_type_ids(self): + # for record in self: + # if len(record.handle_type_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部类型不能为空!") + # if len(record.handle_type_ids) > 1 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部类型只能单选!") + # + # @api.constrains('cutting_direction_ids') + # def _check_cutting_direction_ids(self): + # for record in self: + # if len(record.cutting_direction_ids) == 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("走刀方向不能为空!") + # + # @api.constrains('suitable_coolant_ids') + # def _check_suitable_coolant_ids(self): + # for record in self: + # if not record.suitable_coolant_ids and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("适合冷却液不能为空!") + # + # @api.constrains('integral_total_length') + # def _check_integral_total_length(self): + # if self.integral_total_length <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("总长度不能为0") + # + # @api.constrains('integral_shank_length') + # def _check_integral_shank_length(self): + # if self.integral_shank_length <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部长度不能为0") + # + # @api.constrains('integral_blade_length') + # def _check_integral_blade_length(self): + # if self.integral_blade_length <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刃部长度不能为0") + # + # @api.constrains('integral_blade_number') + # def _check_integral_blade_number(self): + # if self.integral_blade_number <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刃数不能为0") + # + # @api.constrains('integral_shank_diameter') + # def _check_integral_shank_diameter(self): + # if self.integral_shank_diameter <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("柄部直径不能为0") + # + # @api.constrains('integral_blade_diameter') + # def _check_integral_blade_diameter(self): + # if self.integral_blade_diameter <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("刃部直径不能为0") + # + # @api.constrains('integral_run_out_accuracy_min') + # def _check_integral_blade_diameter(self): + # if self.integral_run_out_accuracy_min <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("端跳精度最小(min)不能为0") + # + # @api.constrains('integral_run_out_accuracy_max') + # def _check_integral_run_out_accuracy_max(self): + # if self.integral_run_out_accuracy_max <= 0 and self.cutting_tool_type == '整体式刀具': + # raise ValidationError("端跳精度最大(max)不能为0") + + # integral_front_angle = fields.Float('整体式刀具前角(°)') + # integral_rear_angle = fields.Float('整体式刀具后角(°)') + # integral_main_included_angle = fields.Float('整体式刀具主偏角(°)') + # integral_accuracy = fields.Float('整体式刀具精度等级') + # integral_hardness = fields.Float('整体式刀具加工硬度(HRC)') + # integral_coating_material = fields.Char('整体式刀具涂层材质') + # integral_nut = fields.Float('整体式刀具配对螺母(mm)') + # integral_scope = fields.Char('整体式刀具适用范围') # 刀杆特有字段 bar_code = fields.Char('刀杆编码', readonly=True) @@ -193,4 +293,3 @@ class SfToolMaterialSearch(models.Model): warehouse_area = fields.Char('库区') warehouse_location = fields.Char('库位') three_d_model = fields.Many2one('ir.attachment', '3D模型') - diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 35338eac..7192c8f0 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -1080,7 +1080,7 @@ 功能刀具组装 sf.functional.tool.assembly - + @@ -1133,7 +1133,7 @@ 功能刀具组装 sf.functional.tool.assembly - + sf.tool.material.search - + @@ -33,19 +33,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -134,13 +134,13 @@ - + + + - - @@ -188,27 +188,69 @@ + - + + - - - + + + + - - - - - + + + + + + + + + + + (mm) + + + (mm) + + - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web_gantt/static/src/js/gantt_renderer.js b/web_gantt/static/src/js/gantt_renderer.js index 0627dd88..4ef5b845 100644 --- a/web_gantt/static/src/js/gantt_renderer.js +++ b/web_gantt/static/src/js/gantt_renderer.js @@ -637,8 +637,10 @@ export default AbstractRenderer.extend(WidgetAdapterMixin, { case 'day': return focusDate.format('dddd, MMMM DD, YYYY'); case 'week': - const dateStart = focusDate.clone().startOf('week').format('DD MMMM YYYY'); - const dateEnd = focusDate.clone().endOf('week').format('DD MMMM YYYY'); + // const dateStart = focusDate.clone().startOf('week').format('DD MMMM YYYY'); + const dateStart = focusDate.clone().startOf('week').format('YYYY MMMM DD '); + // const dateEnd = focusDate.clone().endOf('week').format('DD MMMM YYYY'); + const dateEnd = focusDate.clone().endOf('week').format('YYYY MMMM DD '); return _.str.sprintf('%s - %s', dateStart, dateEnd); case 'month': return focusDate.format('MMMM YYYY'); diff --git a/web_gantt/static/src/js/gantt_view.js b/web_gantt/static/src/js/gantt_view.js index 10c0fa83..5bc085b7 100644 --- a/web_gantt/static/src/js/gantt_view.js +++ b/web_gantt/static/src/js/gantt_view.js @@ -112,7 +112,7 @@ const GanttView = AbstractView.extend({ allowedScales = Object.keys(this.SCALES); } - const scale = params.context.default_scale || arch.attrs.default_scale || 'month'; + const scale = params.context.default_scale || arch.attrs.default_scale || 'week'; const initialDate = moment(params.context.initialDate || params.initialDate || arch.attrs.initial_date || new Date()); const offset = arch.attrs.offset; if (offset && scale) { diff --git a/web_gantt/static/src/xml/web_gantt.xml b/web_gantt/static/src/xml/web_gantt.xml index aa1e13bb..264a37ae 100644 --- a/web_gantt/static/src/xml/web_gantt.xml +++ b/web_gantt/static/src/xml/web_gantt.xml @@ -69,7 +69,7 @@ - +
- 设备故障日志 -
+ 设备故障日志 +
+ 暂无机台作业计划 +
+ 跟进请求的处理,并且和合作者沟通。 +