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_delivery #424

Open
wants to merge 13 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
114 changes: 114 additions & 0 deletions rma_delivery/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
==================================================================
Return Merchandise Authorization Management - Link with deliveries
==================================================================

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

.. |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_delivery
: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_delivery
: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|

This module extends the functionality of the RMA module to allow to choose a default
behavior for the shipping method used on the RMA returns to the customer.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure RMAs shipping strategy for your company:

#. Go to *Inventory > Configuration > Settings*
#. Choose an *RMA delivery method strategy*.
#. There are 3 possibilities:

- Fixed method: the method will always be the same. Select it on the field *Default RMA delivery method*
(or leave it empty for no delivery method at all).
- Customer method: the method will be the one configured on the partner.
- Mixed method: the method will be the one configured on the partner, otherwise
the fixed one will be chosen.

Usage
=====

To use this module, you need to:

#. Go to a RMA which has received quantities.
#. Return it to the customer.
#. Depending on your company configuration, the return picking will get one or another
carrier.

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_delivery%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>`_:

* David Vidal

* 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-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/16.0/rma_delivery>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions rma_delivery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions rma_delivery/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Return Merchandise Authorization Management - Link with deliveries",
"summary": "Allow to choose a default delivery carrier for returns",
"version": "16.0.1.0.0",
"development_status": "Beta",
"category": "RMA",
"website": "https://github.com/OCA/rma",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["chienandalu"],
"license": "AGPL-3",
"depends": ["rma", "delivery"],
"data": ["views/res_config_settings_views.xml"],
}
61 changes: 61 additions & 0 deletions rma_delivery/i18n/rma_delivery.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rma_delivery
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: rma_delivery
#: model:ir.model,name:rma_delivery.model_res_company
msgid "Companies"
msgstr ""

#. module: rma_delivery
#: model:ir.model,name:rma_delivery.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: rma_delivery
#: model:ir.model.fields.selection,name:rma_delivery.selection__res_company__rma_delivery_strategy__customer_method
msgid "Customer method"
msgstr ""

#. module: rma_delivery
#: model:ir.model.fields.selection,name:rma_delivery.selection__res_company__rma_delivery_strategy__mixed_method
msgid "Customer method (fallback to fixed)"
msgstr ""

#. module: rma_delivery
#: model:ir.model.fields,field_description:rma_delivery.field_res_company__rma_fixed_delivery_method
#: model:ir.model.fields,field_description:rma_delivery.field_res_config_settings__rma_fixed_delivery_method
msgid "Default RMA delivery method"
msgstr ""

#. module: rma_delivery
#: model:ir.model.fields.selection,name:rma_delivery.selection__res_company__rma_delivery_strategy__fixed_method
msgid "Fixed method"
msgstr ""

#. module: rma_delivery
#: model:ir.model,name:rma_delivery.model_rma
msgid "RMA"
msgstr ""

#. module: rma_delivery
#: model:ir.model.fields,field_description:rma_delivery.field_res_company__rma_delivery_strategy
#: model:ir.model.fields,field_description:rma_delivery.field_res_config_settings__rma_delivery_strategy
msgid "RMA delivery method strategy"
msgstr ""

#. module: rma_delivery
#: model_terms:ir.ui.view,arch_db:rma_delivery.res_config_settings_view_form
msgid "RMA delivery strategy"
msgstr ""
3 changes: 3 additions & 0 deletions rma_delivery/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import res_company
from . import res_config_settings
from . import rma
22 changes: 22 additions & 0 deletions rma_delivery/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2022 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class Company(models.Model):
_inherit = "res.company"

rma_delivery_strategy = fields.Selection(
selection=[
("fixed_method", "Fixed method"),
("customer_method", "Customer method"),
("mixed_method", "Customer method (fallback to fixed)"),
],
string="RMA delivery method strategy",
default="mixed_method",
)
rma_fixed_delivery_method = fields.Many2one(
comodel_name="delivery.carrier",
string="Default RMA delivery method",
)
16 changes: 16 additions & 0 deletions rma_delivery/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

rma_delivery_strategy = fields.Selection(
related="company_id.rma_delivery_strategy",
readonly=False,
)
rma_fixed_delivery_method = fields.Many2one(
related="company_id.rma_fixed_delivery_method",
readonly=False,
)
51 changes: 51 additions & 0 deletions rma_delivery/models/rma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2022 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models


class Rma(models.Model):
_inherit = "rma"

def _get_default_carrier_id(self, company, partner):
"""Gather the company option for default carrier on RMA returns. We could
either:
- Get a fixed method
- Get the partner's defined method (or his commercial entity one)
- Get the partner's and fallback to a fixed one if defined
"""
strategy = company.rma_delivery_strategy
delivery_method = company.rma_fixed_delivery_method
partner_method = (
partner.property_delivery_carrier_id
or partner.commercial_partner_id.property_delivery_carrier_id
)
if strategy == "customer_method" or (
strategy == "mixed_method" and partner_method
):
delivery_method = partner_method
return delivery_method

def _prepare_returning_picking(self, picking_form, origin=None):
res = super()._prepare_returning_picking(picking_form, origin)
picking_form.carrier_id = self._get_default_carrier_id(

Check warning on line 30 in rma_delivery/models/rma.py

View check run for this annotation

Codecov / codecov/patch

rma_delivery/models/rma.py#L29-L30

Added lines #L29 - L30 were not covered by tests
picking_form.company_id, picking_form.partner_id
)
return res

Check warning on line 33 in rma_delivery/models/rma.py

View check run for this annotation

Codecov / codecov/patch

rma_delivery/models/rma.py#L33

Added line #L33 was not covered by tests

def _set_carrier(self, pickings):
for picking in pickings:
picking.carrier_id = self._get_default_carrier_id(
picking.company_id, picking.partner_id
)

def create_replace(self, scheduled_date, warehouse, product, qty, uom):
existing_pickings = self.delivery_move_ids.picking_id
res = super().create_replace(scheduled_date, warehouse, product, qty, uom)
self._set_carrier(self.delivery_move_ids.picking_id - existing_pickings)
return res

def create_return(self, scheduled_date, qty=None, uom=None):
existing_pickings = self.delivery_move_ids.picking_id
res = super().create_return(scheduled_date, qty=qty, uom=uom)
self._set_carrier(self.delivery_move_ids.picking_id - existing_pickings)
return res
11 changes: 11 additions & 0 deletions rma_delivery/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
To configure RMAs shipping strategy for your company:

#. Go to *Inventory > Configuration > Settings*
#. Choose an *RMA delivery method strategy*.
#. There are 3 possibilities:

- Fixed method: the method will always be the same. Select it on the field *Default RMA delivery method*
(or leave it empty for no delivery method at all).
- Customer method: the method will be the one configured on the partner.
- Mixed method: the method will be the one configured on the partner, otherwise
the fixed one will be chosen.
5 changes: 5 additions & 0 deletions rma_delivery/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* David Vidal

* Souheil Bejaoui - ACSONE SA/NV <[email protected]>
2 changes: 2 additions & 0 deletions rma_delivery/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the functionality of the RMA module to allow to choose a default
behavior for the shipping method used on the RMA returns to the customer.
6 changes: 6 additions & 0 deletions rma_delivery/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To use this module, you need to:

#. Go to a RMA which has received quantities.
#. Return it to the customer.
#. Depending on your company configuration, the return picking will get one or another
carrier.
Binary file added rma_delivery/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
Loading