From a427682755fd1feb3ab428fa79dfd010957b66ff Mon Sep 17 00:00:00 2001 From: david Date: Fri, 28 Jan 2022 16:50:02 +0100 Subject: [PATCH] [IMP] rma: finish RMA manually Sometimes there's no choice to return, refund or replace an RMA for different reasons. For example, when the customer doesn't want to repair the product because that would be too expensive. We still want finish the RMA and document the reasons. This improvement allows it. TT34164 --- rma/README.rst | 10 ++ rma/__manifest__.py | 2 + rma/i18n/es.po | 121 +++++++++++++++++-- rma/i18n/rma.pot | 100 +++++++++++++++ rma/models/__init__.py | 1 + rma/models/res_config_settings.py | 5 + rma/models/rma.py | 35 ++++++ rma/models/rma_finalization.py | 26 ++++ rma/readme/CONFIGURE.rst | 5 + rma/readme/USAGE.rst | 5 + rma/security/ir.model.access.csv | 4 + rma/security/rma_security.xml | 12 ++ rma/static/description/index.html | 12 +- rma/tests/test_rma.py | 23 ++++ rma/views/res_config_settings_views.xml | 15 +++ rma/views/rma_finalization_views.xml | 72 +++++++++++ rma/views/rma_views.xml | 28 +++++ rma/wizard/__init__.py | 1 + rma/wizard/rma_finalization_wizard.py | 18 +++ rma/wizard/rma_finalization_wizard_views.xml | 34 ++++++ 20 files changed, 519 insertions(+), 10 deletions(-) create mode 100644 rma/models/rma_finalization.py create mode 100644 rma/views/rma_finalization_views.xml create mode 100644 rma/wizard/rma_finalization_wizard.py create mode 100644 rma/wizard/rma_finalization_wizard_views.xml diff --git a/rma/README.rst b/rma/README.rst index 855d4bf9..4361cc0a 100644 --- a/rma/README.rst +++ b/rma/README.rst @@ -51,6 +51,11 @@ If you want RMAs to be created from incoming emails, you need to: one. #. Go to 'Email' tab and set an 'Email Alias'. +If you want to manually finish RMAs, you need to: + +#. Go to *Settings > Inventory*. +#. Set *Finish RMAs manually* checkbox on. + Usage ===== @@ -79,6 +84,11 @@ To use this module, you need to: The RMA will be set automatically to 'Replaced' or 'Returned' state when the RMA quantity is equal or lower than the quantity in done delivery orders linked to it. +#. You can also finish the RMA without further ado. To do so click on the *Finish* + button. A wizard will ask you for the reason from a selection of preconfigured ones. + Be sure to configure them in advance on *RMA > Configuration > Finalization Reasons*. + Once the RMA is finished, it will be set to that state and the reason will be + registered. An RMA can also be created from a return of a delivery order: diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 84b39b7d..41054ae4 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -21,9 +21,11 @@ "security/ir.model.access.csv", "wizard/stock_picking_return_views.xml", "wizard/rma_delivery_views.xml", + "wizard/rma_finalization_wizard_views.xml", "wizard/rma_split_views.xml", "views/menus.xml", "views/res_partner_views.xml", + "views/rma_finalization_views.xml", "views/rma_portal_templates.xml", "views/rma_team_views.xml", "views/rma_views.xml", diff --git a/rma/i18n/es.po b/rma/i18n/es.po index 195cdd26..d6e390e6 100644 --- a/rma/i18n/es.po +++ b/rma/i18n/es.po @@ -21,12 +21,12 @@ msgstr "" #: model:mail.template,report_name:rma.mail_template_rma_notification #: model:mail.template,report_name:rma.mail_template_rma_receipt_notification msgid "${(object.name or '')}" -msgstr "${(object.name or '')}" +msgstr "" #. module: rma #: model:mail.template,subject:rma.mail_template_rma_notification msgid "${object.company_id.name} RMA (Ref ${object.name or 'n/a' })" -msgstr "${object.company_id.name} RMA (Ref ${object.name or 'n/a' })" +msgstr "" #. module: rma #: model:mail.template,subject:rma.mail_template_rma_receipt_notification @@ -390,9 +390,11 @@ msgid "Action Needed" msgstr "Acción Necesaria" #. module: rma +#: model:ir.model.fields,field_description:rma.field_rma_finalization__active #: model:ir.model.fields,field_description:rma.field_rma_operation__active #: model:ir.model.fields,field_description:rma.field_rma_tag__active #: model:ir.model.fields,field_description:rma.field_rma_team__active +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_view_search #: model_terms:ir.ui.view,arch_db:rma.rma_tag_view_search msgid "Active" msgstr "Activo" @@ -443,7 +445,9 @@ msgid "Aliased Model" msgstr "Modelo con seudónimo" #. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_view_search #: model_terms:ir.ui.view,arch_db:rma.rma_tag_view_search +#: model_terms:ir.ui.view,arch_db:rma.view_rma_finalization_form msgid "Archived" msgstr "Archivado" @@ -461,7 +465,12 @@ msgstr "Conteo de archivos adjuntos" #. module: rma #: model_terms:ir.ui.view,arch_db:rma.rma_team_view_form msgid "Avatar" -msgstr "Avatar" +msgstr "" + +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma__can_be_finished +msgid "Can Be Finished" +msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__can_be_locked @@ -489,6 +498,7 @@ msgid "Can Be Split" msgstr "Puede ser dividido" #. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_wizard_view_form #: model_terms:ir.ui.view,arch_db:rma.rma_redelivery_wizard_view_form #: model_terms:ir.ui.view,arch_db:rma.rma_split_wizard_view_form2 #: model_terms:ir.ui.view,arch_db:rma.rma_view_form @@ -538,6 +548,7 @@ msgstr "Compañías" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__company_id +#: model:ir.model.fields,field_description:rma.field_rma_finalization__company_id #: model:ir.model.fields,field_description:rma.field_rma_team__company_id msgid "Company" msgstr "Compañía" @@ -582,6 +593,11 @@ msgstr "" msgid "Create RMAs" msgstr "Crear RMAs" +#. module: rma +#: model_terms:ir.actions.act_window,help:rma.action_rma_finalization +msgid "Create a new RMA finalization" +msgstr "Crear un nuevo motivo de finalización de RMA" + #. module: rma #: model_terms:ir.actions.act_window,help:rma.action_rma_tag msgid "Create a new RMA tag" @@ -590,6 +606,8 @@ msgstr "Crear una nueva etiqueta de RMA" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__create_uid #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__create_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization__create_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__create_uid #: model:ir.model.fields,field_description:rma.field_rma_operation__create_uid #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__create_uid #: model:ir.model.fields,field_description:rma.field_rma_tag__create_uid @@ -600,6 +618,8 @@ msgstr "Creado por" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__create_date #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__create_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization__create_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__create_date #: model:ir.model.fields,field_description:rma.field_rma_operation__create_date #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__create_date #: model:ir.model.fields,field_description:rma.field_rma_tag__create_date @@ -694,6 +714,8 @@ msgstr "Descripción" #: model:ir.model.fields,field_description:rma.field_res_users__display_name #: model:ir.model.fields,field_description:rma.field_rma__display_name #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__display_name +#: model:ir.model.fields,field_description:rma.field_rma_finalization__display_name +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__display_name #: model:ir.model.fields,field_description:rma.field_rma_operation__display_name #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__display_name #: model:ir.model.fields,field_description:rma.field_rma_tag__display_name @@ -761,7 +783,8 @@ msgstr "Enviar correo al cliente una vez se confirma el RMA." #: model:ir.model.fields,help:rma.field_res_company__rma_mail_receipt_confirmation_template_id #: model:ir.model.fields,help:rma.field_res_config_settings__rma_mail_receipt_confirmation_template_id msgid "Email sent to the customer once the RMA products are received." -msgstr "Enviar correo al cliente una vez se recepcionen los productos del RMA." +msgstr "" +"Enviar correo al cliente una vez se recepcionen los productos del RMA." #. module: rma #: model:ir.model.fields,help:rma.field_res_company__rma_mail_draft_confirmation_template_id @@ -780,6 +803,36 @@ msgstr "RMA Extraído" msgid "Extracted from" msgstr "Extraído de" +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma__finalization_id +msgid "Finalization Reason" +msgstr "Motivo de finalización" + +#. module: rma +#: model:ir.model.constraint,message:rma.constraint_rma_finalization_name_company_uniq +msgid "Finalization name already exists !" +msgstr "¡El nombre de finalización ya existe!" + +#. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_view_form +msgid "Finish" +msgstr "Finalizar" + +#. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_wizard_view_form +msgid "Finish RMA" +msgstr "Finalizar RMA" + +#. module: rma +#: model:ir.actions.act_window,name:rma.rma_finalization_wizard_action +msgid "Finish RMA Manualy" +msgstr "Finalizar RMA manualmente" + +#. module: rma +#: model:ir.model.fields.selection,name:rma.selection__rma__state__finished +msgid "Finished" +msgstr "Finalizado" + #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__message_follower_ids #: model:ir.model.fields,field_description:rma.field_rma_team__message_follower_ids @@ -817,6 +870,8 @@ msgstr "Agrupar por" #: model:ir.model.fields,field_description:rma.field_res_users__id #: model:ir.model.fields,field_description:rma.field_rma__id #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__id +#: model:ir.model.fields,field_description:rma.field_rma_finalization__id +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__id #: model:ir.model.fields,field_description:rma.field_rma_operation__id #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__id #: model:ir.model.fields,field_description:rma.field_rma_tag__id @@ -827,7 +882,7 @@ msgstr "Agrupar por" #: model:ir.model.fields,field_description:rma.field_stock_rule__id #: model:ir.model.fields,field_description:rma.field_stock_warehouse__id msgid "ID" -msgstr "ID" +msgstr "" #. module: rma #: model:ir.model.fields,help:rma.field_rma_team__alias_parent_thread_id @@ -925,6 +980,8 @@ msgstr "Apunte contable" #: model:ir.model.fields,field_description:rma.field_res_users____last_update #: model:ir.model.fields,field_description:rma.field_rma____last_update #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard____last_update +#: model:ir.model.fields,field_description:rma.field_rma_finalization____last_update +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard____last_update #: model:ir.model.fields,field_description:rma.field_rma_operation____last_update #: model:ir.model.fields,field_description:rma.field_rma_split_wizard____last_update #: model:ir.model.fields,field_description:rma.field_rma_tag____last_update @@ -940,6 +997,8 @@ msgstr "Última modificación en" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__write_uid #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__write_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization__write_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__write_uid #: model:ir.model.fields,field_description:rma.field_rma_operation__write_uid #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__write_uid #: model:ir.model.fields,field_description:rma.field_rma_tag__write_uid @@ -950,6 +1009,8 @@ msgstr "Última actualización por" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__write_date #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__write_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization__write_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__write_date #: model:ir.model.fields,field_description:rma.field_rma_operation__write_date #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__write_date #: model:ir.model.fields,field_description:rma.field_rma_tag__write_date @@ -983,6 +1044,14 @@ msgstr "Bloqueado" msgid "Main Attachment" msgstr "Adjuntos principales" +#. module: rma +#: model_terms:ir.actions.act_window,help:rma.action_rma_finalization +msgid "" +"Manage RMA finalization reasons to better classify them for tracking and " +"analysis purposes." +msgstr "Adminitrar motivos de finalización de RMA para una mejor clasificación de estos" +" para su seguimiento análisis posterior." + #. module: rma #: model_terms:ir.actions.act_window,help:rma.action_rma_tag msgid "Manage RMA tags to better classify them for tracking and analysis purposes." @@ -1027,6 +1096,7 @@ msgid "Name" msgstr "Nombre" #. module: rma +#: code:addons/rma/models/rma.py:0 code:addons/rma/models/rma.py:0 #: code:addons/rma/models/rma.py:0 #, python-format msgid "New" @@ -1062,7 +1132,7 @@ msgstr "Ninguno de los RMAs seleccionados puede realizar una devolución." #. module: rma #: model:ir.model.fields.selection,name:rma.selection__rma__priority__0 msgid "Normal" -msgstr "Normal" +msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__message_needaction_counter @@ -1241,7 +1311,7 @@ msgstr "Cantidad a extraer en nuevo RMA." #: model_terms:ir.ui.view,arch_db:rma.view_partner_form #: model_terms:ir.ui.view,arch_db:rma.view_picking_form msgid "RMA" -msgstr "RMA" +msgstr "" #. module: rma #: model_terms:ir.ui.view,arch_db:rma.portal_my_rmas @@ -1281,6 +1351,29 @@ msgstr "Órdenes de entrega de RMA" msgid "RMA Delivery Wizard" msgstr "Asistente de entrega de RMA" +#. module: rma +#: model_terms:ir.ui.view,arch_db:rma.view_rma_finalization_form +msgid "RMA Finalization" +msgstr "Finalización de RMA" + +#. module: rma +#: model:ir.model,name:rma.model_rma_finalization +msgid "RMA Finalization Reason" +msgstr "Motivo de finalización de RMA" + +#. module: rma +#: model:ir.actions.act_window,name:rma.action_rma_finalization +#: model:ir.ui.menu,name:rma.rma_configuration_rma_finalization_menu +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_view_search +#: model_terms:ir.ui.view,arch_db:rma.view_rma_finalization_list +msgid "RMA Finalization Reasons" +msgstr "Motivos de finalización de RMA" + +#. module: rma +#: model:ir.model,name:rma.model_rma_finalization_wizard +msgid "RMA Finalization Wizard" +msgstr "Asistente de finalización de RMA" + #. module: rma #: model:ir.model.fields,field_description:rma.field_stock_warehouse__rma_in_type_id msgid "RMA In Type" @@ -1414,7 +1507,7 @@ msgstr "Equipo de RMA" #: model:ir.model.fields,field_description:rma.field_res_users__rma_ids #: model:ir.model.fields,field_description:rma.field_stock_move__rma_ids msgid "RMAs" -msgstr "RMAs" +msgstr "" #. module: rma #: model_terms:ir.ui.view,arch_db:rma.rma_view_search @@ -1426,6 +1519,16 @@ msgstr "RMAs pasados de fecha límite" msgid "RMAs yet to be fully processed" msgstr "RMAs pendientes de ser procesados por completo" +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__finalization_id +msgid "Reason" +msgstr "Motivo" + +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma_finalization__name +msgid "Reason Name" +msgstr "Nombre del motivo" + #. module: rma #: model_terms:ir.ui.view,arch_db:rma.rma_view_form msgid "Receipt" @@ -1589,7 +1692,7 @@ msgstr "Devuelto" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma_tag__rma_ids msgid "Rma" -msgstr "Rma" +msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__rma_count diff --git a/rma/i18n/rma.pot b/rma/i18n/rma.pot index 1d350b85..ce218474 100644 --- a/rma/i18n/rma.pot +++ b/rma/i18n/rma.pot @@ -328,9 +328,11 @@ msgid "Action Needed" msgstr "" #. module: rma +#: model:ir.model.fields,field_description:rma.field_rma_finalization__active #: model:ir.model.fields,field_description:rma.field_rma_operation__active #: model:ir.model.fields,field_description:rma.field_rma_tag__active #: model:ir.model.fields,field_description:rma.field_rma_team__active +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_view_search #: model_terms:ir.ui.view,arch_db:rma.rma_tag_view_search msgid "Active" msgstr "" @@ -381,7 +383,9 @@ msgid "Aliased Model" msgstr "" #. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_view_search #: model_terms:ir.ui.view,arch_db:rma.rma_tag_view_search +#: model_terms:ir.ui.view,arch_db:rma.view_rma_finalization_form msgid "Archived" msgstr "" @@ -401,6 +405,11 @@ msgstr "" msgid "Avatar" msgstr "" +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma__can_be_finished +msgid "Can Be Finished" +msgstr "" + #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__can_be_locked msgid "Can Be Locked" @@ -427,6 +436,7 @@ msgid "Can Be Split" msgstr "" #. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_wizard_view_form #: model_terms:ir.ui.view,arch_db:rma.rma_redelivery_wizard_view_form #: model_terms:ir.ui.view,arch_db:rma.rma_split_wizard_view_form2 #: model_terms:ir.ui.view,arch_db:rma.rma_view_form @@ -476,6 +486,7 @@ msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__company_id +#: model:ir.model.fields,field_description:rma.field_rma_finalization__company_id #: model:ir.model.fields,field_description:rma.field_rma_team__company_id msgid "Company" msgstr "" @@ -520,6 +531,11 @@ msgstr "" msgid "Create RMAs" msgstr "" +#. module: rma +#: model_terms:ir.actions.act_window,help:rma.action_rma_finalization +msgid "Create a new RMA finalization" +msgstr "" + #. module: rma #: model_terms:ir.actions.act_window,help:rma.action_rma_tag msgid "Create a new RMA tag" @@ -528,6 +544,8 @@ msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__create_uid #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__create_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization__create_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__create_uid #: model:ir.model.fields,field_description:rma.field_rma_operation__create_uid #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__create_uid #: model:ir.model.fields,field_description:rma.field_rma_tag__create_uid @@ -538,6 +556,8 @@ msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__create_date #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__create_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization__create_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__create_date #: model:ir.model.fields,field_description:rma.field_rma_operation__create_date #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__create_date #: model:ir.model.fields,field_description:rma.field_rma_tag__create_date @@ -632,6 +652,8 @@ msgstr "" #: model:ir.model.fields,field_description:rma.field_res_users__display_name #: model:ir.model.fields,field_description:rma.field_rma__display_name #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__display_name +#: model:ir.model.fields,field_description:rma.field_rma_finalization__display_name +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__display_name #: model:ir.model.fields,field_description:rma.field_rma_operation__display_name #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__display_name #: model:ir.model.fields,field_description:rma.field_rma_tag__display_name @@ -718,6 +740,36 @@ msgstr "" msgid "Extracted from" msgstr "" +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma__finalization_id +msgid "Finalization Reason" +msgstr "" + +#. module: rma +#: model:ir.model.constraint,message:rma.constraint_rma_finalization_name_company_uniq +msgid "Finalization name already exists !" +msgstr "" + +#. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_view_form +msgid "Finish" +msgstr "" + +#. module: rma +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_wizard_view_form +msgid "Finish RMA" +msgstr "" + +#. module: rma +#: model:ir.actions.act_window,name:rma.rma_finalization_wizard_action +msgid "Finish RMA Manualy" +msgstr "" + +#. module: rma +#: model:ir.model.fields.selection,name:rma.selection__rma__state__finished +msgid "Finished" +msgstr "" + #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__message_follower_ids #: model:ir.model.fields,field_description:rma.field_rma_team__message_follower_ids @@ -755,6 +807,8 @@ msgstr "" #: model:ir.model.fields,field_description:rma.field_res_users__id #: model:ir.model.fields,field_description:rma.field_rma__id #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__id +#: model:ir.model.fields,field_description:rma.field_rma_finalization__id +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__id #: model:ir.model.fields,field_description:rma.field_rma_operation__id #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__id #: model:ir.model.fields,field_description:rma.field_rma_tag__id @@ -860,6 +914,8 @@ msgstr "" #: model:ir.model.fields,field_description:rma.field_res_users____last_update #: model:ir.model.fields,field_description:rma.field_rma____last_update #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard____last_update +#: model:ir.model.fields,field_description:rma.field_rma_finalization____last_update +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard____last_update #: model:ir.model.fields,field_description:rma.field_rma_operation____last_update #: model:ir.model.fields,field_description:rma.field_rma_split_wizard____last_update #: model:ir.model.fields,field_description:rma.field_rma_tag____last_update @@ -875,6 +931,8 @@ msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__write_uid #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__write_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization__write_uid +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__write_uid #: model:ir.model.fields,field_description:rma.field_rma_operation__write_uid #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__write_uid #: model:ir.model.fields,field_description:rma.field_rma_tag__write_uid @@ -885,6 +943,8 @@ msgstr "" #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__write_date #: model:ir.model.fields,field_description:rma.field_rma_delivery_wizard__write_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization__write_date +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__write_date #: model:ir.model.fields,field_description:rma.field_rma_operation__write_date #: model:ir.model.fields,field_description:rma.field_rma_split_wizard__write_date #: model:ir.model.fields,field_description:rma.field_rma_tag__write_date @@ -918,6 +978,13 @@ msgstr "" msgid "Main Attachment" msgstr "" +#. module: rma +#: model_terms:ir.actions.act_window,help:rma.action_rma_finalization +msgid "" +"Manage RMA finalization reasons to better classify them for tracking and " +"analysis purposes." +msgstr "" + #. module: rma #: model_terms:ir.actions.act_window,help:rma.action_rma_tag msgid "" @@ -1212,6 +1279,29 @@ msgstr "" msgid "RMA Delivery Wizard" msgstr "" +#. module: rma +#: model_terms:ir.ui.view,arch_db:rma.view_rma_finalization_form +msgid "RMA Finalization" +msgstr "" + +#. module: rma +#: model:ir.model,name:rma.model_rma_finalization +msgid "RMA Finalization Reason" +msgstr "" + +#. module: rma +#: model:ir.actions.act_window,name:rma.action_rma_finalization +#: model:ir.ui.menu,name:rma.rma_configuration_rma_finalization_menu +#: model_terms:ir.ui.view,arch_db:rma.rma_finalization_view_search +#: model_terms:ir.ui.view,arch_db:rma.view_rma_finalization_list +msgid "RMA Finalization Reasons" +msgstr "" + +#. module: rma +#: model:ir.model,name:rma.model_rma_finalization_wizard +msgid "RMA Finalization Wizard" +msgstr "" + #. module: rma #: model:ir.model.fields,field_description:rma.field_stock_warehouse__rma_in_type_id msgid "RMA In Type" @@ -1358,6 +1448,16 @@ msgstr "" msgid "RMAs yet to be fully processed" msgstr "" +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma_finalization_wizard__finalization_id +msgid "Reason" +msgstr "" + +#. module: rma +#: model:ir.model.fields,field_description:rma.field_rma_finalization__name +msgid "Reason Name" +msgstr "" + #. module: rma #: model_terms:ir.ui.view,arch_db:rma.rma_view_form msgid "Receipt" diff --git a/rma/models/__init__.py b/rma/models/__init__.py index cc210923..0436117f 100644 --- a/rma/models/__init__.py +++ b/rma/models/__init__.py @@ -2,6 +2,7 @@ from . import account_move from . import rma +from . import rma_finalization from . import rma_operation from . import rma_tag from . import rma_team diff --git a/rma/models/res_config_settings.py b/rma/models/res_config_settings.py index c48d324e..7eae1ded 100644 --- a/rma/models/res_config_settings.py +++ b/rma/models/res_config_settings.py @@ -6,6 +6,11 @@ from odoo import fields, models class ResConfigSettings(models.TransientModel): _inherit = "res.config.settings" + group_rma_manual_finalization = fields.Boolean( + string="Finish RMA manually choosing a reason", + help="Allow to finish an RMA without returning back a product or refunding", + implied_group="rma.group_rma_manual_finalization", + ) send_rma_confirmation = fields.Boolean( related="company_id.send_rma_confirmation", readonly=False, diff --git a/rma/models/rma.py b/rma/models/rma.py index 172d9fa5..c84036b3 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -67,6 +67,14 @@ class Rma(models.Model): states={"locked": [("readonly", True)], "cancelled": [("readonly", True)]}, ) tag_ids = fields.Many2many(comodel_name="rma.tag", string="Tags") + finalization_id = fields.Many2one( + string="Finalization Reason", + comodel_name="rma.finalization", + copy=False, + readonly=True, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + tracking=True, + ) company_id = fields.Many2one( comodel_name="res.company", default=lambda self: self.env.company, @@ -171,6 +179,7 @@ class Rma(models.Model): ("refunded", "Refunded"), ("returned", "Returned"), ("replaced", "Replaced"), + ("finished", "Finished"), ("locked", "Locked"), ("cancelled", "Canceled"), ], @@ -245,6 +254,9 @@ class Rma(models.Model): can_be_locked = fields.Boolean( compute="_compute_can_be_locked", ) + can_be_finished = fields.Boolean( + compute="_compute_can_be_finished", + ) remaining_qty = fields.Float( string="Remaining delivered qty", digits="Product Unit of Measure", @@ -388,6 +400,14 @@ class Rma(models.Model): "replaced", ] + @api.depends("state", "remaining_qty") + def _compute_can_be_finished(self): + for rma in self: + rma.can_be_finished = ( + rma.state in {"received", "waiting_replacement", "waiting_return"} + and rma.remaining_qty > 0 + ) + @api.depends("product_uom_qty", "state", "remaining_qty", "remaining_qty_to_done") def _compute_can_be_split(self): """Compute 'can_be_split'. This field controls the @@ -718,6 +738,21 @@ class Rma(models.Model): action["context"].update(active_id=self.id, active_ids=self.ids) return action + def action_finish(self): + """Invoked when a user wants to manually finalize the RMA""" + self.ensure_one() + self._ensure_can_be_returned() + # Force active_id to avoid issues when coming from smart buttons + # in other models + action = ( + self.env.ref("rma.rma_finalization_wizard_action") + .with_context(active_id=self.id) + .read()[0] + ) + action["context"] = dict(self.env.context) + action["context"].update(active_id=self.id, active_ids=self.ids) + return action + def action_cancel(self): """Invoked when 'Cancel' button in rma form view is clicked.""" self.mapped("reception_move_id")._action_cancel() diff --git a/rma/models/rma_finalization.py b/rma/models/rma_finalization.py new file mode 100644 index 00000000..46b50b2c --- /dev/null +++ b/rma/models/rma_finalization.py @@ -0,0 +1,26 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class RmaFinalization(models.Model): + _description = "RMA Finalization Reason" + _name = "rma.finalization" + _order = "name" + + active = fields.Boolean(default=True) + name = fields.Char( + string="Reason Name", + required=True, + translate=True, + copy=False, + ) + company_id = fields.Many2one(comodel_name="res.company") + + _sql_constraints = [ + ( + "name_company_uniq", + "unique (name, company_id)", + "Finalization name already exists !", + ), + ] diff --git a/rma/readme/CONFIGURE.rst b/rma/readme/CONFIGURE.rst index c5513046..94121f64 100644 --- a/rma/readme/CONFIGURE.rst +++ b/rma/readme/CONFIGURE.rst @@ -6,3 +6,8 @@ If you want RMAs to be created from incoming emails, you need to: #. Go to *RMA > Configuration > RMA Team* and select a team or create a new one. #. Go to 'Email' tab and set an 'Email Alias'. + +If you want to manually finish RMAs, you need to: + +#. Go to *Settings > Inventory*. +#. Set *Finish RMAs manually* checkbox on. diff --git a/rma/readme/USAGE.rst b/rma/readme/USAGE.rst index aa524e7a..1381ebc4 100644 --- a/rma/readme/USAGE.rst +++ b/rma/readme/USAGE.rst @@ -23,6 +23,11 @@ To use this module, you need to: The RMA will be set automatically to 'Replaced' or 'Returned' state when the RMA quantity is equal or lower than the quantity in done delivery orders linked to it. +#. You can also finish the RMA without further ado. To do so click on the *Finish* + button. A wizard will ask you for the reason from a selection of preconfigured ones. + Be sure to configure them in advance on *RMA > Configuration > Finalization Reasons*. + Once the RMA is finished, it will be set to that state and the reason will be + registered. An RMA can also be created from a return of a delivery order: diff --git a/rma/security/ir.model.access.csv b/rma/security/ir.model.access.csv index 911c8d53..1a264c1b 100644 --- a/rma/security/ir.model.access.csv +++ b/rma/security/ir.model.access.csv @@ -10,3 +10,7 @@ access_rma_tag_user_own,rma.tag.user.own,model_rma_tag,rma_group_user_own,1,0,0, access_rma_tag_manager,rma.tag.manager,model_rma_tag,rma_group_manager,1,1,1,1 access_rma_delivery_wizard_user_all,rma.delivery.wizard.user.all,model_rma_delivery_wizard,rma_group_user_all,1,1,1,1 access_rma_split_wizard_user_all,rma.split.wizard.user.all,model_rma_split_wizard,rma_group_user_all,1,1,1,1 +access_rma_finalization_portal,rma.finalization.portal,model_rma_finalization,base.group_portal,1,0,0,0 +access_rma_finalization_user_own,rma.finalization.user.own,model_rma_finalization,rma_group_user_own,1,0,0,0 +access_rma_finalization_manager,rma.finalization.manager,model_rma_finalization,rma_group_manager,1,1,1,1 +access_rma_finalization_wizard_user_own,rma.finalization.wizard.user.own,model_rma_finalization_wizard,rma_group_user_own,1,0,0,0 diff --git a/rma/security/rma_security.xml b/rma/security/rma_security.xml index e7c42289..f9c3ad48 100644 --- a/rma/security/rma_security.xml +++ b/rma/security/rma_security.xml @@ -38,6 +38,10 @@ eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]" /> + + Allow RMA manual finalization + + Personal RMAs @@ -79,6 +83,14 @@ name="domain_force" >['|',('company_id','=',False),('company_id','in',company_ids)] + + RMA Finalization Reason multi-company + + + ['|', ('company_id', 'in', company_ids), ('company_id', '=', False)] + diff --git a/rma/static/description/index.html b/rma/static/description/index.html index 2fbf341f..005092a3 100644 --- a/rma/static/description/index.html +++ b/rma/static/description/index.html @@ -3,7 +3,7 @@ - + Return Merchandise Authorization Management