diff --git a/jikimo_frontend/__manifest__.py b/jikimo_frontend/__manifest__.py index 4165a503..a90a374e 100644 --- a/jikimo_frontend/__manifest__.py +++ b/jikimo_frontend/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['web'], + 'depends': ['web', 'purchase'], 'data': [ ], @@ -28,6 +28,13 @@ 'jikimo_frontend/static/src/views/list_nums/list_nums2.xml', 'jikimo_frontend/static/src/views/list_nums/list_nums3.xml', 'jikimo_frontend/static/src/js/custom_form_status_indicator.js', + 'jikimo_frontend/static/src/scss/rowno_in_tree.scss', + # 'jikimo_frontend/static/src/views/list_nums/list_render.xml', + 'jikimo_frontend/static/src/list/list_up_down_button.xml', + 'jikimo_frontend/static/src/list/custom_import.js', + 'jikimo_frontend/static/src/list/custom_width.js', + 'jikimo_frontend/static/src/views/list_nums/extent_purchase.xml', + ], }, diff --git a/jikimo_frontend/static/src/list/custom_width.js b/jikimo_frontend/static/src/list/custom_width.js new file mode 100644 index 00000000..512abc44 --- /dev/null +++ b/jikimo_frontend/static/src/list/custom_width.js @@ -0,0 +1,84 @@ +/** @odoo-module */ + +import {patch} from '@web/core/utils/patch'; +import {ListRenderer} from "@web/views/list/list_renderer" + +// var {patch} = require("web.utils") 这句话也行 + +patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { + // 你可以重写或者添加一些方法和属性 + // The following code manipulates the DOM directly to avoid having to wait for a + // render + patch which would occur on the next frame and cause flickering. + freezeColumnWidths() { + console.log('ccccccccccccccccccccccccccc') + if (!this.keepColumnWidths) { + this.columnWidths = null; + } + + const table = this.tableRef.el; + const headers = [...table.querySelectorAll("thead th:not(.o_list_actions_header)")]; + const column_num = headers.length + + if (!this.columnWidths || !this.columnWidths.length) { + // no column widths to restore + // Set table layout auto and remove inline style to make sure that css + // rules apply (e.g. fixed width of record selector) + table.style.tableLayout = "auto"; + headers.forEach((th) => { + th.style.width = null; + th.style.maxWidth = null; + }); + + this.setDefaultColumnWidths(column_num); + + // Squeeze the table by applying a max-width on largest columns to + // ensure that it doesn't overflow + this.columnWidths = this.computeColumnWidthsFromContent(); + table.style.tableLayout = "fixed"; + } + headers.forEach((th, index) => { + if (!th.style.width) { + th.style.width = `${Math.floor(this.columnWidths[index])}px`; + } + }); + }, + + setDefaultColumnWidths(column_num) { + const bbb = this.state.columns[0].name + const widths = this.state.columns.map((col) => this.calculateColumnWidth(col)); + const sumOfRelativeWidths = (widths + .filter(({ type }) => type === "relative") + .reduce((sum, { value }) => sum + value, 0)); + + // 获取数组的最后一项 + const lastItem = widths[widths.length - 1]; + + // 复制最后一项 + const newItem = { ...lastItem }; + + // 将新的对象添加到数组的末尾 + widths.push(newItem); + + // 判断销售的sequence + if (this.state.columns[0].name === "sequence") { + widths[1] = { type: "relative", value: 0.1 }; + } + + // 1 because nth-child selectors are 1-indexed, 2 when the first column contains + // the checkboxes to select records. + const columnOffset = this.hasSelectors ? 2 : 1; + widths.forEach(({ type, value }, i) => { + const headerEl = this.tableRef.el.querySelector(`th:nth-child(${i + columnOffset})`); + if (type === "absolute") { + if (this.isEmpty) { + headerEl.style.width = value; + } else { + headerEl.style.minWidth = value; + } + } else if (type === "relative" && this.isEmpty) { + headerEl.style.width = `${((value / column_num) * 100).toFixed(2)}%`; + } + }); + }, +} +); diff --git a/jikimo_frontend/static/src/list/list_up_down_button.xml b/jikimo_frontend/static/src/list/list_up_down_button.xml new file mode 100644 index 00000000..8bd28f5e --- /dev/null +++ b/jikimo_frontend/static/src/list/list_up_down_button.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jikimo_frontend/static/src/scss/custom_style.scss b/jikimo_frontend/static/src/scss/custom_style.scss index d3534180..c01ca6c9 100644 --- a/jikimo_frontend/static/src/scss/custom_style.scss +++ b/jikimo_frontend/static/src/scss/custom_style.scss @@ -17,6 +17,7 @@ div:has(.o_required_modifier) > label::before { } .my-image div { + width: 110px !important; height: 110px !important; } @@ -341,3 +342,15 @@ div:has(.o_required_modifier) > label::before { overflow: visible; } +.o_form_view { + .o_form_sheet_bg .o_form_sheet { + //max-width: none !important; + width: auto !important; + max-width: 98% !important; + } + .o_FormRenderer_chatterContainer { + max-width: none; + } +} + + diff --git a/jikimo_frontend/static/src/scss/rowno_in_tree.scss b/jikimo_frontend/static/src/scss/rowno_in_tree.scss new file mode 100644 index 00000000..c244ad7d --- /dev/null +++ b/jikimo_frontend/static/src/scss/rowno_in_tree.scss @@ -0,0 +1,4 @@ +.row_no { + width: 3.2% !important; + vertical-align: middle; +} diff --git a/jikimo_frontend/static/src/views/list_nums/extent_purchase.xml b/jikimo_frontend/static/src/views/list_nums/extent_purchase.xml new file mode 100644 index 00000000..f9c25a3d --- /dev/null +++ b/jikimo_frontend/static/src/views/list_nums/extent_purchase.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/jikimo_frontend/static/src/views/list_nums/list_nums.xml b/jikimo_frontend/static/src/views/list_nums/list_nums.xml index 6424887a..d2ad6824 100644 --- a/jikimo_frontend/static/src/views/list_nums/list_nums.xml +++ b/jikimo_frontend/static/src/views/list_nums/list_nums.xml @@ -5,7 +5,7 @@ - + diff --git a/jikimo_frontend/static/src/views/list_nums/list_render.xml b/jikimo_frontend/static/src/views/list_nums/list_render.xml new file mode 100644 index 00000000..7ba46848 --- /dev/null +++ b/jikimo_frontend/static/src/views/list_nums/list_render.xml @@ -0,0 +1,47 @@ + + diff --git a/sf_dlm/data/product_data.xml b/sf_dlm/data/product_data.xml index a31f97fc..f5d1904e 100644 --- a/sf_dlm/data/product_data.xml +++ b/sf_dlm/data/product_data.xml @@ -30,6 +30,25 @@ 夹具 + + 功能刀具 + 功能刀具 + + + + 功能刀具 + + + delivery + product + false + + + + serial + + CNC加工产品模板 diff --git a/sf_maintenance/models/sf_equipment_maintenance_standards.py b/sf_maintenance/models/sf_equipment_maintenance_standards.py index 55fea8b0..80ec2ba3 100644 --- a/sf_maintenance/models/sf_equipment_maintenance_standards.py +++ b/sf_maintenance/models/sf_equipment_maintenance_standards.py @@ -48,8 +48,8 @@ class SfEquipmentSaintenanceStandards(models.Model): string='适用设备', domain="[('category_id', '=', maintenance_equipment_category_id)]" ) - - maintenance_standards_ids = fields.One2many('maintenance.standards', 'equipment_maintenance_standards_id', string='维保项目') + maintenance_standards_ids = fields.One2many('maintenance.standards', 'equipment_maintenance_standards_id', + string='维保项目', widget='one2many_list') eq_maintenance_ids = fields.One2many('maintenance.equipment', 'eq_maintenance_id', string='保养设备') overhaul_ids = fields.One2many('maintenance.equipment', 'overhaul_id', string='检修设备') @@ -81,6 +81,7 @@ class SfSaintenanceStandards(models.Model): [('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='类别') equipment_maintenance_standards_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准') images = fields.One2many('maintenance.standard.image', 'standard_id', string='反馈图片') + maintenance_request_ids = fields.Many2many('maintenance.request', string='维保计划') Period = fields.Integer('周期/频次(天)') remark = fields.Char('备注说明') diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index 38ac5813..c44f283c 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -237,9 +237,9 @@ class SfMaintenanceEquipment(models.Model): item.brand_id = item.type_id.brand_id.id # AGV小车设备参数 - AGV_L = fields.Char('设备尺寸(长)') - AGV_W = fields.Char('设备尺寸(宽)') - AGV_H = fields.Char('设备尺寸(高)') + AGV_L = fields.Char('AGV尺寸(长)') + AGV_W = fields.Char('AGV尺寸(宽)') + AGV_H = fields.Char('AGV尺寸(高)') AGV_goods_L = fields.Char('载货尺寸(长)') AGV_goods_W = fields.Char('载货尺寸(宽)') AGV_goods_H = fields.Char('载货尺寸(高)') @@ -276,9 +276,9 @@ class SfMaintenanceEquipment(models.Model): detect_L = fields.Char('设备尺寸(长)') detect_W = fields.Char('设备尺寸(宽)') detect_H = fields.Char('设备尺寸(高)') - detect_x_axis = fields.Char('X轴') - detect_y_axis = fields.Char('Y轴') - detect_z_axis = fields.Char('Z轴') + detect_x_axis = fields.Char('检测X轴') + detect_y_axis = fields.Char('检测Y轴') + detect_z_axis = fields.Char('检测Z轴') detect_precision = fields.Char('测量精度') detect_measurement_mode = fields.Selection([('光栅尺', '光栅尺'), ('容栅', '容栅'), ('磁栅', '磁栅'), ('激光干涉仪', '激光干涉仪')], string='测量方式') detect_resolution = fields.Char('分辨率') @@ -295,8 +295,8 @@ class SfMaintenanceEquipment(models.Model): detect_object_field_of_view_max = fields.Char('物方视场(最大)') detect_object_field_of_view_min = fields.Char('物方视场(最小)') detect_power_requirements = fields.Char('电源要求') - detect_operating_temperature = fields.Char('环境温度') - detect_operating_humidity = fields.Char('环境湿度') + detect_operating_temperature = fields.Char('检测设备环境温度') + detect_operating_humidity = fields.Char('检测设备环境湿度') # 机器人设备参数 robot_gripping_of_workpieces_L = fields.Char('可抓取工件(长)') @@ -313,8 +313,8 @@ class SfMaintenanceEquipment(models.Model): robot_track_dimensions_H = fields.Char('轨道尺寸(高)') robot_drive_mode = fields.Char('驱动方式') robot_installation_method = fields.Selection([('置地式', '置地式'), ('壁挂式', '壁挂式'), ('倒挂式', '倒挂式')], string='安装方式') - robot_operating_temperature = fields.Char('环境温度') - robot_operating_humidity = fields.Char('环境湿度') + robot_operating_temperature = fields.Char('机器人环境温度') + robot_operating_humidity = fields.Char('机器人环境湿度') # 其他参数(所有设备) date_of_purchase = fields.Date('采购日期') diff --git a/sf_maintenance/models/sf_maintenance_requests.py b/sf_maintenance/models/sf_maintenance_requests.py index fad9e55f..330c1ece 100644 --- a/sf_maintenance/models/sf_maintenance_requests.py +++ b/sf_maintenance/models/sf_maintenance_requests.py @@ -25,7 +25,7 @@ class SfMaintenanceEquipmentCategory(models.Model): if not record.equipment_maintenance_id: record.equipment_maintenance_id = False - maintenance_standards = fields.Many2many('maintenance.standards', string='维保标准') + maintenance_standards = fields.Many2many('maintenance.standards', string='维保项目') @api.constrains('equipment_maintenance_id') def _check_equipment_maintenance_id(self): diff --git a/sf_maintenance/views/maintenance_request_views.xml b/sf_maintenance/views/maintenance_request_views.xml index 83bd6e44..1ad030b8 100644 --- a/sf_maintenance/views/maintenance_request_views.xml +++ b/sf_maintenance/views/maintenance_request_views.xml @@ -1,5 +1,63 @@ + + + + + maintenance.standards.form + maintenance.standards + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
+
+ + + + + + +
+
+ +
+
+ +
+
+ + + Maintenance Standards + maintenance.standards + tree,form + + @@ -21,17 +79,16 @@ - - - - - + + + + - + + - @@ -71,40 +128,5 @@ - - - - maintenance.standards.form - maintenance.standards - -
- - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
\ No newline at end of file diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml index 8efbdd55..b65b2235 100644 --- a/sf_manufacturing/data/stock_data.xml +++ b/sf_manufacturing/data/stock_data.xml @@ -22,6 +22,24 @@
+ + 组装后 + + internal + DJ-ZZ + true + + + + + + + + + + + + 外协入库 internal @@ -46,6 +64,16 @@ + + 刀具组装入库 + internal + true + + ZR + + + diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index 672741e3..71161b59 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -6,7 +6,7 @@ class ResProductCategory(models.Model): type = fields.Selection( [("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"), - ("夹具", "夹具")], + ("夹具", "夹具"), ("功能刀具", "功能刀具")], default="", string="类型") diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 064a1e20..e80a7783 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -63,6 +63,14 @@ class sf_production_plan(models.Model): # 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 get_import_templates(self): + """returns the xlsx import template file""" + return [{ + 'label': _('导入计划数据'), + 'template': '/sf_plan/static/src/xlsx/sf_production_plan.xlsx' + }] + @api.model def _compute_orderpoint_id(self): pass diff --git a/sf_plan/static/src/xlsx/sf_production_plan.xlsx b/sf_plan/static/src/xlsx/sf_production_plan.xlsx new file mode 100644 index 00000000..a82cab58 Binary files /dev/null and b/sf_plan/static/src/xlsx/sf_production_plan.xlsx differ diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 142ab8d1..02d723ce 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -12,8 +12,10 @@ class FunctionalCuttingToolEntity(models.Model): _name = 'sf.functional.cutting.tool.entity' _description = '功能刀具列表' - code = fields.Char('编码') - name = fields.Char('名称', required=True, size=20) + # code = fields.Char('序列号') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) + name = fields.Char(related='barcode_id.name') + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) 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='功能刀具类型', group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True) @@ -93,53 +95,6 @@ class FunctionalCuttingToolEntity(models.Model): return [(6, 0, functional_tool_model_ids)] -class FunctionalCuttingToolEntityCache(models.Model): - _name = 'sf.functional.cutting.tool.entity.cache' - _description = '功能刀具列表缓存' - - code = fields.Char('编码') - name = fields.Char('名称') - mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号') - - # 整体式刀具型号 - cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '整体式刀具')]) - - # 刀片型号 - cutting_tool_blade_model_id = fields.Many2one('product.product', string='刀片型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀片')]) - - # 刀杆型号 - cutting_tool_cutterbar_model_id = fields.Many2one('product.product', string='刀杆型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀杆')]) - - # 刀盘型号 - cutting_tool_cutterpad_model_id = fields.Many2one('product.product', string='刀盘型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀盘')]) - - # 刀柄型号 - cutting_tool_cutterhandle_model_id = fields.Many2one('product.product', string='刀柄型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '刀柄')]) - - # 夹头型号 - cutting_tool_cutterhead_model_id = fields.Many2one('product.product', string='夹头型号', readonly=True, - domain=[('cutting_tool_material_id', '=', '夹头')]) - - diameter = fields.Float('直径(mm)') - tool_grade = fields.Selection([('1', 'P1'), ('2', 'P2'), ('3', 'P3'), ('4', 'P4'), ('5', 'P5'), ('6', 'P6')], - string='刀具等级') - machining_accuracy = fields.Float('加工精度(mm)') - tool_length = fields.Float('装刀长(mm)') - blade_number = fields.Integer('刃数') - integral_blade_length = fields.Float('整体刃长(mm)') - effective_blade_length = fields.Float('有效刃长(mm)') - max_life = fields.Float('最大寿命值') - is_standard = fields.Selection([('1', '是'), ('0', '否')], '是否标准刀') - applicable_range = fields.Char('适用范围') - image = fields.Binary('图片') - - class FunctionalToolWarning(models.Model): _name = 'sf.functional.tool.warning' _description = '功能刀具预警' @@ -147,8 +102,12 @@ class FunctionalToolWarning(models.Model): functional_cutting_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', readonly=True) functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True) - code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') + # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True, + related='functional_cutting_tool_id.barcode_id') name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name') + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True, + related='functional_cutting_tool_id.functional_tool_name_id') mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, related='functional_cutting_tool_id.mrs_cutting_tool_type_id') @@ -261,8 +220,12 @@ class RealTimeDistributionOfFunctionalTools(models.Model): if record: record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id - code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') + # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True, + related='functional_cutting_tool_id.barcode_id') name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name') + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True, + related='functional_cutting_tool_id.functional_tool_name_id') # mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, # related='functional_cutting_tool_id.mrs_cutting_tool_type_id') @@ -371,8 +334,12 @@ class InboundAndOutboundRecordsOfFunctionalTools(models.Model): if record: record.mrs_cutting_tool_type_id = record.functional_cutting_tool_id.mrs_cutting_tool_type_id.id - code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') + # code = fields.Char('编码', readonly=True, related='functional_cutting_tool_id.code') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True, + related='functional_cutting_tool_id.barcode_id') name = fields.Char('名称', invisible=True, readonly=True, related='functional_cutting_tool_id.name') + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True, + related='functional_cutting_tool_id.functional_tool_name_id') # 整体式刀具型号 cutting_tool_integral_model_id = fields.Many2one('product.product', string='整体式刀具型号', readonly=True, @@ -470,35 +437,28 @@ class MachineTableToolChangingApply(models.Model): _name = 'sf.machine.table.tool.changing.apply' _description = '机床换刀申请' - # apply_to_tool_change_ids = fields.One2many( - # 'sf.tool.change.requirement.information', - # 'tool_change_to_apply_id', - # string='换刀需求信息', - # attrs="{'invisible': 1}") - name = fields.Many2one('maintenance.equipment', string='CNC机床', required=True, readonly=False, group_expand='_read_group_names') machine_table_type_id = fields.Many2one('maintenance.equipment.category', string='机床类型', readonly=True, compute='_compute_machine_table_type_id') - machine_tool_code = fields.Char(string='机台号', invisible=True, readonly=True, compute='_compute_machine_tool_code') + machine_tool_code = fields.Char(string='机台号', store=True, invisible=True, readonly=True) + cutter_spacing_code = fields.Char(string='刀位号', readonly=False, required=True) @api.depends('name') def _compute_machine_table_type_id(self): for record in self: if record: record.machine_table_type_id = record.name.category_id.id - - @api.depends('name') - def _compute_machine_tool_code(self): - for record in self: - if record: record.machine_tool_code = record.name.code + else: + record.machine_table_type_id = None + record.machine_tool_code = None - 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) - functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, - compute='_compute_functional_tool_name_id') + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', + domain=[('product_id.name', '=', '功能刀具')]) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', + domain=[('name', '=', '功能刀具')]) + functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') diameter = fields.Char(string='直径(mm)', readonly=False) coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=False) @@ -510,8 +470,9 @@ class MachineTableToolChangingApply(models.Model): functional_tool_status = fields.Selection([('正常', '正常'), ('异常', '异常')], string='功能刀具状态', default='正常', readonly=False) - replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True) - replacement_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='待换功能刀具名称', readonly=True) + # replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True) + assembly_order_code = fields.Char(string='组装单编码', readonly=True) + replacement_tool_name_id = fields.Many2one('product.product', string='待换功能刀具名称', readonly=True) replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型', readonly=True) replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], @@ -522,22 +483,15 @@ class MachineTableToolChangingApply(models.Model): reason_for_applying = fields.Char(string='申请原因', readonly=True) remark = fields.Char(string='备注说明', readonly=False) - status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移')], string='操作状态', default='0') + status = fields.Selection([('0', '未操作'), ('1', '已换刀申请'), ('2', '已转移'), ('3', '已组装')], string='操作状态', default='0') - sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装') + sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True) @api.model def _read_group_names(self, categories, domain, order): names = categories._search([], order=order, access_rights_uid=SUPERUSER_ID) return categories.browse(names) - @api.depends('functional_tool_name_id') - def _compute_functional_tool_name_id(self): - for record in self: - if record: - record.functional_tool_code = record.functional_tool_name_id.code - record.functional_tool_type_id = record.functional_tool_name_id.mrs_cutting_tool_type_id.id - @api.onchange('functional_tool_status') def automation_apply_for_tool_change(self): """ @@ -549,7 +503,6 @@ class MachineTableToolChangingApply(models.Model): if self.functional_tool_status == '异常': self.env['sf.machine.table.tool.changing.apply'].search([ ('name', '=', self.name.id)]).write({ - 'replacement_tool_code': self.functional_tool_code, 'replacement_tool_name_id': self.functional_tool_name_id.id, 'replacement_tool_type_id': self.functional_tool_type_id.id, 'replacement_tool_coarse_middle_thin': self.coarse_middle_thin, @@ -563,7 +516,6 @@ class MachineTableToolChangingApply(models.Model): # 新建组装任务 self.env['sf.functional.tool.assembly'].create({ - 'functional_tool_code': self.functional_tool_code, 'name': self.functional_tool_name_id, 'functional_tool_type_id': self.functional_tool_type_id.id, 'functional_tool_diameter': self.diameter, @@ -596,12 +548,11 @@ class MachineTableToolChangingApply(models.Model): """ # 撤回功能刀具组装创建的任务 self.env['sf.functional.tool.assembly'].search( - [('functional_tool_code', '=', self.replacement_tool_code), + [('assembly_order_code', '=', self.assembly_order_code), ('loading_task_source', '=', '1')]).unlink() # 撤回数据更新 self.env['sf.machine.table.tool.changing.apply'].search([('name', '=', self.name.id)]).write({ - 'replacement_tool_code': None, 'replacement_tool_name_id': None, 'replacement_tool_type_id': None, 'replacement_tool_coarse_middle_thin': None, @@ -624,16 +575,6 @@ class MachineTableToolChangingApply(models.Model): 'status': '0' }) - def open_sf_functional_tool_assembly(self): - """ - 跳转到功能刀具组装界面按键功能 - :return: - """ - action = self.env.ref('sf_tool_management.sf_functional_tool_assembly_view_act') - result = action.read()[0] - result['domain'] = [('sf_machine_table_tool_changing_apply_id', '=', self.id)] - return result - class CAMWorkOrderProgramKnifePlan(models.Model): _name = 'sf.cam.work.order.program.knife.plan' @@ -642,8 +583,10 @@ class CAMWorkOrderProgramKnifePlan(models.Model): name = fields.Char(string='工单任务编号', readonly=False) cam_procedure_code = fields.Char(string='CAM程序编号', readonly=False) cam_cutter_spacing_code = fields.Char(string='CAM刀位号', readonly=False) - functional_tool_code = fields.Char(string='功能刀具编码', readonly=False) - functional_tool_name_id = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=False) + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', + domain=[('product_id.name', '=', '功能刀具')]) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', + domain=[('name', '=', '功能刀具')]) 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, group_expand='_read_group_machine_table_name_ids') @@ -671,7 +614,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): reason_for_applying = fields.Char(string='申请原因', readonly=False) remark = fields.Char(string='备注说明', readonly=False) - sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装') + sf_functional_tool_assembly_id = fields.Many2one('sf.functional.tool.assembly', '功能刀具组装', readonly=True) def apply_for_tooling(self): """ @@ -679,8 +622,8 @@ class CAMWorkOrderProgramKnifePlan(models.Model): :return: """ record = self.env['sf.functional.tool.assembly'].create({ - 'functional_tool_code': self.functional_tool_code, - 'name': self.functional_tool_name_id.id, + 'barcode_id': self.barcode_id.id, + 'functional_tool_name_id': self.functional_tool_name_id.id, 'functional_tool_type_id': self.functional_tool_type_id.id, 'functional_tool_diameter': self.diameter, 'functional_tool_length': self.tool_loading_length, @@ -699,7 +642,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): # 将计划执行状态改为执行中 self.env['sf.cam.work.order.program.knife.plan'].search( - [('functional_tool_code', '=', self.functional_tool_code)]).write({ + [('barcode_id', '=', self.barcode_id.id)]).write({ 'plan_execute_status': '1', 'applicant': self.env.user.name}) @@ -709,35 +652,27 @@ class CAMWorkOrderProgramKnifePlan(models.Model): :return: """ self.env['sf.functional.tool.assembly'].search( - [('functional_tool_code', '=', self.functional_tool_code), + [('barcode_id', '=', self.barcode_id.id), ('loading_task_source', '=', '0')]).unlink() # 将计划执行状态改为待执行,同时清除申请人、功能刀具组装字段数据 self.env['sf.cam.work.order.program.knife.plan'].search( - [('functional_tool_code', '=', self.functional_tool_code)]).write({ + [('barcode_id', '=', self.barcode_id.id)]).write({ 'plan_execute_status': '0', 'applicant': None, 'sf_functional_tool_assembly_id': None, }) - def open_sf_functional_tool_assembly(self): - """ - 跳转到功能刀具组装界面按键功能 - :return: - """ - action = self.env.ref('sf_tool_management.sf_functional_tool_assembly_view_act') - result = action.read()[0] - result['domain'] = [('sf_cam_work_order_program_knife_plan_id', '=', self.id)] - return result - class FunctionalToolAssembly(models.Model): _name = 'sf.functional.tool.assembly' - _description = '功能刀具组装' + _description = '功能刀具组装单' _order = 'use_tool_time asc' - functional_tool_code = fields.Char(string='功能刀具编码', readonly=True) - name = fields.Many2one('sf.functional.cutting.tool', string='功能刀具名称', readonly=True) + assembly_order_code = fields.Char(string='编码', readonly=True) + barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', readonly=True) + functional_tool_name_id = fields.Many2one('product.product', string='功能刀具名称', readonly=True) + name = fields.Char(string='名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, group_expand='_read_group_functional_tool_type_ids') @@ -787,6 +722,58 @@ class FunctionalToolAssembly(models.Model): chuck_name = fields.Char('夹头名称', readonly=True) sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True) + @api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id') + def _compute_auto_fill(self): + for record in self: + if record.integral_code_id: + record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_material_id.id + record.integral_name = record.integral_code_id.product_id.name + record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id + else: + record.cutting_tool_integral_model_id = None + record.integral_name = None + record.sf_tool_brand_id_1 = None + if record.blade_code_id: + record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_material_id.id + record.blade_name = record.blade_code_id.product_id.name + record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id + else: + record.cutting_tool_blade_model_id = None + record.blade_name = None + record.sf_tool_brand_id_2 = None + if record.bar_code_id: + record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_material_id.id + record.bar_name = record.bar_code_id.product_id.name + record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id + else: + record.cutting_tool_cutterbar_model_id = None + record.bar_name = None + record.sf_tool_brand_id_3 = None + if record.pad_code_id: + record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_material_id.id + record.pad_name = record.pad_code_id.product_id.name + record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id + else: + record.cutting_tool_cutterpad_model_id = None + record.pad_name = None + record.sf_tool_brand_id_4 = None + if record.handle_code_id: + record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_material_id.id + record.handle_name = record.handle_code_id.product_id.name + record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id + else: + record.cutting_tool_cutterhandle_model_id = None + record.handle_name = None + record.sf_tool_brand_id_5 = None + if record.chuck_code_id: + record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_material_id.id + record.chuck_name = record.chuck_code_id.product_id.name + record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id + else: + record.cutting_tool_cutterhead_model_id = None + record.chuck_name = None + record.sf_tool_brand_id_6 = None + coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) tool_loading_length = fields.Char(string='装刀长(mm)', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -795,11 +782,12 @@ class FunctionalToolAssembly(models.Model): cut_length = fields.Char(string='已切削长度(mm)', readonly=True) cut_number = fields.Char(string='已切削次数', readonly=True) - loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀')], string='装刀任务来源', readonly=True) + loading_task_source = fields.Selection([('0', 'CAM装刀'), ('1', '机台换刀'), ('2', '按库存组装')], + string='装刀任务来源', readonly=True) applicant = fields.Char(string='申请人', readonly=True) reason_for_applying = fields.Char(string='申请原因', readonly=True) apply_time = fields.Datetime(string='申请时间', default=fields.Datetime.now(), readonly=True) - assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装'), ('2', '已出库')], string='组装状态', + assemble_status = fields.Selection([('0', '待组装'), ('1', '已组装')], string='组装状态', default='0', readonly=True) use_tool_time = fields.Datetime(string='用刀时间', readonly=True) production_line_name_id = fields.Many2one('sf.production.line', string='产线名称', readonly=False) @@ -814,159 +802,33 @@ class FunctionalToolAssembly(models.Model): remark = fields.Char(string='备注说明', readonly=True) check_box_1 = fields.Boolean(string='复选框', default=False, readonly=False) - sf_machine_table_tool_changing_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', '机床换刀申请') + sf_machine_table_tool_changing_apply_id = fields.Many2one('sf.machine.table.tool.changing.apply', '机床换刀申请', readonly=True) sf_cam_work_order_program_knife_plan_id = fields.Many2one('sf.cam.work.order.program.knife.plan', - 'CAM工单程序用刀计划') + 'CAM工单程序用刀计划', readonly=True, ) - def open_sf_cam_work_order_program_knife_plan(self): + def _get_code(self, loading_task_source): """ - 跳转到CAM工单程序用刀计划界面按钮功能 + 自动生成组装单编码 """ - action = self.env.ref('sf_tool_management.sf_cam_work_order_program_knife_plan_view_act') - result = action.read()[0] - result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)] - return result - - def open_sf_machine_table_tool_changing_apply(self): - """ - 跳转到机床换刀申请界面按钮功能 - """ - action = self.env.ref('sf_tool_management.sf_machine_table_tool_changing_apply_view_act') - result = action.read()[0] - result['domain'] = [('sf_functional_tool_assembly_id', '=', self.id)] - return result - - def cancel_functional_tool_assembly(self): - """ - 取消功能刀具组装 - :return: - """ - if self.new_former == '0': - # 如果是新刀,则删除功能刀具列表、功能刀具预警、功能刀具实时分布、功能刀具出入库记录的记录 - record = self.env['sf.functional.cutting.tool.entity'].search([ - ('code', '=', self.functional_tool_code)]) - self.env['sf.functional.tool.warning'].search( - [('functional_cutting_tool_id', '=', record.id)]).unlink() - self.env['sf.real.time.distribution.of.functional.tools'].search( - [('functional_cutting_tool_id', '=', record.id)]).unlink() - self.env['sf.inbound.and.outbound.records.of.functional.tools'].search( - [('functional_cutting_tool_id', '=', record.id)]).unlink() - record.unlink() + new_time = str(fields.Date.today()) + datetime = new_time[2:4] + new_time[5:7] + new_time[-2:] + functional_tool_assembly = self.env['sf.functional.tool.assembly'].sudo().search( + [('loading_task_source', '=', loading_task_source), + ('assembly_order_code', 'ilike', datetime)], limit=1, order="id desc") + if not functional_tool_assembly: + num = "%03d" % 1 else: - # 获取功能刀具缓存信息 - record = self.env['sf.functional.cutting.tool.entity.cache'].search([ - ('code', '=', self.functional_tool_code)], limit=1) - # # 删除现有功能刀具列表记录 - # self.env['sf.functional.cutting.tool.entity'].search([ - # ('code', '=', self.functional_tool_code)]).unlink() - # 修改功能刀具列表信息 - self.env['sf.functional.cutting.tool.entity'].search([ - ('code', '=', self.functional_tool_code)]).sudo().write({ - 'code': record.code, - 'name': record.name, - 'mrs_cutting_tool_type_id': record.mrs_cutting_tool_type_id.id, - 'mrs_cutting_tool_model_id': record.mrs_cutting_tool_model_id.id, - 'cutting_tool_integral_model_id': record.cutting_tool_integral_model_id.id, - 'cutting_tool_blade_model_id': record.cutting_tool_blade_model_id.id, - 'cutting_tool_cutterbar_model_id': record.cutting_tool_cutterbar_model_id.id, - 'cutting_tool_cutterpad_model_id': record.cutting_tool_cutterpad_model_id.id, - 'cutting_tool_cutterhandle_model_id': record.cutting_tool_cutterhandle_model_id.id, - 'cutting_tool_cutterhead_model_id': record.cutting_tool_cutterhead_model_id.id, - 'diameter': record.diameter, - 'tool_grade': record.tool_grade, - 'machining_accuracy': record.machining_accuracy, - 'tool_length': record.tool_length, - 'blade_number': record.blade_number, - 'integral_blade_length': record.integral_blade_length, - 'effective_blade_length': record.effective_blade_length, - 'max_life': record.max_life, - 'is_standard': record.is_standard, - 'applicable_range': record.applicable_range, - 'image': record.image, - }) - # 删除功能刀具缓存信息 - self.env['sf.functional.cutting.tool.entity.cache'].search([ - ('code', '=', self.functional_tool_code)]).unlink() - - # 修改功能刀具组装的组装信息 - self.env['sf.functional.tool.assembly'].search([ - ('machine_tool_name_id', '=', self.machine_tool_name_id.id), - ('cutter_spacing_code', '=', self.cutter_spacing_code), - ('assemble_status', '=', '1') - ]).write({ - 'cutting_tool_integral_model_id': None, - 'integral_code': None, - 'integral_name': None, - 'sf_tool_brand_id_1': None, - 'cutting_tool_blade_model_id': None, - 'blade_code': None, - 'blade_name': None, - 'sf_tool_brand_id_2': None, - 'cutting_tool_cutterbar_model_id': None, - 'bar_code': None, - 'bar_name': None, - 'sf_tool_brand_id_3': None, - 'cutting_tool_cutterpad_model_id': None, - 'pad_code': None, - 'pad_name': None, - 'sf_tool_brand_id_4': None, - 'cutting_tool_cutterhandle_model_id': None, - 'handle_code': None, - 'handle_name': None, - 'sf_tool_brand_id_5': None, - 'cutting_tool_cutterhead_model_id': None, - 'chuck_code': None, - 'chuck_name': None, - 'sf_tool_brand_id_6': None, - 'coarse_middle_thin': None, - 'tool_loading_length': None, - 'new_former': None, - 'reference_length': None, - 'cut_time': None, - 'cut_length': None, - 'cut_number': None, - 'assemble_status': '0', - 'tool_loading_person': None, - 'tool_loading_time': None - }) - - def show_popup(self): - """ - 单个功能刀具出库 - :return: - """ - self.env['sf.delivery.of.cargo.from.storage'].search([]).unlink() - - vals = self.env['sf.functional.tool.assembly'].search( - [('check_box_1', '=', True), ('assemble_status', '=', '1')]) - if vals: - for val in vals: - self.env['sf.delivery.of.cargo.from.storage'].create({ - 'functional_tool_code': val.functional_tool_code, - 'name': val.name.id, - 'functional_tool_type_id': val.functional_tool_type_id.id, - 'production_line_name_id': val.production_line_name_id.id, - 'machine_tool_code': val.machine_tool_code, - 'receive_person': val.receive_person, - 'receive_time': val.receive_time}) + m = int(functional_tool_assembly.assembly_order_code[-3:]) + 1 + num = "%03d" % m + if loading_task_source == '0': + code = 'CAMZZD' + datetime + str(num) + elif loading_task_source == '1': + code = 'JTZZD' + datetime + str(num) + elif loading_task_source == '2': + code = 'MTSZZD' + datetime + str(num) else: - self.env['sf.delivery.of.cargo.from.storage'].create({ - 'functional_tool_code': self.functional_tool_code, - 'name': self.name.id, - 'functional_tool_type_id': self.functional_tool_type_id.id, - 'production_line_name_id': self.production_line_name_id.id, - 'machine_tool_code': self.machine_tool_code, - 'receive_person': self.receive_person, - 'receive_time': self.receive_time}) - - return { - 'type': 'ir.actions.act_window', - 'name': '功能刀具出库', - 'res_model': 'sf.delivery.of.cargo.from.storage', - 'view_mode': 'tree', - 'view_type': 'tree', - 'target': 'new' - } + code = False + return code def automated_assembly(self): """ @@ -985,3 +847,12 @@ class FunctionalToolAssembly(models.Model): todo 组装单打印 :return: """ + + @api.model_create_multi + def create(self, vals): + obj = super(FunctionalToolAssembly, self).create(vals) + if obj.loading_task_source: + code = self._get_code(obj.loading_task_source) + obj.assembly_order_code = code + obj.name = code + return obj \ No newline at end of file diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index 5a336eff..fa10d0c5 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -1,6 +1,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_sf_functional_cutting_tool_entity,sf.functional.cutting.tool.entity,model_sf_functional_cutting_tool_entity,base.group_user,1,1,1,1 -access_sf_functional_cutting_tool_entity_cache,sf.functional.cutting.tool.entity.cache,model_sf_functional_cutting_tool_entity_cache,base.group_user,1,1,1,1 access_sf_functional_tool_warning,sf.functional.tool.warning,model_sf_functional_tool_warning,base.group_user,1,1,1,1 access_sf_real_time_distribution_of_functional_tools,sf.real.time.distribution.of.functional.tools,model_sf_real_time_distribution_of_functional_tools,base.group_user,1,1,1,1 access_sf_inbound_and_outbound_records_of_functional_tools,sf.inbound.and.outbound.records.of.functional.tools,model_sf_inbound_and_outbound_records_of_functional_tools,base.group_user,1,1,1,1 @@ -15,7 +14,6 @@ access_sf_tool_transfer_request_information,sf.tool.transfer.request.information access_sf_functional_tool_assembly,sf.functional.tool.assembly,model_sf_functional_tool_assembly,base.group_user,1,1,1,1 access_sf_functional_tool_assembly_order,sf.functional.tool.assembly.order,model_sf_functional_tool_assembly_order,base.group_user,1,1,1,1 -access_sf_delivery_of_cargo_from_storage,sf.delivery.of.cargo.from.storage,model_sf_delivery_of_cargo_from_storage,base.group_user,1,1,1,1 access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_search,base.group_user,1,1,1,1 diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 2396af30..c1495df7 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -7,8 +7,8 @@ sf.functional.cutting.tool.entity - - + + @@ -29,14 +29,13 @@

- +

- + - sf.functional.cutting.tool.entity - - + + @@ -179,9 +178,9 @@ sf.functional.tool.warning - - - + + + @@ -209,12 +208,12 @@

- +

- + sf.functional.tool.warning - - + + @@ -338,10 +337,9 @@ sf.real.time.distribution.of.functional.tools - - + + - @@ -371,12 +369,12 @@

- +

- + sf.real.time.distribution.of.functional.tools - - + + @@ -496,8 +494,8 @@ sf.inbound.and.outbound.records.of.functional.tools - - + + @@ -521,12 +519,12 @@

- +

- + sf.inbound.and.outbound.records.of.functional.tools - - + + @@ -700,9 +698,9 @@ - + - + @@ -714,11 +712,10 @@ type="action" context="{ 'default_name':name, 'default_machine_tool_code': machine_tool_code, - 'default_functional_tool_code': functional_tool_code, + 'default_barcode_id': barcode_id, 'default_functional_tool_name_id': functional_tool_name_id, 'default_functional_tool_type_id': functional_tool_type_id, 'default_cutter_spacing_code': cutter_spacing_code, - 'default_replacement_tool_code': functional_tool_code, 'default_replacement_tool_name_id': functional_tool_name_id, 'default_replacement_tool_type_id': functional_tool_type_id, 'default_replacement_tool_coarse_middle_thin': coarse_middle_thin}" @@ -731,15 +728,13 @@ context="{ 'default_CNC_machine_table_id':name, 'default_machine_tool_code': machine_tool_code, 'default_cutter_spacing_code': cutter_spacing_code, - 'default_functional_tool_code': functional_tool_code, + 'default_barcode_id': barcode_id, 'default_functional_tool_name_id': functional_tool_name_id, 'default_functional_tool_type_id': functional_tool_type_id}" class="btn-primary" attrs="{'invisible': [('status', '!=', '0')]}" /> -