0

Lets Create a Demo for question !

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")

Here is my question: For licensor_brand field i need a Domain. This domain should be match "licensor_brands" from "santex.licensor_brands" to "licensor_contracts" from "santex.license_contracts".

Dummuy-Domain: [(santex.licanse_contracts.licensor_contracts), = ,(santex.licensor_brands.licensor_brands)]

THANKS FOR TAKING YOUR TIME !!!

i tried this [(santex.licanse_contracts.licensor_contracts), = ,(santex.licensor_brands.licensor_brands)] but it didn't worked.

0

1 Answer 1

2

You can use a computed field to filter out licensor brands that are not referenced from licensor contracts and use the domain in the view

Example:

    1. Define the computed field
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")
    1. Set the domain attribute on the field tag
<field name="partner_ids" invisible="1"/>

<field name="licensor_brand" domain="[('licensor_brands', 'in', partner_ids)]"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.