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

[16.0][MIG] rma_sale: Migration to 16.0 #364

Merged
merged 55 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
bf90035
[ADD] rma_sale: new module
Jun 24, 2020
093c482
Added translation using Weblate (Portuguese (Brazil))
fcolus Jul 22, 2020
61e2788
[FIX] rma_sale: fix expected single record error in tests.
Jul 30, 2020
10689d9
[FIX+IMP] rma: views permissions + portal permissions + teams flow
chienandalu Aug 14, 2020
ab83dfd
[FIX+IMP] rma, rma_sale: fix bugs and add improvements
Aug 19, 2020
21ec3b9
Translated using Weblate (Spanish)
pedrobaeza Aug 22, 2020
0405519
[IMP] rma_sale: portal improvents
chienandalu Aug 28, 2020
bad9614
[FIX+IMP] rma_sale: Proper dependency + propagate salesman
pedrobaeza Sep 14, 2020
2b5b82e
[FIX+IMP] rma: usability + Translated using Weblate (Spanish)
chienandalu Sep 30, 2020
8791196
[FIX] rma_sale: show related RMAs without default filters
Oct 20, 2020
fbabf8a
[FIX] rma_sale: Show directly form on 1 RMA
pedrobaeza Oct 20, 2020
1267c92
[IMP] rma_sale: black, isort, prettier
Oct 28, 2020
132f877
[MIG] rma_sale: Migration to 13.0
Oct 28, 2020
acab236
Added translation using Weblate (Romanian)
dhongu Dec 11, 2020
08a4146
Added translation using Weblate (Dutch)
bosd Dec 13, 2020
81fe8d6
[IMP] *rma*: Avoid RMAs of kits until rma_mrp is installed
Dec 12, 2020
7b3f7de
[IMP] *rma*: some improvements
Dec 12, 2020
9096417
[FIX] rma_sale: product in multiple lines
chienandalu Dec 17, 2020
33c456a
[FIX] rma_sale: Request RMA from SO without picking from portal
Dec 10, 2020
acca401
[IMP] rma_sale: prepare kits integration
chienandalu Nov 16, 2020
de75501
[IMP] rma_sale: portal ux
chienandalu Mar 1, 2021
773a443
[IMP] rma, rma_sale: shipping address
chienandalu Nov 6, 2020
f4bca10
[FIX] rma_sale: fix wrong values for RMA creation
SilvioGregorini Mar 31, 2021
48cec57
[FIX] rma_sale: fix CacheError in _prepare_rma_values()
SilvioGregorini Apr 13, 2021
12fd6cb
[FIX] rma_sale: recurrent RMA
chienandalu Apr 22, 2021
8b9dbd3
[FIX] rma_sale: take product from move
chienandalu May 4, 2021
d4d724f
[FIX] rma_sale: view id
chienandalu May 3, 2021
0b66845
[FIX] rma_sale: chained returns
chienandalu May 27, 2021
7fe4109
[FIX] rma: pre-commit
pedrobaeza Jun 19, 2021
66c9fc1
[IMP] rma_sale: portal rma request single page view
chienandalu Jun 22, 2021
2cab64f
[IMP] rma_sale: black, isort, prettier
chafique-delli Sep 3, 2021
1b47077
[14.0][MIG] rma_sale module
chafique-delli Dec 10, 2020
dfb9c20
[FIX] fix filter rma location based on the sale order company
sebastienbeau Oct 22, 2021
d4794a3
Added translation using Weblate (Portuguese)
pedrocs-exo Oct 28, 2021
23e95ca
Added translation using Weblate (Italian)
francesco-ooops Nov 23, 2021
5f82d77
Translated using Weblate (Italian)
SicurSam Mar 31, 2022
71dec5c
[FIX] rma_sale: issue opening rma view from wizard + action permissio…
GSLabIt Apr 21, 2022
d1cc04a
[IMP] rma_sale: avoid submit form in portal if no info
chienandalu Jan 20, 2022
7339f69
[FIX] rma_sale: subscribe portal users to RMA notifications
chienandalu Mar 22, 2022
6528b8e
[FIX] rma + rma_sale: Allow to create an RMA to a user with access_to…
victoralmau May 16, 2022
f5f142d
[FIX] rma_sale: Filter done pickings and done moves
victoralmau Sep 21, 2022
04ff94b
[FIX] rma_sale: Set picking_id field to required in wizard to avoid c…
victoralmau Sep 21, 2022
efb0464
[MIG] rma_sale: Migration to 15.0
Alex-Vining Sep 20, 2022
4dce7e6
[FIX] rma_sale: Allow to request a rma from portal order page only wi…
victoralmau Sep 22, 2022
515f2af
[IMP] rma_sale: Improve tests
victoralmau Oct 10, 2022
58e2383
[IMP] rma_sale: Domains performance
pedrobaeza Dec 5, 2022
9846ae5
Translated using Weblate (Italian)
francesco-ooops Jan 2, 2023
4b9bf2b
Translated using Weblate (Italian)
mymage Apr 3, 2023
eb43a0a
Added translation using Weblate (German)
Apr 5, 2023
9037bec
[UPD] Update rma_sale.pot
May 10, 2023
e1e1b7a
[FIX+IMP] rma_sale: Link invoice/move line with origin sale line when…
pedrobaeza Feb 11, 2023
048e342
[IMP] rma_sale: rollback sale refund on deleted invoice
chienandalu Jun 23, 2023
0a71d84
[IMP] rma_sale: pre-commit stuff
pedrobaeza Aug 29, 2023
54e08e8
[MIG] rma_sale: Migration to 16.0
pedrobaeza Aug 29, 2023
4c6dbd2
[MIG] rma_sale: sale portal
chienandalu Aug 30, 2023
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
130 changes: 130 additions & 0 deletions rma_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
=============================================================
Return Merchandise Authorization Management - Link with Sales
=============================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/16.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-16-0/rma-16-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/webui/builds.html?repo=OCA/rma&target_branch=16.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:

#. Go to *RMA > Orders* and create a new RMA.
#. Select a sales order to be linked to the RMA if you want.
#. 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:

#. Go to *Sales > Orders > Orders*.
#. Create a new sales order or select an existing one.
#. 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.
#. Modify the data at your convenience and click on 'Accept' button.
#. 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:

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

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma_sale%0Aversion:%2016.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 <chafique.delli@akretion.com>
* Giovanni Serra - Ooops <giovanni@ooops404.com>

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-ernestotejeda| image:: https://github.com/ernestotejeda.png?size=40px
:target: https://github.com/ernestotejeda
:alt: ernestotejeda

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

|maintainer-ernestotejeda|

This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/16.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": "16.0.1.0.0",
"development_status": "Production/Stable",
"category": "RMA",
"website": "https://github.com/OCA/rma",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["ernestotejeda"],
"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.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)
if "sale_id" in kw:
res.append(("order_id", "=", int(kw["sale_id"])))
return res
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")
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
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})
# 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(
["{}: {}".format(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()
elif len(rma) == 1:
route = rma._get_share_url() if user_has_group_portal else rma.access_url
else:
route = (
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(
"sale.order", order_id, access_token=access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
if order_sudo.state in ("draft", "sent", "cancel"):
return request.redirect("/my")
values = {
"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)
Loading