Skip to content

Commit

Permalink
[ADD] add rma_sale_reason
Browse files Browse the repository at this point in the history
[IMP] rma_reason: add rma reason to stock return wizard
  • Loading branch information
sbejaoui committed Aug 16, 2024
1 parent d2c1b50 commit 694fb4d
Show file tree
Hide file tree
Showing 33 changed files with 1,026 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rma_reason/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Contributors
------------

- Jacques-Etienne Baudoux - BCIM [email protected]
- Souheil Bejaoui - ACSONE SA/NV [email protected].com
- Souheil Bejaoui - ACSONE SA/NV [email protected]

Maintainers
-----------
Expand Down
1 change: 1 addition & 0 deletions rma_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import wizards
1 change: 1 addition & 0 deletions rma_reason/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"views/rma_reason.xml",
"views/res_config_settings.xml",
"views/rma_portal_templates.xml",
"wizards/stock_return_picking.xml",
],
"demo": [
"demo/rma_reason.xml",
Expand Down
2 changes: 1 addition & 1 deletion rma_reason/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- Jacques-Etienne Baudoux - BCIM <[email protected]>
- Souheil Bejaoui - ACSONE SA/NV <[email protected].com>
- Souheil Bejaoui - ACSONE SA/NV <[email protected]>
2 changes: 1 addition & 1 deletion rma_reason/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Jacques-Etienne Baudoux - BCIM <a class="reference external" href="mailto:je&#64;bcim.be">je&#64;bcim.be</a></li>
<li>Souheil Bejaoui - ACSONE SA/NV <a class="reference external" href="mailto:souheil.bejaoui&#64;acsone.eu.com">souheil.bejaoui&#64;acsone.eu.com</a></li>
<li>Souheil Bejaoui - ACSONE SA/NV <a class="reference external" href="mailto:souheil.bejaoui&#64;acsone.eu">souheil.bejaoui&#64;acsone.eu</a></li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
2 changes: 2 additions & 0 deletions rma_reason/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_return_picking
from . import stock_return_picking_line
13 changes: 13 additions & 0 deletions rma_reason/wizards/stock_return_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockReturnPicking(models.TransientModel):

_inherit = "stock.return.picking"

rma_reason_id = fields.Many2one(
comodel_name="rma.reason", readonly=False, string="RMA Reason"
)
34 changes: 34 additions & 0 deletions rma_reason/wizards/stock_return_picking.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="stock_return_picking_form_view">
<field name="model">stock.return.picking</field>
<field name="inherit_id" ref="stock.view_stock_return_picking_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='product_return_moves']//tree//field[@name='rma_operation_id']"
position="before"
>
<field
name="rma_reason_id"
attrs="{'column_invisible': [('parent.create_rma', '=', False)], 'required': [('is_rma_reason_required', '=', True)]}"
/>
<field name="is_rma_reason_required" invisible="1" />
</xpath>
<xpath
expr="//group[@name='group_rma']//field[@name='rma_operation_id']"
position="before"
>
<field
name="rma_reason_id"
attrs="{'invisible': [('create_rma', '=', False)]}"
/>
</xpath>
</field>
</record>



</odoo>
32 changes: 32 additions & 0 deletions rma_reason/wizards/stock_return_picking_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class StockReturnPickingLine(models.TransientModel):

_inherit = "stock.return.picking.line"

rma_reason_id = fields.Many2one(
comodel_name="rma.reason",
compute="_compute_rma_reason_id",
store=True,
readonly=False,
string="RMA Reason",
)
is_rma_reason_required = fields.Boolean(
related="wizard_id.company_id.is_rma_reason_required"
)

@api.depends("wizard_id.rma_reason_id")
def _compute_rma_reason_id(self):
for rec in self:
if rec.wizard_id.rma_reason_id:
rec.rma_reason_id = rec.wizard_id.rma_reason_id

Check warning on line 26 in rma_reason/wizards/stock_return_picking_line.py

View check run for this annotation

Codecov / codecov/patch

rma_reason/wizards/stock_return_picking_line.py#L26

Added line #L26 was not covered by tests

def _prepare_rma_vals(self):
self.ensure_one()
vals = super()._prepare_rma_vals()
vals["reason_id"] = self.rma_reason_id.id
return vals

Check warning on line 32 in rma_reason/wizards/stock_return_picking_line.py

View check run for this annotation

Codecov / codecov/patch

rma_reason/wizards/stock_return_picking_line.py#L29-L32

Added lines #L29 - L32 were not covered by tests
1 change: 1 addition & 0 deletions rma_sale/static/src/js/rma_portal_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ odoo.define("rma_sale.animation", function (require) {
$(ev.currentTarget).addClass("bg-primary").addClass("text-primary");
},
});
return publicWidget;
});
7 changes: 5 additions & 2 deletions rma_sale/views/sale_portal_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@
<th class="text-start">Product</th>
<th class="text-end">Quantity</th>
<th class="text-start">Delivery</th>
<th class="text-start">Requested operation</th>
<th
class="text-start"
name="operation"
>Requested operation</th>
<th name="portal_rma_button_desc" />
</tr>
</thead>
Expand Down Expand Up @@ -147,7 +150,7 @@
t-att-value="data['picking'] and data['picking'].id"
/>
</td>
<td class="text-start">
<td class="text-start" name="operation">
<select
t-attf-name="#{data_index}-operation_id"
class="form-control rma-operation"
Expand Down
101 changes: 101 additions & 0 deletions rma_sale_reason/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
===============
Rma Sale Reason
===============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cbc6042f5078d432134c3bb0f3aa3ca2eaaca763041004ab982997f8f44b9a58
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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_reason
: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_reason
: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=16.0
:alt: Try me on Runboat

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

Getting the information as soon as possible is crucial for any business.
That's why, when creating an RMA order from a sales order, it's more
efficient to give the salesperson the possibility to record the return
reason instead of waiting for the RMA team to do it when they process
the order. This ensures accurate recording of customer issues and
improves data accuracy.

This addon is an extension of the rma_sale and rma_reason addons. It
allows salespersons to specify the return reason when creating the RMA
order from the sales order.

**Table of contents**

.. contents::
:local:

Usage
=====

When creating an RMA from a sale order select the reason for the return.

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_reason%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
-------

* Raumschmiede GmbH
* BCIM
* ACSONE SA/NV

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

- Jacques-Etienne Baudoux - BCIM [email protected]
- Souheil Bejaoui - ACSONE SA/NV [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-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px
:target: https://github.com/sbejaoui
:alt: sbejaoui

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

|maintainer-sbejaoui|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions rma_sale_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import wizards
27 changes: 27 additions & 0 deletions rma_sale_reason/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Raumschmiede GmbH
# Copyright 2024 BCIM
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Rma Sale Reason",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Raumschmiede GmbH,BCIM,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/rma",
"depends": ["rma_sale", "rma_reason"],
"maintainers": ["sbejaoui"],
"data": [
"wizards/sale_order_rma_wizard.xml",
"views/rma_portal_templates.xml",
],
"demo": [],
"assets": {
"web.assets_frontend": [
"/rma_sale_reason/static/src/js/rma_portal_form.js",
],
"web.assets_tests": [
"/rma_sale_reason/static/src/tests/*.js",
],
},
}
3 changes: 3 additions & 0 deletions rma_sale_reason/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import rma_portal
27 changes: 27 additions & 0 deletions rma_sale_reason/controllers/rma_portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Raumschmiede GmbH
# Copyright 2024 BCIM
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import http

from odoo.addons.rma_sale.controllers.sale_portal import CustomerPortal


class RmaPortal(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):
"""
We used a hidden input to determine whether the reason is required or not.
Now, we remove it from the post data as the base controller puts all custom
inputs in the description field.
"""
if "is_rma_reason_required" in post:
del post["is_rma_reason_required"]
return super().request_rma(order_id, access_token=access_token, **post)
2 changes: 2 additions & 0 deletions rma_sale_reason/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Jacques-Etienne Baudoux - BCIM <[email protected]>
- Souheil Bejaoui - ACSONE SA/NV <[email protected]>
10 changes: 10 additions & 0 deletions rma_sale_reason/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Getting the information as soon as possible is crucial for any business.
That's why, when creating an RMA order from a sales order,
it's more efficient to give the salesperson the possibility to record the
return reason instead of waiting for the RMA team to do it when they process
the order. This ensures accurate recording of customer issues and improves
data accuracy.

This addon is an extension of the rma_sale and rma_reason addons.
It allows salespersons to specify the return reason when creating the RMA
order from the sales order.
1 change: 1 addition & 0 deletions rma_sale_reason/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When creating an RMA from a sale order select the reason for the return.
Binary file added rma_sale_reason/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 694fb4d

Please sign in to comment.