Add context['company'] in CompanyValueMixin

Hello,
Checking multi-company fields in the parties, I see that, whenever the CompanyValueMixin is set, the “company” is added to the context through the setup and I don’t quite understand why it is necessary.

An example would be the “party.party.lang” model. modules/company: 24f16c00a4c5 party.py :

    @classmethod
    def __setup__(cls):
        super().__setup__()
        cls.party.context['company'] = Eval('company', -1) # <-- 
        if 'company' not in cls.party.depends:
            cls.party.depends.append('company')

This is required to force the context value of each record to the current value of the company field in the Mixin table. For example, if you have the same party in two companies with this clause the tryton ORM will browse each party with the right company in the context.

You can see the full explanation in the related issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.