为什么这个域没有给我结果?

Why isn't this domain giving me results?

所以我正在为黎巴嫩制作这种本地化模块,目前正在做位置位。 预期的功能是通过过滤掉不相关的选项,让政府、地区和地区的选择限制用户可以做出的选择。

以下是模型:

# -*- coding: utf-8 -*-

from odoo import models, fields, api


# Base model
class LebaneseLocation(models.Model):
    _inherit = "res.partner"
    governate_id = fields.Many2one("lebanon.governate", "Governate")
    district_id = fields.Many2one("lebanon.district", "District")
    region_id = fields.Many2one("lebanon.region", "Region")


# Child models with the necessary relations
class Governate(models.Model):
    _name = "lebanon.governate"
    name = fields.Char()
    child_districts = fields.One2many("lebanon.district", "parent_governate",
            "Child Districts")

class District(models.Model):
    _name = "lebanon.district"
    name = fields.Char()
    parent_governate = fields.Many2one("lebanon.governate", "Parent Governate")
    child_regions = fields.One2many("lebanon.region", "parent_district",
            "Child Regions")

class Region(models.Model):
    _name = "lebanon.region"
    name = fields.Char()
    parent_district = fields.Many2one("lebanon.district", "Parent District")  

和视图文件:

<?xml version="1.0"?>                                  
<odoo>                                                 
    <record id="view_res_partner_extended_location" model="ir.ui.view">
        <field name="name">Contacts Custom</field>     
        <field name="model">res.partner</field>        
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">                 
            <field name="category_id" position="after">                                                                
                <field name="governate_id" domain="[('child_districts','=?','district_id'),('child_districts.child_regions','=?','region_id')]"/>
                <field name="district_id"/>            
                <field name="region_id"/>              
            </field>                                   
        </field>                                       
    </record>                                          
</odoo>                                                

并且所有的数据都是通过两个数据文件输入的,一个做无关系的记录,另一个更新有关系的相同记录。

我正在使用 Governate 域进行测试,但它一直没有返回任何内容。

有什么方法可以检查我正在评估的这些参数究竟返回了什么?这对调试有很大帮助。

编辑:这是来自 Studio 域菜单的屏幕截图,以防与调试相关(我通常像躲避瘟疫一样避免使用 Studio) Domain Image

我通过放弃 XML 方法并使用 onchange api 调用设置域解决了我的问题:

@api.onchange('governate_id', 'district_id', 'region_id')
def update_domains(self):
    governate = self.governate_id.name
    district = self.district_id.name
    region = self.region_id.name
    result = {}
    result['domain']={
            'governate_id':[('child_districts.name','=?', governate),
                ('child_districts.child_regions.name', '=?', region)],
            'district_id':[('parent_governate.name', '=?', governate),
                ('child_regions.name', '=?', region)],
            'region_id':[('parent_district.name', '=?', district),
                ('parent_district.parent_governate.name', '=?', governate)]
            }
    return result