From 537e89092609c5305731eb0f6e608f1c28e0ed20 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 29 Apr 2024 14:19:22 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E6=8B=86=E8=A7=A3=E5=90=8E=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E6=83=85=E5=86=B5=E4=B8=8B=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E7=9A=84=E4=BD=8D=E7=A7=BB?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=9B=E6=B7=BB=E5=8A=A0=E6=8B=86=E8=A7=A3?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E6=8B=86=E8=A7=A3=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E7=9A=84=E5=88=80=E5=85=B7=E6=97=A5=E5=BF=97=EF=BC=9B=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BD=93=E6=8B=86=E8=A7=A3=E5=8E=9F=E5=9B=A0=E6=98=AF?= =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=8D=A2=E4=B8=BA=E5=85=B6=E4=BB=96=E5=88=80?= =?UTF-8?q?=E5=85=B7=E3=80=91=E6=97=B6=EF=BC=8C=E7=9B=AE=E6=A0=87=E8=B4=A7?= =?UTF-8?q?=E4=BD=8D=E5=BF=85=E5=A1=AB=EF=BC=9B2=E3=80=81=E8=B4=A7?= =?UTF-8?q?=E4=BD=8D=E7=9C=8B=E6=9D=BF=E6=B7=BB=E5=8A=A0=E6=8C=89=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 43 ++++++++++++-------- sf_tool_management/views/tool_base_views.xml | 18 +++++--- sf_warehouse/views/shelf_location.xml | 1 + 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 8673d370..b00ab209 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -769,6 +769,15 @@ class FunctionalToolDismantle(models.Model): chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位', domain="[('product_id', 'in', (chuck_product_id, False))]") + @api.onchange('functional_tool_id') + def _onchange_freight(self): + for item in self: + item.integral_freight_id = False + item.blade_freight_id = False + item.bar_freight_id = False + item.pad_freight_id = False + item.chuck_freight_id = False + @api.depends('functional_tool_id') def _compute_functional_tool_num(self): for item in self: @@ -807,7 +816,7 @@ class FunctionalToolDismantle(models.Model): raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle) location = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) location_dest = self.env['stock.location'].search([('name', '=', '刀具房')]) - # =================刀柄是否报废拆解======= + # =================刀柄是否[报废]拆解======= location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')]) if self.handle_rfid: lot = self.env['stock.lot'].sudo().search([('rfid', '=', self.handle_rfid)]) @@ -822,34 +831,34 @@ class FunctionalToolDismantle(models.Model): # 刀柄不报废 入库到刀具房 lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解', functional_tool_assembly, functional_tool_assembly.tool_groups_id) - # ==============功能刀具报废拆解================ + # ==============功能刀具[报废]拆解================ if self.dismantle_cause in ['寿命到期报废', '崩刀报废']: # 除刀柄外物料报废 入库到Scrap - if self.integral_freight_id: + if self.integral_product_id: self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - elif self.blade_freight_id: + elif self.blade_product_id: self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - if self.bar_freight_id: + if self.bar_product_id: self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - elif self.pad_freight_id: + elif self.pad_product_id: self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - if self.chuck_freight_id: + if self.chuck_product_id: self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap) - # ===========功能刀具磨削拆解============== + # ===========功能刀具[磨削]拆解============== elif self.dismantle_cause in ['刀具需磨削']: location_dest = self.env['stock.location'].search([('name', '=', '磨削房')]) # 除刀柄外物料拆解 入库到具体库位 - if self.integral_freight_id: + if self.integral_product_id: self.integral_product_id.dismantle_stock_moves(False, location, location_dest) - elif self.blade_freight_id: + elif self.blade_product_id: self.blade_product_id.dismantle_stock_moves(False, location, location_dest) - if self.bar_freight_id: + if self.bar_product_id: self.bar_product_id.dismantle_stock_moves(False, location, location_dest) - elif self.pad_freight_id: + elif self.pad_product_id: self.pad_product_id.dismantle_stock_moves(False, location, location_dest) - if self.chuck_freight_id: + if self.chuck_product_id: self.chuck_product_id.dismantle_stock_moves(False, location, location_dest) - # ==============功能刀具更换拆解============== + # ==============功能刀具[更换]拆解============== elif self.dismantle_cause in ['更换为其他刀具']: # 除刀柄外物料拆解 入库到具体库位 if self.integral_freight_id: @@ -877,7 +886,7 @@ class FunctionalToolDismantle(models.Model): 'rfid': '', 'state': '已拆解' }) - logging.info('刀具拆解成功!') + logging.info('【%s】刀具拆解成功!' % self.name) class ProductProduct(models.Model): @@ -897,12 +906,12 @@ class ProductProduct(models.Model): location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)]) location.product_num = location.product_num + 1 else: - location = False + location = self.env['sf.shelf.location'] # 创建移动历史记录 stock_move_line_id = self.env['stock.move.line'].sudo().create({ 'product_id': self.id, 'move_id': stock_move_id.id, - 'current_location_id': location.id or False, + 'current_location_id': location.id, 'install_tool_time': fields.Datetime.now(), 'qty_done': 1.0, 'state': 'done', diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index e907144d..61bbd110 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -846,7 +846,8 @@ attrs="{'invisible': [('dismantle_cause', 'not in', ['寿命到期报废','崩刀报废'])], 'readonly': [('state', '=', '已拆解')]}"/> - + @@ -855,7 +856,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('chuck_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -869,7 +871,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('integral_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -884,7 +887,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('blade_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -896,7 +900,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('bar_product_id', '!=', False),('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> @@ -908,7 +913,8 @@ + attrs="{'invisible': [('dismantle_cause', 'not in', ['更换为其他刀具'])], 'readonly': [('state', '=', '已拆解')], + 'required': [('pad_freight_id', '!=', False), ('dismantle_cause', 'in', ['更换为其他刀具'])]}"/> diff --git a/sf_warehouse/views/shelf_location.xml b/sf_warehouse/views/shelf_location.xml index 90783fca..2f6317b9 100644 --- a/sf_warehouse/views/shelf_location.xml +++ b/sf_warehouse/views/shelf_location.xml @@ -246,6 +246,7 @@ +