diff --git a/yuthon_issue/wizard/soong_workflow_comment_wizard_inherit.py b/yuthon_issue/wizard/soong_workflow_comment_wizard_inherit.py index 9013c8353..b07d045ed 100644 --- a/yuthon_issue/wizard/soong_workflow_comment_wizard_inherit.py +++ b/yuthon_issue/wizard/soong_workflow_comment_wizard_inherit.py @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- -from odoo import fields, models +from odoo import fields, models, api +from lxml import etree +import logging + +_logger = logging.getLogger(__name__) class SoongWorkflowCommentWizard(models.TransientModel): @@ -9,7 +13,29 @@ class SoongWorkflowCommentWizard(models.TransientModel): 'issue.library', 'soong_comment_wizard_issue_filter_rel', 'wizard_id', 'issue_id', string='议题过滤') - avoid_issue_ids = fields.Many2many( - 'issue.library', 'soong_comment_wizard_avoid_issue_rel', - 'wizard_id', 'issue_id', string='回避议题', - domain="[('id', 'in', issue_filter_ids)]") + @api.model + def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False): + res = super(SoongWorkflowCommentWizard, self).fields_view_get( + view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu) + _logger.info("=== fields_view_get called, view_type=%s, context keys=%s", view_type, list(self._context.keys())) + if view_type == 'form': + default_cmd = self._context.get('default_issue_filter_ids') + _logger.info("=== default_issue_filter_ids from context: %s", default_cmd) + issue_ids = [] + if default_cmd and isinstance(default_cmd, list): + for cmd in default_cmd: + if cmd and len(cmd) >= 3 and cmd[0] == 6: + issue_ids = list(cmd[2]) + break + _logger.info("=== extracted issue_ids: %s", issue_ids) + if issue_ids: + domain_py = [('id', 'in', issue_ids)] + domain_str = str(domain_py) + _logger.info("=== injecting domain: %s", domain_str) + doc = etree.fromstring(res['arch']) + nodes = doc.xpath("//field[@name='avoid_issue_ids']") + _logger.info("=== found %d avoid_issue_ids nodes", len(nodes)) + for node in nodes: + node.set('domain', domain_str) + res['arch'] = etree.tostring(doc, encoding='unicode') + return res