我如何使用域的第3个模型的字段?



让我们为问题创建一个演示!

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)],但是没有成功。

您可以使用计算字段来过滤未从许可方合同中引用的许可方品牌,并在视图

中使用域例子:

    1. 定义计算字段
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)]"/>

相关内容

  • 没有找到相关文章

最新更新