[15.0] edi_oca: support multicompany with edi.exchange.record
Module
edi_oca
Describe de bug
When you try to access the exchange records menus, a multi-company permissions error appears. If there are elements in the tree view whose model field contains record rules associated with multi-companies and the res_id field does not belong to the active companies, the error is displayed.
To Reproduce
Affected versions: I see the error in 15.0
Steps to reproduce the behavior:
- Have a multi-company record Rule for a model.
- Generate edi.exchange.record for the record rule model, with different companies.
- Access the exchange menu without having all the active companies
Expected behavior When accessing the menu, only the elements that belong to the active companies should be displayed.
Additional context To avoid this problem I have tried two solutions, but neither of them seem correct to me:
- Filter so that only the acces_rule is checked with the records of the active companies
records = self.env[model].browse(rec_ids).with_user(self._uid).filtered(lambda x: x.sudo( ).company_id in self.env.companies.ids). This prevents the error from appearing but does not filter the elements that must be seen. - Create a company_id field from the res_id and model fields, https://github.com/OCA/edi/pull/932 but I have had problems in a real environment since there may be the case in which the loading order of the modules means that a model does not yet exist when trying to access him.
@simahawk @etobella your ideas would be much appreciated here
Well, actually, the problem I see is another. We might need to filter edi records according to the rules of the related record.
Imagine you don't have access to employees and we create an edi exchange for employees, the same problem will arise.
WDYT?
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.