Files
rma/rma_sale/controllers/sale_portal.py
david 26ecb18f95 [FIX+IMP] rma: views permissions + portal permissions + teams flow
[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_sale 12.0.1.1.0

[FIX] rma_sale: portal permissions

Some operations need to be sudoed to be reachable by the portal user

[UPD] Update rma_sale.pot

rma_sale 12.0.1.1.1

Update translation files

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

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

Update translation files

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

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

[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_sale.pot

rma_sale 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_sale
Translate-URL: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma_sale/
2022-09-20 08:16:11 -04:00

42 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import http, _
from odoo.exceptions import AccessError, MissingError
from odoo.http import request
from odoo.addons.sale.controllers.portal import CustomerPortal
class CustomerPortal(CustomerPortal):
@http.route(['/my/orders/<int:order_id>/requestrma'], type='http',
auth="public", methods=['POST'], website=True)
def request_rma(self, order_id, access_token=None, **post):
try:
order_sudo = self._document_check_access('sale.order', order_id,
access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
order_obj = request.env['sale.order']
wizard_obj = request.env['sale.order.rma.wizard']
# Set wizard line vals
mapped_vals = {}
for name, value in post.items():
row, field_name = name.split('-', 1)
mapped_vals.setdefault(row, {}).update({field_name: value})
line_vals = [(0, 0, vals) for vals in mapped_vals.values()]
# Create wizard an generate rmas
order = order_obj.browse(order_id).sudo()
location_id = order.warehouse_id.rma_loc_id.id
wizard = wizard_obj.with_context(active_id=order_id).create({
'line_ids': line_vals,
'location_id': location_id
})
rma = wizard.sudo().create_rma(from_portal=True)
for rec in rma:
rec.origin += _(' (Portal)')
if len(rma) == 0:
route = order_sudo.get_portal_url()
else:
route = "/my/rmas?sale_id=%d" % order_id
return request.redirect(route)