[FIX] portal: share a record without partner_id field

The method _notify_get_groups is called to determine how a user should be
notified based on the groups he belongs to.
If a record is shared via portal but the model does not have a field named
`partner_id`, the method was failing.

With this patch, the presence of the field is checked first. No additional
access_token is computed if the field is not present.

Forward port of #59123

closes odoo/odoo#59310

X-original-commit: 6612c7ae766e996c57bda5c4c23132797f162f1e
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
fw-bot
2020-10-06 15:53:14 +00:00
committed by Martin Trigaux
parent a9f20dcbb9
commit 7076449752
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -62,9 +62,9 @@ class PortalMixin(models.AbstractModel):
def _notify_get_groups(self):
access_token = self._portal_ensure_token()
customer = self['partner_id']
groups = super(PortalMixin, self)._notify_get_groups()
if access_token and customer:
if access_token and 'partner_id' in self._fields and self['partner_id']:
customer = self['partner_id']
additional_params = {
'access_token': self.access_token,
}
+2
View File
@@ -21,3 +21,5 @@ David Vidal david.vidal@tecnativa.com https://github.com/chienandalu
Cristina Martín cristina.martin@tecnativa.com https://github.com/cristinamartinrod (up to 2019-04-30)
Ernesto Tejeda ernesto.tejeda@tecnativa.com https://github.com/ernestotejeda
Alexandre Díaz alexandre.diaz@tecnativa.com https://github.com/Tardo
Víctor Martínez victor.martinez@tecnativa.com https://github.com/victoralmau
João Marques joao.marques@tecnativa.com https://github.com/joao-p-marques