Files
rma/rma/models/rma_team.py
david 87bff4530d [FIX+IMP] rma: view permissions + portal views access errors + teams flow + Translated using Weblate (Spanish)
[FIX] rma: views permissions

Regular users don't have permissions to rma models, so we should avoid
loading views that lead to permission errors.

TT24986

rma 12.0.1.1.0

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: rma-12.0/rma-12.0-rma
Translate-URL: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma/

[FIX] rma: portal views access errors

- Portal mail thread needs token config.
- Unpublished products will raise AccessError on RMAs portal views for
portal users due to record rules.
- Ensure active_id when getting actions in rma, since we could come from
a context that pollutes the expected active rma id.

[IMP] rma: teams flow

- If no RMA Team is set, we'll assign a default one to the new RMA.
- A sequence is now used to search for the top team and assign it.
- No default user is assigned when it's not in the context (i.e. portal
rmas).

[UPD] Update rma.pot

rma 12.0.1.2.0

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: rma-12.0/rma-12.0-rma
Translate-URL: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma/

Translated using Weblate (Spanish)

Currently translated at 96.2% (253 of 263 strings)

Translation: rma-12.0/rma-12.0-rma
Translate-URL: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma/es/
2022-08-10 07:47:02 +02:00

58 lines
1.7 KiB
Python

# Copyright 2020 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, fields, models
class RmaTeam(models.Model):
_name = "rma.team"
_inherit = ['mail.alias.mixin', 'mail.thread']
_description = "RMA Team"
_order = "sequence, name"
sequence = fields.Integer()
name = fields.Char(
required=True,
translate=True,
)
active = fields.Boolean(
default=True,
help="If the active field is set to false, it will allow you "
"to hide the RMA Team without removing it.",
)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
default=lambda self: self.env.user.company_id,
)
user_id = fields.Many2one(
comodel_name="res.users",
string="Team Leader",
domain=[('share', '=', False)],
default=lambda self: self.env.user,
)
member_ids = fields.One2many(
comodel_name='res.users',
inverse_name='rma_team_id',
string='Team Members',
)
def copy(self, default=None):
if default is None:
default = {}
if not default.get('name'):
default['name'] = _("%s (copy)") % self.name
team = super().copy(default)
for follower in self.message_follower_ids:
team.message_subscribe(partner_ids=follower.partner_id.ids,
subtype_ids=follower.subtype_ids.ids)
return team
def get_alias_model_name(self, vals):
return vals.get('alias_model', 'rma')
def get_alias_values(self):
values = super().get_alias_values()
values['alias_defaults'] = {'team_id': self.id}
return values