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] =?UTF-8?q?1=E3=80=81=E8=8E=B7=E5=8F=96=E6=97=A5=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E8=B4=A7=E4=BD=8D=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=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: