让我们为问题创建一个演示!
class Characters(models.Model):
_name = "santex.characters"
licensor_brand = fields.Many2one("santex.licensor_brands",
domain="????????????????") # todo
class LicensorBrands(models.Model):
_name = "santex.licensor_brands"
licensor_brands = fields.Many2one("res.partner", string="Licensor")
class LicenseContracts(models.Model):
_name = "santex.license_contracts"
licensor_contracts = fields.Many2one("res.partner")
我的问题是:对于licensor_brand字段,我需要一个域。该域名应该匹配"licensor_brands"从"santex.licensor_brands"来"licensor_contracts"从"santex.license_contracts".Dummuy-Domain: [(santex.licanse_contracts.licensor_contracts), =,(santex.licensor_brands.licensor_brands)]
感谢您的宝贵时间!!我尝试了[(santex.licanse_contracts.licensor_contracts), =,(santex.licensor_brands.licensor_brands)],但是没有成功。
您可以使用计算字段来过滤未从许可方合同中引用的许可方品牌,并在视图
中使用域例子:
- 定义计算字段
def compute_partner_ids(self):
self.partner_ids = self.env["santex.license_contracts"].search([]).licensor_contracts
partner_ids = fields.Many2many("res.partner", compute='compute_partner_ids')
licensor_brand = fields.Many2one("santex.licensor_brands")
- 设置域属性字段标记
<field name="partner_ids" invisible="1"/>
<field name="licensor_brand" domain="[('licensor_brands', 'in', partner_ids)]"/>