Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] rma_sale: Migration to 18.0 #450

Open
wants to merge 68 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9a6f881
[ADD] rma_sale: new module
Jun 24, 2020
4cb0a29
Added translation using Weblate (Portuguese (Brazil))
fcolus Jul 22, 2020
768472c
[FIX] rma_sale: fix expected single record error in tests.
Jul 30, 2020
a7260af
[FIX+IMP] rma: views permissions + portal permissions + teams flow
chienandalu Aug 14, 2020
ba5f7be
[FIX+IMP] rma, rma_sale: fix bugs and add improvements
Aug 19, 2020
196c666
Translated using Weblate (Spanish)
pedrobaeza Aug 22, 2020
027b8e9
[IMP] rma_sale: portal improvents
chienandalu Aug 28, 2020
8378ee7
[FIX+IMP] rma_sale: Proper dependency + propagate salesman
pedrobaeza Sep 14, 2020
ad02919
[FIX+IMP] rma: usability + Translated using Weblate (Spanish)
chienandalu Sep 30, 2020
698290e
[FIX] rma_sale: show related RMAs without default filters
Oct 20, 2020
9c5fd2c
[FIX] rma_sale: Show directly form on 1 RMA
pedrobaeza Oct 20, 2020
861b72e
[IMP] rma_sale: black, isort, prettier
Oct 28, 2020
f061d45
[MIG] rma_sale: Migration to 13.0
Oct 28, 2020
1e13a1a
Added translation using Weblate (Romanian)
dhongu Dec 11, 2020
7de3d30
Added translation using Weblate (Dutch)
bosd Dec 13, 2020
3c4e6f5
[IMP] *rma*: Avoid RMAs of kits until rma_mrp is installed
Dec 12, 2020
8759219
[IMP] *rma*: some improvements
Dec 12, 2020
0ff61ce
[FIX] rma_sale: product in multiple lines
chienandalu Dec 17, 2020
793b2ea
[FIX] rma_sale: Request RMA from SO without picking from portal
Dec 10, 2020
d8511db
[IMP] rma_sale: prepare kits integration
chienandalu Nov 16, 2020
836cae8
[IMP] rma_sale: portal ux
chienandalu Mar 1, 2021
d14ad9b
[IMP] rma, rma_sale: shipping address
chienandalu Nov 6, 2020
7a28f10
[FIX] rma_sale: fix wrong values for RMA creation
SilvioGregorini Mar 31, 2021
bffa165
[FIX] rma_sale: fix CacheError in _prepare_rma_values()
SilvioGregorini Apr 13, 2021
fa69aea
[FIX] rma_sale: recurrent RMA
chienandalu Apr 22, 2021
da01a3d
[FIX] rma_sale: take product from move
chienandalu May 4, 2021
1c7ab6a
[FIX] rma_sale: view id
chienandalu May 3, 2021
010d615
[FIX] rma_sale: chained returns
chienandalu May 27, 2021
573bb88
[FIX] rma: pre-commit
pedrobaeza Jun 19, 2021
de3e2de
[IMP] rma_sale: portal rma request single page view
chienandalu Jun 22, 2021
8da711d
[IMP] rma_sale: black, isort, prettier
chafique-delli Sep 3, 2021
8fba491
[14.0][MIG] rma_sale module
chafique-delli Dec 10, 2020
1d2dda0
[FIX] fix filter rma location based on the sale order company
sebastienbeau Oct 22, 2021
4c66fa6
Added translation using Weblate (Portuguese)
pedrocs-exo Oct 28, 2021
b53f353
Added translation using Weblate (Italian)
francesco-ooops Nov 23, 2021
7def456
Translated using Weblate (Italian)
SicurSam Mar 31, 2022
8d84a81
[FIX] rma_sale: issue opening rma view from wizard + action permissio…
GSLabIt Apr 21, 2022
0910bba
[IMP] rma_sale: avoid submit form in portal if no info
chienandalu Jan 20, 2022
26fa1b9
[FIX] rma_sale: subscribe portal users to RMA notifications
chienandalu Mar 22, 2022
984255e
[FIX] rma + rma_sale: Allow to create an RMA to a user with access_to…
victoralmau May 16, 2022
1ff3b6b
[FIX] rma_sale: Filter done pickings and done moves
victoralmau Sep 21, 2022
4c22f8e
[FIX] rma_sale: Set picking_id field to required in wizard to avoid c…
victoralmau Sep 21, 2022
4317de3
[MIG] rma_sale: Migration to 15.0
Alex-Vining Sep 20, 2022
408e249
[FIX] rma_sale: Allow to request a rma from portal order page only wi…
victoralmau Sep 22, 2022
0026431
[IMP] rma_sale: Improve tests
victoralmau Oct 10, 2022
0f2f76a
[IMP] rma_sale: Domains performance
pedrobaeza Dec 5, 2022
0d0c874
Translated using Weblate (Italian)
francesco-ooops Jan 2, 2023
22d5613
Translated using Weblate (Italian)
mymage Apr 3, 2023
438a3a0
Added translation using Weblate (German)
Apr 5, 2023
58194a9
[FIX+IMP] rma_sale: Link invoice/move line with origin sale line when…
pedrobaeza Feb 11, 2023
d2d3a3a
[IMP] rma_sale: rollback sale refund on deleted invoice
chienandalu Jun 23, 2023
3833297
[MIG] rma_sale: Migration to 16.0
pedrobaeza Aug 29, 2023
d125b90
[MIG] rma_sale: sale portal
chienandalu Aug 30, 2023
1d74d73
Translated using Weblate (Spanish)
Ivorra78 Sep 7, 2023
32630b1
Translated using Weblate (Italian)
francesco-ooops Oct 11, 2023
0df83cd
Translated using Weblate (Italian)
mymage Oct 23, 2023
e76964c
Added translation using Weblate (French)
kbentaleb Jan 4, 2024
5bae76c
[FIX] rma_sale: mantainers
chienandalu Jan 30, 2024
36add32
Translated using Weblate (Portuguese (Brazil))
May 22, 2024
5e04cb9
[IMP] rma: use only procurement.group run to create stock transfers
mt-software-de Apr 15, 2024
063f266
Translated using Weblate (Italian)
mymage Jun 14, 2024
ebb61da
[FIX] rma_sale: Avoid rma access error when cancel a sales order or c…
victoralmau Jul 22, 2024
a3d374c
[IMP] rma_sale: operation required
sbejaoui Jul 22, 2024
5290e87
[IMP] rma: improve rma report layout
sbejaoui Jan 8, 2025
790e8de
Translated using Weblate (Italian)
mymage Jan 10, 2025
b3808e2
[MIG] rma_sale: Migration to 17.0
victoralmau Feb 19, 2025
f2df90f
[IMP] rma_sale: pre-commit auto fixes
victoralmau Feb 21, 2025
6d3b475
[MIG] rma_sale: Migration to 18.0
victoralmau Feb 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions rma_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
=============================================================
Return Merchandise Authorization Management - Link with Sales
=============================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0ace4968c86bee8d2caa4e6d41af6a02fa6258de8a826eecb3378fd4d68db1b8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github
:target: https://github.com/OCA/rma/tree/18.0/rma_sale
:alt: OCA/rma
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rma-18-0/rma-18-0-rma_sale
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/rma&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to link a sales order to an RMA. This can be done
by creating an RMA from scratch and selecting the sales order, creating
one or more RMAs from a sales order form view or from a sales order web
portal page.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. Go to *RMA > Orders* and create a new RMA.
2. Select a sales order to be linked to the RMA if you want.
3. Now you can do the rest of the instructions described in the *readme*
of the rma module.

If you want to create one or more RMAs from a sale order:

1. Go to *Sales > Orders > Orders*.
2. Create a new sales order or select an existing one.
3. If the sales order is in 'Sales Order' state you can see in the
status bar a button labeled 'Create RMA', click it and a wizard will
appear.
4. Modify the data at your convenience and click on 'Accept' button.
5. As many RMAs as lines with quantity greater than zero will be
created. Those RMAs will be linked to the sales order.

The customer can also create RMAs from a sales order portal page:

1. Go to a confirmed sales order portal page.
2. In the left sidebar you can see a button named 'Request RMAs'.
3. By clicking on this button a popup will appear to allow you to define
the quantity per product and delivery order line.
4. Click on the 'Request RMAs' button and RMAs will be created linked to
the sales order.

Single page RMA request:

1. Go to Sales > Configuration > Settings
2. Check the 'Single page RMA request' box.
3. On a sales order in the portal, clicking on 'Request RMAs' button
will open a new page (not a popup).

Known issues / Roadmap
======================

- When you try to request an RMA from a Sales Order in the portal, a
popup appears and the inputs for the quantity doesn't allow decimal
numbers. It would be good to have a component that allows that and at
the same time keeps the constraint of not allowing a number greater
than the order line product quantity.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma_sale%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Ernesto Tejeda
- Pedro M. Baeza
- David Vidal
- Víctor Martínez

- Chafique Delli <[email protected]>
- Giovanni Serra - Ooops <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-chienandalu| image:: https://github.com/chienandalu.png?size=40px
:target: https://github.com/chienandalu
:alt: chienandalu

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-chienandalu|

This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/18.0/rma_sale>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions rma_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import controllers
from . import models
from . import wizard
36 changes: 36 additions & 0 deletions rma_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2020 Tecnativa - Ernesto Tejeda
# Copyright 2022-2023 Tecnativa - Víctor Martínez
# Copyright 2021-2023 Tecnativa - David Vidal
# Copyright 2021-2023 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Return Merchandise Authorization Management - Link with Sales",
"summary": "Sale Order - Return Merchandise Authorization (RMA)",
"version": "18.0.1.0.0",
"development_status": "Production/Stable",
"category": "RMA",
"website": "https://github.com/OCA/rma",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["chienandalu"],
"license": "AGPL-3",
"depends": ["rma", "sale_stock"],
"data": [
"security/ir.model.access.csv",
"views/account_move_views.xml",
"views/report_rma.xml",
"views/rma_views.xml",
"views/sale_views.xml",
"views/sale_portal_template.xml",
"views/res_config_settings_views.xml",
"wizard/sale_order_rma_wizard_views.xml",
],
"assets": {
"web.assets_frontend": [
"/rma_sale/static/src/js/rma_portal_form.esm.js",
"/rma_sale/static/src/scss/rma_sale.scss",
],
"web.assets_tests": [
"/rma_sale/static/src/tests/*.js",
],
},
}
4 changes: 4 additions & 0 deletions rma_sale/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import rma_portal
from . import sale_portal
12 changes: 12 additions & 0 deletions rma_sale/controllers/rma_portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2020 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.addons.rma.controllers.main import PortalRma


class PortalRma(PortalRma):
def _get_filter_domain(self, kw):
res = super()._get_filter_domain(kw)

Check warning on line 9 in rma_sale/controllers/rma_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/rma_portal.py#L9

Added line #L9 was not covered by tests
if "sale_id" in kw:
res.append(("order_id", "=", int(kw["sale_id"])))
return res

Check warning on line 12 in rma_sale/controllers/rma_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/rma_portal.py#L11-L12

Added lines #L11 - L12 were not covered by tests
120 changes: 120 additions & 0 deletions rma_sale/controllers/sale_portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Copyright 2020 Tecnativa - Ernesto Tejeda
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

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")

Check warning on line 26 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L25-L26

Added lines #L25 - L26 were not covered by tests
order_obj = request.env["sale.order"]
wizard_obj = request.env["sale.order.rma.wizard"].sudo()
wizard_line_field_types = {
f: d["type"] for f, d in wizard_obj.line_ids.fields_get().items()
}
# Set wizard line vals
mapped_vals = {}
custom_vals = {}
partner_shipping_id = post.pop("partner_shipping_id", False)
if partner_shipping_id:
try:
partner_shipping_id = int(partner_shipping_id)
except ValueError:
partner_shipping_id = False

Check warning on line 40 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L39-L40

Added lines #L39 - L40 were not covered by tests
for name, value in post.items():
try:
row, field_name = name.split("-", 1)
if wizard_line_field_types.get(field_name) == "many2one":
value = int(value) if value else False
mapped_vals.setdefault(row, {}).update({field_name: value})
# Catch possible form custom fields to add them to the RMA
# description values
except ValueError:
custom_vals.update({name: value})

Check warning on line 50 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L49-L50

Added lines #L49 - L50 were not covered by tests
# If no operation is filled, no RMA will be created
line_vals = [
(0, 0, vals) for vals in mapped_vals.values() if vals.get("operation_id")
]
# Create wizard an generate rmas
order = order_obj.browse(order_id).sudo()
location_id = order.warehouse_id.rma_loc_id.id
# Add custom fields text
custom_description = ""
if custom_vals:
custom_description = r"<br \>---<br \>"
custom_description += r"<br \>".join(

Check warning on line 62 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L61-L62

Added lines #L61 - L62 were not covered by tests
[f"{x}: {y}" for x, y in custom_vals.items()]
)
wizard = wizard_obj.with_context(active_id=order_id).create(
{
"line_ids": line_vals,
"location_id": location_id,
"partner_shipping_id": partner_shipping_id,
"custom_description": custom_description,
}
)
user_has_group_portal = request.env.user.has_group(
"base.group_portal"
) or request.env.user.has_group("base.group_public")
rma = wizard.sudo().create_rma(from_portal=True)
for rec in rma:
rec.origin += _(" (Portal)")
# Add the user as follower of the created RMAs so they can later view them.
rma.message_subscribe([request.env.user.partner_id.id])
# Subscribe the user to the notification subtype so he receives the confirmation
# note.
rma.message_follower_ids.filtered(
lambda x: x.partner_id == request.env.user.partner_id
).subtype_ids += request.env.ref("rma.mt_rma_notification")
if len(rma) == 0:
route = order_sudo.get_portal_url()

Check warning on line 87 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L87

Added line #L87 was not covered by tests
elif len(rma) == 1:
route = rma._get_share_url() if user_has_group_portal else rma.access_url
else:
route = (

Check warning on line 91 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L91

Added line #L91 was not covered by tests
order._get_share_url()
if user_has_group_portal
else "/my/rmas?sale_id=%d" % order_id
)
return request.redirect(route)

@http.route(
["/my/requestrma/<int:order_id>"], type="http", auth="public", website=True
)
def request_sale_rma(self, order_id, access_token=None, **kw):
"""Request RMA on a single page"""
try:
order_sudo = self._document_check_access(

Check warning on line 104 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L103-L104

Added lines #L103 - L104 were not covered by tests
"sale.order", order_id, access_token=access_token
)
except (AccessError, MissingError):
return request.redirect("/my")

Check warning on line 108 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L107-L108

Added lines #L107 - L108 were not covered by tests
if order_sudo.state in ("draft", "sent", "cancel"):
return request.redirect("/my")
values = {

Check warning on line 111 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L110-L111

Added lines #L110 - L111 were not covered by tests
"sale_order": order_sudo,
"page_name": "request_rma",
"default_url": order_sudo.get_portal_url(),
"token": access_token,
"partner_id": order_sudo.partner_id.id,
}
if order_sudo.company_id:
values["res_company"] = order_sudo.company_id
return request.render("rma_sale.request_rma_single_page", values)

Check warning on line 120 in rma_sale/controllers/sale_portal.py

View check run for this annotation

Codecov / codecov/patch

rma_sale/controllers/sale_portal.py#L119-L120

Added lines #L119 - L120 were not covered by tests
Loading