From 896c1ad3a7d8277d93e1725c6460a8688922e230 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 20 May 2025 13:46:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=88=B0=E6=95=B0=E6=8D=AE=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/functional_tool.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 498d9436..dcbca0e7 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -150,6 +150,17 @@ class FunctionalCuttingToolEntity(models.Model): else: # 原刀从线边出库 item.tool_in_out_stock_location_1(location_id, tool_room_id) + # 系统中该刀在线边刀架其他位置,需先清除这个位置的刀具信息 + shelf_location_id = self.env['sf.shelf.location'].sudo().search([ + ('product_sn_id', '=', item.barcode_id.id)]) + if shelf_location_id: + shelf_location_id.write( + {'product_id': None, + 'product_sn_id': None, + 'tool_rfid': None, + "tool_name_id": None, + 'product_num': 0, + 'location_status': '空闲'}) # 新刀入库到线边 item.create_stock_move(pre_manufacturing_id, location_id) item.current_shelf_location_id = location_id.id From 3a9cd3f39ddec1669bf3229cf2ae44e697856cd5 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 22 May 2025 11:04:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E8=8E=B7=E5=8F=96=E6=97=A5?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E8=B4=A7=E4=BD=8D=E4=BF=A1=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 16 ++++++++++------ sf_warehouse/models/sync_common.py | 8 +++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index cd449c69..569559ac 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -738,21 +738,25 @@ class ResMrpWorkOrder(models.Model): # self.workpiece_delivery_ids[0].write({'rfid_code': self.rfid_code}) def get_plan_workorder(self, production_line): - tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d") - tomorrow_start = tomorrow + ' 00:00:00' - tomorrow_end = tomorrow + ' 23:59:59' + tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d") + tomorrow_start = f"{tomorrow} 00:00:00" + tomorrow_end = f"{tomorrow} 23:59:59" logging.info('tomorrow:%s' % tomorrow) sql = """ SELECT * FROM mrp_workorder WHERE state!='rework' - to_char(date_planned_start::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')>= %s - AND to_char(date_planned_finished::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')<= %s + AND (date_planned_start + interval '8 hours') >= %s::timestamp + AND (date_planned_finished + interval '8 hours') <= %s::timestamp """ params = [tomorrow_start, tomorrow_end] if production_line: + line = self.env['sf.production.line'].search( + [('name', '=', production_line)], limit=1) + if not line: + raise ValueError(f"生产线'{production_line}'不存在") sql += "AND production_line_id = %s" - params.append(production_line) + params.append(line.id) self.env.cr.execute(sql, params) ids = [t[0] for t in self.env.cr.fetchall()] return [('id', 'in', ids)] diff --git a/sf_warehouse/models/sync_common.py b/sf_warehouse/models/sync_common.py index d8f075dd..18510917 100644 --- a/sf_warehouse/models/sync_common.py +++ b/sf_warehouse/models/sync_common.py @@ -121,10 +121,16 @@ class MrsShelfLocationDataSync(models.Model): tool.tool_in_out_stock_location(location_id) if tool: location_id.product_sn_id = tool.barcode_id.id + # 修改功能刀具标准状态值和已使用寿命值 + if 'LifeStd' in item and 'LifeUse' in item: + tool.sudo().write({ + 'max_lifetime_value': item['LifeStd'], + 'used_value': item['LifeUse'] + }) # 修改功能刀具状态 if item.get('State') == '报警': if tool.functional_tool_status != item.get('State'): - tool.write({ + tool.sudo().write({ 'functional_tool_status': item['State'] }) else: