From 1b6ca170c00e6044365d1f35e834d22d96f1a40b Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 19 Sep 2024 15:15:30 +0800 Subject: [PATCH] =?UTF-8?q?bom=E7=BB=84=E8=A3=85=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/wizard/jikimo_bom_wizard.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sf_tool_management/wizard/jikimo_bom_wizard.py b/sf_tool_management/wizard/jikimo_bom_wizard.py index ed6fe790..7a31711c 100644 --- a/sf_tool_management/wizard/jikimo_bom_wizard.py +++ b/sf_tool_management/wizard/jikimo_bom_wizard.py @@ -17,6 +17,22 @@ class JikimoBomWizard(models.TransientModel): ], string='组装方式', required=True) is_ok = fields.Boolean('确认上述信息正确无误。') + + @api.model + def default_get(self, fields): + res = super(JikimoBomWizard, self).default_get(fields) + # 根据某个字段的值设置默认选项 + if 'default_bom_id' in self.env.context: + jikimo_bom = self.env['jikimo.bom'].browse(self.env.context['default_bom_id']) + if not jikimo_bom: + return res + + if jikimo_bom.options: + res['assembly_options'] = jikimo_bom.options + # some_field_value = self.env.context.get('some_field') + # if some_field_value == 'condition_value': + # res['default_option'] = 'option2' # 设置为特定选项 + return res def submit(self): if not self.bom_id: raise UserError('缺少bom信息')