From 062ca66328f80bb50fa27d739a771ae9f2709d7e Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 19 Aug 2024 17:29:09 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=BA=93=E4=BD=8D=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=81=E5=BA=93=E4=BD=8D=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E6=A8=A1=E5=9E=8Bfrom?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F=E5=8F=8A?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=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/controllers/controllers.py | 10 ++++++---- sf_tool_management/models/functional_tool.py | 11 ++++++++++- sf_tool_management/views/functional_tool_views.xml | 12 +++++++----- sf_warehouse/models/sync_common.py | 10 ++++++---- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 86d919f3..6116ac12 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -450,10 +450,12 @@ class Manufacturing_Connect(http.Controller): if tool: location_id.product_sn_id = tool.barcode_id.id # 修改功能刀具状态 - # tool_install_time = {'Nomal': '正常', 'Warning': '报警'} - # tool.write({ - # 'functional_tool_status': tool_install_time.get(item['State']) - # }) + tool_state = {'Nomal': '正常', 'Warning': '报警'} + if tool_state.get(item.get('State')): + if tool_state.get(item.get('State')) != tool.functional_tool_status: + tool.write({ + 'functional_tool_status': tool_state.get(item['State']) + }) else: location_id.product_sn_id = False logging.info('货架已获取信息:%s' % item) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 06078528..55a87339 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -41,7 +41,7 @@ class FunctionalCuttingToolEntity(models.Model): max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) alarm_value = fields.Integer(string='报警值(min)', readonly=True) used_value = fields.Integer(string='已使用值(min)', readonly=True) - functional_tool_status = fields.Selection([('报警', '报警'), ('正常', '正常'), ('已拆除', '已拆除')], + functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], string='状态', store=True, default='正常') current_location_id = fields.Many2one('stock.location', string='当前位置', compute='_compute_current_location_id', store=True) @@ -256,6 +256,15 @@ class FunctionalCuttingToolEntity(models.Model): functional_tool_model_ids.append(functional_tool_model.id) return [(6, 0, functional_tool_model_ids)] + dismantle_num = fields.Integer('拆解单数量', compute='_compute_dismantle_num', store=True) + dismantle_ids = fields.One2many('sf.functional.tool.dismantle', 'functional_tool_id', '拆解单') + + @api.depends('dismantle_ids') + def _compute_dismantle_num(self): + for item in self: + if item: + item.dismantle_num = len(item.dismantle_ids) + def open_functional_tool_dismantle_form(self): self.ensure_one() dismantle_ids = self.env['sf.functional.tool.dismantle'].sudo().search([('functional_tool_id', '=', self.id)]) diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml index b0c78117..b2e71fb3 100644 --- a/sf_tool_management/views/functional_tool_views.xml +++ b/sf_tool_management/views/functional_tool_views.xml @@ -53,12 +53,14 @@