From 2c1a101c24efd94d9eff4f15542a260a7bf0e06f Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 28 Nov 2023 16:42:19 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=BA=93=E5=AD=98=E8=B4=A7=E6=9E=B6?= =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E4=BF=AE=E6=94=B9=E5=9F=BA=E6=9C=AC=E5=AE=8C?= =?UTF-8?q?=E6=88=90=EF=BC=8C=E6=8E=A8=E9=80=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_warehouse/__manifest__.py | 1 + sf_warehouse/models/model.py | 185 +++++++++++++++--- .../views/change_stock_move_views.xml | 41 ++++ sf_warehouse/views/shelf_location.xml | 183 ++++++++--------- sf_warehouse/views/view.xml | 6 +- 5 files changed, 279 insertions(+), 137 deletions(-) create mode 100644 sf_warehouse/views/change_stock_move_views.xml diff --git a/sf_warehouse/__manifest__.py b/sf_warehouse/__manifest__.py index 0f241b90..45143693 100644 --- a/sf_warehouse/__manifest__.py +++ b/sf_warehouse/__manifest__.py @@ -16,6 +16,7 @@ 'security/ir.model.access.csv', 'views/view.xml', 'views/shelf_location.xml', + 'views/change_stock_move_views.xml', ], 'demo': [ ], diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 5e83ff1f..29b8aa2e 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -185,33 +185,29 @@ class SfLocation(models.Model): """ 当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量 """ - if self.location_type == '货架': - for i in range(self.shelf_layer): - for j in range(self.layer_capacity): - self.create({ - 'name': self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置', - 'location_id': self.id, - 'location_type': '货位', - 'barcode': self.generate_barcode(i, j), - 'location_status': '空闲' - }) + pass + # if self.location_type == '货架': + # for i in range(self.shelf_layer): + # for j in range(self.layer_capacity): + # self.create({ + # 'name': self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置', + # 'location_id': self.id, + # 'location_type': '货位', + # 'barcode': self.generate_barcode(i, j), + # 'location_status': '空闲' + # }) def generate_barcode(self, i, j): """ 生成货位条码 """ - # 这里是你生成barcode的代码 - # area_type_barcode = self.location_id.barcode - area_type_barcode = self.barcode - i_str = str(i + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0 - j_str = str(j + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0 - return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + i_str + '-' + j_str - - # def generate_barcode(self, i, j): - # # 这里是你生成barcode的代码 - # area_type_barcode = self.location_id.barcode - # return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + str(i + 1) + '-' - # + str(j + 1) + pass + # # 这里是你生成barcode的代码 + # # area_type_barcode = self.location_id.barcode + # area_type_barcode = self.barcode + # i_str = str(i + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0 + # j_str = str(j + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0 + # return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + i_str + '-' + j_str class ShelfLocation(models.Model): @@ -227,9 +223,12 @@ class ShelfLocation(models.Model): ('货位', '货位') ], string='存储类型') # 绑定库区 + shelf_location_id = fields.Many2one('stock.location', string='所属库区', domain=[('location_type', '=', '库区')]) location_id = fields.Many2one('stock.location', string='所属库区', domain=[('location_type', '=', '库区')]) # 产品类别 (关联:product.category) - product_type = fields.Many2many('product.category', string='产品类别') + # product_type = fields.Many2many('product.category', string='产品类别') + + # picking_product_type = fields.Many2many('stock.picking', string='调拨产品类别', related='location_dest_id.product_type') # 货架独有字段:通道、方向、货架高度(m)、货架层数、层数容量 channel = fields.Char(string='通道') direction = fields.Selection([ @@ -253,6 +252,16 @@ class ShelfLocation(models.Model): hide_shelf = fields.Boolean(compute='_compute_hide_what', string='隐藏货架') hide_location = fields.Boolean(compute='_compute_hide_what', string='隐藏货位') + @api.onchange('shelf_location_id') + def _onchange_shelf_location_id(self): + """ + 根据货架的所属库区修改货位的所属库区 + """ + all_location = self.env['sf.shelf.location'].search([('name', 'ilike', self.name)]) + for record in self: + for location in all_location: + location.location_id = record.shelf_location_id.id + @api.depends('product_sn_id') def _compute_product_id(self): """ @@ -264,7 +273,7 @@ class ShelfLocation(models.Model): record.location_status = '占用' else: record.product_id = False - # record.location_status = '空闲' + record.location_status = '空闲' @api.depends('location_type') def _compute_hide_what(self): @@ -292,10 +301,10 @@ class ShelfLocation(models.Model): for j in range(self.layer_capacity): self.create({ 'name': self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置', - 'location_id': self.id, + 'location_id': self.shelf_location_id.id, 'location_type': '货位', 'barcode': self.generate_barcode(i, j), - 'location_status': '空闲' + 'location_status': '空闲', }) def generate_barcode(self, i, j): @@ -309,11 +318,125 @@ class ShelfLocation(models.Model): j_str = str(j + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0 return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + i_str + '-' + j_str - # def generate_barcode(self, i, j): - # # 这里是你生成barcode的代码 - # area_type_barcode = self.location_id.barcode - # return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + str(i + 1) + '-' - # + str(j + 1) + +class Sf_stock_move_line(models.Model): + _inherit = 'stock.move.line' + + current_location_id = fields.Many2one( + 'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True) + # location_dest_id = fields.Many2one('stock.location', string='目标库位') + location_dest_id_product_type = fields.Many2many(related='location_dest_id.product_type') + location_dest_id_value = fields.Integer(compute='_compute_location_dest_id_value', store=True) + + # def button_test(self): + # print(self.picking_id.name) + # stock_picking = self.env['stock.picking'].search([('name', '=', self.picking_id.name)], limit=1) + # print(self.picking_id.name) + # print(aa.move_line_ids.lot_id.name) + # # 获取当前的stock.picking对象 + # current_picking = self.env['stock.picking'].search([('name', '=', self.picking_id.name)], limit=1) + # + # # 获取当前picking的第一个stock.move对象 + # current_move = current_picking.move_ids[0] if current_picking.move_ids else False + # + # # 如果存在相关的stock.move对象 + # if current_move: + # # 获取源stock.move对象 + # origin_move = current_move.move_orig_ids[0] if current_move.move_orig_ids else False + # + # # 从源stock.move对象获取源stock.picking对象 + # origin_picking = origin_move.picking_id if origin_move else False + # # 现在,origin_picking就是current_picking的上一步 + # # 获取目标stock.move对象 + # dest_move = current_move.move_dest_ids[0] if current_move.move_dest_ids else False + # + # # 从目标stock.move对象获取目标stock.picking对象 + # dest_picking = dest_move.picking_id if dest_move else False + # # 现在,dest_picking就是current_picking的下一步 + + @api.depends('location_id') + def _compute_current_location_id(self): + # for record in self: + # 获取当前的stock.picking对象 + current_picking = self.env['stock.picking'].search([('name', '=', self.picking_id.name)], limit=1) + + # 获取当前picking的第一个stock.move对象 + current_move = current_picking.move_ids[0] if current_picking.move_ids else False + + # 如果存在相关的stock.move对象 + if current_move: + # 获取源stock.move对象 + origin_move = current_move.move_orig_ids[0] if current_move.move_orig_ids else False + + # 从源stock.move对象获取源stock.picking对象 + origin_picking = origin_move.picking_id if origin_move else False + # 现在,origin_picking就是current_picking的上一步 + + # 如果前一个调拨单有目标货位,那么当前调拨单的当前货位就是前一个调拨单的目标货位 + if origin_picking: + for i in current_picking.move_line_ids: + for j in origin_picking.move_line_ids: + if j.destination_location_id: + if i.lot_id == j.lot_id: + i.current_location_id = j.destination_location_id + + # if origin_picking.move_line_ids.destination_location_id: + # aa = origin_picking.move_line_ids + # bb = origin_picking.move_line_ids.destination_location_id + # record.current_location_id = origin_picking.move_line_ids.destination_location_id + # + # # 获取目标stock.move对象 + # dest_move = current_move.move_dest_ids[0] if current_move.move_dest_ids else False + # + # # 从目标stock.move对象获取目标stock.picking对象 + # dest_picking = dest_move.picking_id if dest_move else False + # # 现在,dest_picking就是current_picking的下一步 + + # 是一张单据一张单据往下走的,所以这里的目标货位是上一张单据的当前货位,且这样去计算是可以的。 + @api.depends('location_dest_id') + def _compute_location_dest_id_value(self): + for record in self: + record.location_dest_id_value = record.location_dest_id.id if record.location_dest_id else False + + destination_location_id = fields.Many2one( + 'sf.shelf.location', string='目标货位') + + @api.onchange('destination_location_id') + def _compute_destination_location_id(self): + for record in self: + shelf_location_obj = self.env['sf.shelf.location'].search( + [('product_sn_id', '=', record.lot_id.id)]) + if shelf_location_obj: + shelf_location_obj.product_sn_id = False + # obj = self.env['sf.shelf.location'].search([('location_id', '=', + # self.destination_location_id.id)]) + obj = self.env['sf.shelf.location'].search([('name', '=', + self.destination_location_id.name)]) + if obj: + obj.product_sn_id = record.lot_id.id + else: + pass + else: + obj = self.env['sf.shelf.location'].search([('name', '=', + self.destination_location_id.name)]) + if obj: + obj.product_sn_id = record.lot_id.id + + +class SfStockPicking(models.Model): + _inherit = 'stock.picking' + + def button_validate(self): + """ + 重写验证方法,当验证时意味着调拨单已经完成,已经移动到了目标货位,所以需要将当前货位的状态改为空闲 + """ + res = super(SfStockPicking, self).button_validate() + for line in self.move_line_ids: + if line: + if line.current_location_id: + line.current_location_id.product_sn_id = False + line.current_location_id = False + return res class SfProcurementGroup(models.Model): diff --git a/sf_warehouse/views/change_stock_move_views.xml b/sf_warehouse/views/change_stock_move_views.xml new file mode 100644 index 00000000..d0999a7b --- /dev/null +++ b/sf_warehouse/views/change_stock_move_views.xml @@ -0,0 +1,41 @@ + + + + + sf.stock.move.line.tree + stock.move.line + + + + + + + + + + + + + + + + + sf.stock.move.line.form + stock.move.line + + + + + + + + + + + + + diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml index a7ef00d9..458db805 100644 --- a/sf_warehouse/views/shelf_location.xml +++ b/sf_warehouse/views/shelf_location.xml @@ -28,15 +28,18 @@ - + + - + - + + + @@ -44,108 +47,49 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + shelf.location.kanban + sf.shelf.location + + + + +
+ +
+
+ +
+
+ +
+ +
+
+ + | + +
+
+
- + - + - + @@ -156,17 +100,50 @@ - - - - +
+
+
+
- - - - - - + + + shelf.location.search + sf.shelf.location + + + + + + + + + 货架货位 + ir.actions.act_window + sf.shelf.location + kanban,form + [('location_type', '=', '货位')] + + + + + + + + + + + + + + + + 货架货位 diff --git a/sf_warehouse/views/view.xml b/sf_warehouse/views/view.xml index 93e55dfb..b80177bc 100644 --- a/sf_warehouse/views/view.xml +++ b/sf_warehouse/views/view.xml @@ -158,9 +158,9 @@ - + + + From 685eced709798724b1c10c0817d9be30c5d3565b Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 28 Nov 2023 17:21:29 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_warehouse/models/model.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 07e98c5a..4bb84299 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -212,6 +212,7 @@ class SfLocation(models.Model): class ShelfLocation(models.Model): _name = 'sf.shelf.location' _description = '货架货位' + _order = 'name' name = fields.Char('名称', required=True, size=20) barcode = fields.Char('编码', copy=False, size=15) @@ -290,7 +291,6 @@ class ShelfLocation(models.Model): else: pass - # 生成货位 def create_location(self): """ 当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量 @@ -298,13 +298,17 @@ class ShelfLocation(models.Model): if self.location_type == '货架': for i in range(self.shelf_layer): for j in range(self.layer_capacity): - self.create({ - 'name': self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置', - 'location_id': self.shelf_location_id.id, - 'location_type': '货位', - 'barcode': self.generate_barcode(i, j), - 'location_status': '空闲', - }) + location_name = self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置' + # 检查是否已经有同名的位置存在 + existing_location = self.search([('name', '=', location_name)]) + if not existing_location: + self.create({ + 'name': location_name, + 'location_id': self.shelf_location_id.id, + 'location_type': '货位', + 'barcode': self.generate_barcode(i, j), + 'location_status': '空闲', + }) def generate_barcode(self, i, j): """ From 7c478ec4fd94289b3d5583acd0bc80c75ae658f3 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 29 Nov 2023 09:39:11 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B4=A7=E4=BD=8D?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_frontend/__manifest__.py | 2 +- sf_warehouse/models/model.py | 59 ++++++++++++++++----------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/jikimo_frontend/__manifest__.py b/jikimo_frontend/__manifest__.py index 65438849..e5424c39 100644 --- a/jikimo_frontend/__manifest__.py +++ b/jikimo_frontend/__manifest__.py @@ -31,7 +31,7 @@ '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/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/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 4bb84299..c8937cf4 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import logging from odoo import api, fields, models from odoo.osv import expression @@ -356,44 +357,40 @@ class Sf_stock_move_line(models.Model): # # 从目标stock.move对象获取目标stock.picking对象 # dest_picking = dest_move.picking_id if dest_move else False # # 现在,dest_picking就是current_picking的下一步 - @api.depends('location_id') def _compute_current_location_id(self): - # for record in self: - # 获取当前的stock.picking对象 - current_picking = self.env['stock.picking'].search([('name', '=', self.picking_id.name)], limit=1) + for record in self: + # 使用record代替self来引用当前遍历到的记录 + logging.info('record.picking_id.name: %s' % record.picking_id.name) + logging.info('record.env: %s' % record.env['stock.picking'].search([('name', '=', record.picking_id.name)])) - # 获取当前picking的第一个stock.move对象 - current_move = current_picking.move_ids[0] if current_picking.move_ids else False + # 获取当前的stock.picking对象 + current_picking = record.env['stock.picking'].search([('name', '=', record.picking_id.name)], limit=1) - # 如果存在相关的stock.move对象 - if current_move: - # 获取源stock.move对象 - origin_move = current_move.move_orig_ids[0] if current_move.move_orig_ids else False + # 获取当前picking的第一个stock.move对象 + current_move = current_picking.move_ids[0] if current_picking.move_ids else False - # 从源stock.move对象获取源stock.picking对象 - origin_picking = origin_move.picking_id if origin_move else False - # 现在,origin_picking就是current_picking的上一步 + # 如果存在相关的stock.move对象 + if current_move: + # 获取源stock.move对象 + origin_move = current_move.move_orig_ids[0] if current_move.move_orig_ids else False - # 如果前一个调拨单有目标货位,那么当前调拨单的当前货位就是前一个调拨单的目标货位 - if origin_picking: - for i in current_picking.move_line_ids: - for j in origin_picking.move_line_ids: - if j.destination_location_id: - if i.lot_id == j.lot_id: - i.current_location_id = j.destination_location_id + # 从源stock.move对象获取源stock.picking对象 + origin_picking = origin_move.picking_id if origin_move else False - # if origin_picking.move_line_ids.destination_location_id: - # aa = origin_picking.move_line_ids - # bb = origin_picking.move_line_ids.destination_location_id - # record.current_location_id = origin_picking.move_line_ids.destination_location_id - # - # # 获取目标stock.move对象 - # dest_move = current_move.move_dest_ids[0] if current_move.move_dest_ids else False - # - # # 从目标stock.move对象获取目标stock.picking对象 - # dest_picking = dest_move.picking_id if dest_move else False - # # 现在,dest_picking就是current_picking的下一步 + # 如果前一个调拨单有目标货位 + if origin_picking: + for i in current_picking.move_line_ids: + for j in origin_picking.move_line_ids: + if j.destination_location_id and i.lot_id == j.lot_id: + # 更新当前记录的current_location_id字段 + record.current_location_id = j.destination_location_id + # # 获取目标stock.move对象 + # dest_move = current_move.move_dest_ids[0] if current_move.move_dest_ids else False + # + # # 从目标stock.move对象获取目标stock.picking对象 + # dest_picking = dest_move.picking_id if dest_move else False + # # 现在,dest_picking就是current_picking的下一步 # 是一张单据一张单据往下走的,所以这里的目标货位是上一张单据的当前货位,且这样去计算是可以的。 @api.depends('location_dest_id') From c3ba11bed4b37c67394e0d633f7e855a65301b00 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 29 Nov 2023 10:17:43 +0800 Subject: [PATCH 4/7] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E5=AE=89=E5=85=A8=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E7=9A=84=E5=88=80=E5=B0=96=E7=89=B9=E5=BE=81?= =?UTF-8?q?=E3=80=81=E6=9F=84=E9=83=A8=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E4=B8=BAmany2one?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 13 +++++++------ sf_tool_management/models/tool_material_search.py | 6 ++++-- sf_tool_management/views/tool_base_views.xml | 7 ++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index f2aaaff0..b5e62d6e 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -81,7 +81,8 @@ class FunctionalCuttingToolEntity(models.Model): suitable_machining_method_ids = fields.Many2many( 'maintenance.equipment.image', 'rel_machining_product_template_tool_entity', '适合加工方式', domain=[('type', '=', '加工能力')], related='cutting_tool_integral_model_id.suitable_machining_method_ids') - blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image', '刀尖特征', + blade_tip_characteristics_id = fields.Many2one( + 'maintenance.equipment.image', '刀尖特征', domain=[('type', '=', '刀尖特征')], related='cutting_tool_integral_model_id.blade_tip_characteristics_id') handle_type_id = fields.Many2one( 'maintenance.equipment.image', '柄部类型', @@ -202,13 +203,13 @@ class RealTimeDistributionOfFunctionalTools(models.Model): 'maintenance.equipment.image', 'rel_machining_product_template_distribution', '适合加工方式', domain=[('type', '=', '加工能力')], related='sf_functional_cutting_tool_entity_ids.suitable_machining_method_ids') - blade_tip_characteristics_id = fields.Many2many( - 'maintenance.equipment.image', 'rel_blade_tip_product_template_distribution', '刀尖特征', + blade_tip_characteristics_id = fields.Many2one( + 'maintenance.equipment.image', '刀尖特征', domain=[('type', '=', '刀尖特征')], related='sf_functional_cutting_tool_entity_ids.blade_tip_characteristics_id') - handle_type_ids = fields.Many2many( - 'maintenance.equipment.image', 'rel_handle_product_template_distribution', '柄部类型', - domain=[('type', '=', '柄部类型')], related='sf_functional_cutting_tool_entity_ids.handle_type_ids') + handle_type_id = fields.Many2one( + 'maintenance.equipment.image', '柄部类型', + domain=[('type', '=', '柄部类型')], related='sf_functional_cutting_tool_entity_ids.handle_type_id') cutting_direction_ids = fields.Many2many( 'maintenance.equipment.image', 'rel_cutting_product_template_distribution', '走刀方向', domain=[('type', '=', '走刀方向')], related='sf_functional_cutting_tool_entity_ids.cutting_direction_ids') diff --git a/sf_tool_management/models/tool_material_search.py b/sf_tool_management/models/tool_material_search.py index e78766f4..1dc48322 100644 --- a/sf_tool_management/models/tool_material_search.py +++ b/sf_tool_management/models/tool_material_search.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- from odoo import fields, models, api, SUPERUSER_ID + + # from odoo.exceptions import ValidationError @@ -100,8 +102,8 @@ class SfToolMaterialSearch(models.Model): 'rel_machining_product_template_material_search', '适合加工方式', domain=[('type', '=', '加工能力')]) blade_tip_characteristics_id = fields.Many2one('maintenance.equipment.image', '刀尖特征', - domain=[('type', '=', '刀尖特征')]) - handle_type_id = fields.Many2many('maintenance.equipment.image', '柄部类型',domain=[('type', '=', '柄部类型')]) + domain=[('type', '=', '刀尖特征')]) + handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')]) cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'rel_cutting_product_template_material_search', '走刀方向', domain=[('type', '=', '走刀方向')]) diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index d1be9bf2..6e2258e5 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -329,12 +329,13 @@ - + From 2cf4958f46e52acbe647675590fc0e1b4c2b5ec1 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 29 Nov 2023 20:58:12 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=9D=83=E9=99=90=EF=BC=8C=E4=BC=98=E5=8C=96=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/models/ftp_client.py | 2 +- sf_plan_management/models/base.py | 15 +++++ sf_plan_management/models/calendar_base.py | 63 +++++++++++++++++---- sf_plan_management/views/plan_base_view.xml | 22 +++++++ 4 files changed, 89 insertions(+), 13 deletions(-) diff --git a/sf_machine_connect/models/ftp_client.py b/sf_machine_connect/models/ftp_client.py index b33dbeee..2cc1ee5d 100644 --- a/sf_machine_connect/models/ftp_client.py +++ b/sf_machine_connect/models/ftp_client.py @@ -543,7 +543,7 @@ class WorkCenterBarcode(models.Model): # 如果没有附件,直接返回 if not self.cnc_ids: - return + return None # 处理第一个附件的文件名 first_attachment = self.cnc_ids[0].cnc_id diff --git a/sf_plan_management/models/base.py b/sf_plan_management/models/base.py index d1eff04a..1bf1e599 100644 --- a/sf_plan_management/models/base.py +++ b/sf_plan_management/models/base.py @@ -23,6 +23,21 @@ class ProcedureEquipmentResourceSetting(models.Model): create_time = fields.Datetime(string='新增时间', default=lambda self: fields.Datetime.now(), readonly=True) participate_in_scheduling = fields.Boolean(string='参与排程', default=True) + # check_status = fields.Selection([('unchecked', '未审核'), ('checked', '已审核')], '审核状态', default='unchecked') + check_status = fields.Boolean(string='启用状态', default=False, readonly=True) + + def action_check(self): + """ + 审核启用 + """ + self.check_status = True + + def action_uncheck(self): + """ + 审核禁用 + """ + self.check_status = False + @api.depends('work_center_name_id') def _compute_equipment_name_id(self): for record in self: diff --git a/sf_plan_management/models/calendar_base.py b/sf_plan_management/models/calendar_base.py index b493053d..cc1d395e 100644 --- a/sf_plan_management/models/calendar_base.py +++ b/sf_plan_management/models/calendar_base.py @@ -38,6 +38,19 @@ class WorkLogSetting(models.Model): update_time = fields.Datetime(string='更新时间', default=lambda self: fields.Datetime.now()) setting_to_calendar_ids = fields.One2many('sf.work.schedule.calendar', 'name_id', '工作日历') + check_status = fields.Boolean(string='启用状态', default=False, readonly=True) + + def action_check(self): + """ + 审核启用 + """ + self.check_status = True + + def action_uncheck(self): + """ + 审核禁用 + """ + self.check_status = False @api.depends('working_shift_ids') def _compute_working_shift_ids(self): @@ -157,13 +170,13 @@ class WorkLogSetting(models.Model): :return: """ weekdays = { - '星期一': 'Monday', 'Monday': 'Monday', - '星期二': 'Tuesday', 'Tuesday': 'Tuesday', + '星期一': 'Monday', 'Monday': 'Monday', + '星期二': 'Tuesday', 'Tuesday': 'Tuesday', '星期三': 'Wednesday', 'Wednesday': 'Wednesday', - '星期四': 'Thursday', 'Thursday': 'Thursday', - '星期五': 'Friday', 'Friday': 'Friday', - '星期六': 'Saturday', 'Saturday': 'Saturday', - '星期日': 'Sunday', 'Sunday': 'Sunday', + '星期四': 'Thursday', 'Thursday': 'Thursday', + '星期五': 'Friday', 'Friday': 'Friday', + '星期六': 'Saturday', 'Saturday': 'Saturday', + '星期日': 'Sunday', 'Sunday': 'Sunday', } english_weekdays = [] for chinese_weekday in chinese_weekdays: @@ -179,13 +192,13 @@ class WorkLogSetting(models.Model): :return: """ weekdays = { - '星期一': 'Monday', 'Monday': 'Monday', - '星期二': 'Tuesday', 'Tuesday': 'Tuesday', + '星期一': 'Monday', 'Monday': 'Monday', + '星期二': 'Tuesday', 'Tuesday': 'Tuesday', '星期三': 'Wednesday', 'Wednesday': 'Wednesday', - '星期四': 'Thursday', 'Thursday': 'Thursday', - '星期五': 'Friday', 'Friday': 'Friday', - '星期六': 'Saturday', 'Saturday': 'Saturday', - '星期日': 'Sunday', 'Sunday': 'Sunday', + '星期四': 'Thursday', 'Thursday': 'Thursday', + '星期五': 'Friday', 'Friday': 'Friday', + '星期六': 'Saturday', 'Saturday': 'Saturday', + '星期日': 'Sunday', 'Sunday': 'Sunday', } weekday = weekdays.get(chinese_weekday) if weekday: @@ -233,6 +246,19 @@ class WorkingShift(models.Model): start_time = fields.Datetime('班次开始时间') end_time = fields.Datetime('班次结束时间') remark = fields.Char('备注') + check_status = fields.Boolean(string='启用状态', default=False, readonly=True) + + def action_check(self): + """ + 审核启用 + """ + self.check_status = True + + def action_uncheck(self): + """ + 审核禁用 + """ + self.check_status = False class DayOff(models.Model): @@ -247,6 +273,19 @@ class DayOff(models.Model): ('Friday ', '星期五'), ('Saturday ', '星期六'), ('Sunday ', '星期日')], '休息日名称') + check_status = fields.Boolean(string='启用状态', default=False, readonly=True) + + def action_check(self): + """ + 审核启用 + """ + self.check_status = True + + def action_uncheck(self): + """ + 审核禁用 + """ + self.check_status = False class WorkScheduleCalendar(models.Model): diff --git a/sf_plan_management/views/plan_base_view.xml b/sf_plan_management/views/plan_base_view.xml index 06464b98..f9606303 100644 --- a/sf_plan_management/views/plan_base_view.xml +++ b/sf_plan_management/views/plan_base_view.xml @@ -16,6 +16,10 @@ + + +