From 3fa57ff8d0ea6f4a397d3ec32393948f9eae6e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Mon, 30 Mar 2026 15:38:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/inherit_product_template.py | 14 -------------- .../views/inherit_product_template.xml | 3 ++- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/yuthon_sps_approval/models/inherit_product_template.py b/yuthon_sps_approval/models/inherit_product_template.py index 24ac8eedd..22e98163a 100644 --- a/yuthon_sps_approval/models/inherit_product_template.py +++ b/yuthon_sps_approval/models/inherit_product_template.py @@ -9,13 +9,6 @@ class ProductTemplate(models.Model): @api.onchange('is_fixed_assets') def _onchange_fixed_assets(self): - """勾选/取消“是否固定资产”时,动态限制产品类别的可选范围。 - - - 勾选:`categ_id` 只允许名称包含“固定资产”的类别 - - 取消:`categ_id` 不加限制 - 同时保留“已关联设备不允许取消固定资产”的校验。 - """ - # 原有校验逻辑:已作为固定资产使用时不允许取消 if not self.is_fixed_assets and self._origin.is_fixed_assets: related_equipments = self.env['maintenance.equipment'].search([ ('name', '=', self.name) @@ -23,13 +16,6 @@ class ProductTemplate(models.Model): if related_equipments: raise UserError('该产品已关联设备,请先删除固定资产') - # 根据是否固定资产,返回动态 domain - if self.is_fixed_assets: - domain = {'categ_id': [('name', 'ilike', '固定资产')]} - else: - domain = {'categ_id': []} - return {'domain': domain} - def update_company_id(self): template_ids = self.env["product.template"].browse(self._context.get('active_ids', self._context.get('active_id'))) diff --git a/yuthon_sps_approval/views/inherit_product_template.xml b/yuthon_sps_approval/views/inherit_product_template.xml index 846319f20..4257bd625 100644 --- a/yuthon_sps_approval/views/inherit_product_template.xml +++ b/yuthon_sps_approval/views/inherit_product_template.xml @@ -10,9 +10,10 @@ 产品类型 - + 产品类别 + [('name', 'like', '固定资产')] if is_fixed_assets else []