From a70bf4951e828dcda6a94c90afe29987089600ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 10 Feb 2025 17:42:22 +0100 Subject: [PATCH] [MIG] rma: Migration to 18.0 Changes done: - Purge translations - Remove migration scripts - Change translations (_) to self.env._ - Change check_access_rights() method to has_access() method - Change method _product_is_storable() to product_id.is_storable - Set check_company=True to stock.warehouse fields - Change domain of multi-company rules for better performance - Change tree to list in views - Change kanban-box to card - Replace
with - Remove unnecessary invisible fields in views - Changes in portal templates - Changes in stock.picking.return - Change copy() methods to make them multi-records - Remove copy() method from stock.picking, context key is not used TT54263 --- rma/__manifest__.py | 2 +- rma/controllers/main.py | 11 +- rma/i18n/de.po | 243 ------- rma/i18n/es.po | 263 -------- rma/i18n/fr.po | 45 -- rma/i18n/it.po | 294 --------- rma/i18n/pt.po | 152 ----- rma/i18n/pt_BR.po | 142 ----- rma/i18n/ro.po | 119 ---- rma/migrations/17.0.1.2.0/post-migration.py | 17 - rma/models/account_move.py | 4 +- rma/models/res_company.py | 4 +- rma/models/res_config_settings.py | 3 + rma/models/rma.py | 79 +-- rma/models/rma_team.py | 25 +- rma/models/stock_move.py | 4 +- rma/models/stock_picking.py | 12 - rma/models/stock_warehouse.py | 34 +- rma/security/rma_security.xml | 12 +- rma/tests/test_rma.py | 74 ++- rma/views/res_config_settings_views.xml | 3 - rma/views/rma_finalization_views.xml | 4 +- rma/views/rma_portal_templates.xml | 674 +++++++++----------- rma/views/rma_tag_views.xml | 4 +- rma/views/rma_team_views.xml | 57 +- rma/views/rma_views.xml | 30 +- rma/wizard/rma_delivery.py | 4 +- rma/wizard/rma_delivery_views.xml | 3 - rma/wizard/rma_split.py | 4 +- rma/wizard/rma_split_views.xml | 1 - rma/wizard/stock_picking_return.py | 54 +- rma/wizard/stock_picking_return_views.xml | 6 +- 32 files changed, 509 insertions(+), 1874 deletions(-) delete mode 100644 rma/migrations/17.0.1.2.0/post-migration.py diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 087e4e4f..7695e3bb 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Return Merchandise Authorization Management", "summary": "Return Merchandise Authorization (RMA)", - "version": "17.0.2.0.0", + "version": "18.0.1.0.0", "development_status": "Production/Stable", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma/controllers/main.py b/rma/controllers/main.py index 164b3716..9796ba89 100644 --- a/rma/controllers/main.py +++ b/rma/controllers/main.py @@ -1,5 +1,5 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda -# Copyright 2022 Tecnativa - Víctor Martínez +# Copyright 2022-2025 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import _, exceptions, http @@ -17,9 +17,7 @@ class PortalRma(CustomerPortal): if "rma_count" in counters: rma_model = request.env["rma"] rma_count = ( - rma_model.search_count([]) - if rma_model.check_access_rights("read", raise_exception=False) - else 0 + rma_model.search_count([]) if rma_model.has_access("read") else 0 ) values["rma_count"] = rma_count return values @@ -43,7 +41,7 @@ class PortalRma(CustomerPortal): values = self._prepare_portal_layout_values() rma_obj = request.env["rma"] # Avoid error if the user does not have access. - if not rma_obj.check_access_rights("read", raise_exception=False): + if not rma_obj.has_access("read"): return request.redirect("/my") domain = self._get_filter_domain(kw) searchbar_sortings = { @@ -137,8 +135,7 @@ class PortalRma(CustomerPortal): picking = request.env["stock.picking"].browse([picking_id]) picking_sudo = picking.sudo() try: - picking.check_access_rights("read") - picking.check_access_rule("read") + picking.check_access("read") except exceptions.AccessError: if not access_token or not consteq(rma.access_token, access_token): raise diff --git a/rma/i18n/de.po b/rma/i18n/de.po index 1efd3a45..d79a51c2 100644 --- a/rma/i18n/de.po +++ b/rma/i18n/de.po @@ -2301,246 +2301,3 @@ msgid "" msgstr "" "{{object.company_id.name}} Ihre RMA wurde erfolgreich erstellt (Ref {{object." "name or 'n/a' }})" - -#~ msgid "SMS Delivery error" -#~ msgstr "SMS-Zustellungsfehler" - -#~ msgid "" -#~ "" -#~ msgstr "" -#~ "" - -#~ msgid "Alias domain" -#~ msgstr "Alias domain" - -#~ msgid "Delivered Qty Done" -#~ msgstr "gelieferte Menge Erledigt" - -#~ msgid "Last Modified on" -#~ msgstr "Zuletzt geändert am" - -#~ msgid "Main Attachment" -#~ msgstr "Hauptanhang" - -#~ msgid "Owner" -#~ msgstr "Eigentümer" - -#~ msgid "RMA Confirmation Email" -#~ msgstr "RMA-Bestätigungs-E-Mail" - -#~ msgid "RMA Manual Finalization" -#~ msgstr "Manueller RMA-Abschluss" - -#~ msgid "RMA Receipt Confirmation Email" -#~ msgstr "RMA-Empfangsbestätigungs-E-Mail" - -#~ msgid "RMA draft notification Email" -#~ msgstr "Benachrichtigungs-E-Mail zum RMA-Entwurf" - -#~ msgid "Remaining delivered qty to done" -#~ msgstr "Verbleibende Liefermenge zu erledigen" - -#~ msgid "" -#~ "The owner of records created upon receiving emails on this alias. If this " -#~ "field is not set the system will attempt to find the right owner based on " -#~ "the sender (From) address, or will use the Administrator account if no " -#~ "system user is found for that address." -#~ msgstr "" -#~ "Der Eigentümer von Datensätzen, die beim Empfang von E-Mails unter diesem " -#~ "Alias erstellt wurden. Wenn dieses Feld nicht gesetzt ist, versucht das " -#~ "System, den richtigen Eigentümer anhand der Absenderadresse (Von) zu " -#~ "finden, oder verwendet das Administratorkonto, wenn kein Systembenutzer " -#~ "für diese Adresse gefunden wird." - -#~ msgid "" -#~ "When the RMA is receive, allow to finsish it manually choosing\n" -#~ " a finalization reason." -#~ msgstr "" -#~ "Wenn die RMA eingegangen ist, können Sie sie manuell abschließen, \n" -#~ " indem Sie einen Abschlussgrund auswählen." - -#~ msgid "{{(object.name or '')}}" -#~ msgstr "{{(object.name or '')}}" - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " Here is the RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " from\n" -#~ " \n" -#~ " .\n" -#~ "
\n" -#~ "
\n" -#~ " Do not hesitate to contact us if you have any " -#~ "question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Sehr geehrte/r\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " Hiermit übermitteln wie Ihnen unseren RMA Auftrag\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " von\n" -#~ " \n" -#~ " .\n" -#~ "
\n" -#~ "
\n" -#~ " Zögern Sie nicht uns zu kontaktieren.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " The products for your RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " from\n" -#~ " \n" -#~ " have been received in our warehouse.\n" -#~ "
\n" -#~ "
\n" -#~ " Do not hesitate to contact us if you have any " -#~ "question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Sehr geehrte/r\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ "Die Produkte für ihren RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " von\n" -#~ " \n" -#~ "wurden in unserem Lager erfolgreich entgegen genommen.\n" -#~ "
\n" -#~ "
\n" -#~ " Zögern Sie nicht uns bei weiteren Fragen erneut zu " -#~ "kontaktieren\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " You've succesfully placed your RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " on\n" -#~ " \n" -#~ " . Our team will check it and will validate it as soon " -#~ "as possible.\n" -#~ "
\n" -#~ "
\n" -#~ " Do not hesitate to contact us if you have any " -#~ "question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Sehr geehrte/r\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " Sie haben erfolgreich ihren Reklamationsauftrag " -#~ "eingebracht.\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " für\n" -#~ " \n" -#~ " . Unser Team wird die Anfrage bearbeiten uns sich so " -#~ "bald wie möglich bei Ihnen melden.\n" -#~ "
\n" -#~ "
\n" -#~ "Zögern Sie nicht uns bei weiteren Fragen erneut zu kontaktieren\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "Number of messages which requires an action" -#~ msgstr "Anzahl der Nachrichten, die eine Aktion erfordern" - -#~ msgid "Number of unread messages" -#~ msgstr "Anzahl der ungelesenen Nachrichten" - -#~ msgid "Unread Messages" -#~ msgstr "ungelesene Nachrichten" - -#~ msgid "Unread Messages Counter" -#~ msgstr "Zähler für ungelesene Nachrichten" - -#~ msgid "Users" -#~ msgstr "Benutzer" diff --git a/rma/i18n/es.po b/rma/i18n/es.po index 0016f8dd..e092cf1d 100644 --- a/rma/i18n/es.po +++ b/rma/i18n/es.po @@ -2360,266 +2360,3 @@ msgid "" msgstr "" "{{object.company_id.name}} Su RMA se ha creado con éxito (Ref {{object.name " "or 'n/a' }})" - -#~ msgid "SMS Delivery error" -#~ msgstr "Error de Envío de Mensaje" - -#~ msgid "" -#~ "" -#~ msgstr "" -#~ "" - -#~ msgid "Alias domain" -#~ msgstr "Seudónimo del dominio" - -#~ msgid "Delivered Qty Done" -#~ msgstr "Ctd. entregada realizada" - -#~ msgid "Last Modified on" -#~ msgstr "Última modificación en" - -#~ msgid "Main Attachment" -#~ msgstr "Adjuntos principales" - -#~ msgid "Owner" -#~ msgstr "Propietario" - -#~ msgid "RMA Confirmation Email" -#~ msgstr "Correo de confirmación de RMA" - -#~ msgid "RMA Manual Finalization" -#~ msgstr "Finalización del Manual RMA" - -#~ msgid "RMA Receipt Confirmation Email" -#~ msgstr "Correo de confirmación de recepción de RMA" - -#~ msgid "RMA draft notification Email" -#~ msgstr "Correo de notificación de borrador de RMA" - -#~ msgid "Remaining delivered qty to done" -#~ msgstr "Ctd. entregada restante por realizar" - -#~ msgid "" -#~ "The owner of records created upon receiving emails on this alias. If this " -#~ "field is not set the system will attempt to find the right owner based on " -#~ "the sender (From) address, or will use the Administrator account if no " -#~ "system user is found for that address." -#~ msgstr "" -#~ "El propietario de los registros creados al recibir correos electrónicos " -#~ "en este seudónimo. Si el campo no está establecido, el sistema tratará de " -#~ "encontrar el propietario adecuado basado en la dirección del emisor (De), " -#~ "o usará la cuenta de administrador si no se encuentra un usuario para esa " -#~ "dirección." - -#~ msgid "" -#~ "When the RMA is receive, allow to finsish it manually choosing\n" -#~ " a finalization reason." -#~ msgstr "" -#~ "Cuando se recibe el RMA, permite finalizarlo manualmente eligiendo\n" -#~ " un motivo de finalización." - -#~ msgid "{{(object.name or '')}}" -#~ msgstr "{{(object.name or '')}}" - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " Here is the RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " from\n" -#~ " \n" -#~ " .\n" -#~ "
\n" -#~ "
\n" -#~ " Do not hesitate to contact us if you have any " -#~ "question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Estimado/a\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " Aquí tiene el RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " desde\n" -#~ " \n" -#~ " .\n" -#~ "
\n" -#~ "
\n" -#~ " No dude en ponerse en contacto con nosotros si tiene " -#~ "alguna pregunta.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " The products for your RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " from\n" -#~ " \n" -#~ " have been received in our warehouse.\n" -#~ "
\n" -#~ "
\n" -#~ " Do not hesitate to contact us if you have any " -#~ "question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Estimado/a\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " Los productos de su RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " desde\n" -#~ " \n" -#~ " han sido recibidos en nuestro almacén.\n" -#~ "
\n" -#~ "
\n" -#~ " Póngase en contacto con nosotros para cualquier duda " -#~ "al respecto.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " You've succesfully placed your RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " on\n" -#~ " \n" -#~ " . Our team will check it and will validate it as soon " -#~ "as possible.\n" -#~ "
\n" -#~ "
\n" -#~ " Do not hesitate to contact us if you have any " -#~ "question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Estimado/a\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ "
\n" -#~ "
\n" -#~ " Ha solicitado con éxito su RMA\n" -#~ " \n" -#~ " \n" -#~ " \n" -#~ " en\n" -#~ " \n" -#~ " . Nuestro equipo la comprobará y validará tan pronto " -#~ "como sea posible.\n" -#~ "
\n" -#~ "
\n" -#~ " Póngase en contacto con nosotros para cualquier duda " -#~ "al respecto.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ " Cancelled" -#~ msgstr "" -#~ "Cancelado" - -#~ msgid "" -#~ " Preparation" -#~ msgstr "" -#~ "Preparación" - -#~ msgid "" -#~ " Shipped" -#~ msgstr "" -#~ " Enviado" - -#~ msgid "" -#~ " Partially Available" -#~ msgstr "" -#~ "Disponible parcialmente" - -#~ msgid "Number of messages which requires an action" -#~ msgstr "Número de mensajes que requieren una acción" - -#~ msgid "Number of unread messages" -#~ msgstr "Número de mensajes no leidos" - -#~ msgid "Unread Messages" -#~ msgstr "Mensajes por leer" - -#~ msgid "Unread Messages Counter" -#~ msgstr "Contador de mensajes sin leer" - -#~ msgid "Users" -#~ msgstr "Usuarios" - -#~ msgid "Followers (Channels)" -#~ msgstr "Seguidores (Canales)" diff --git a/rma/i18n/fr.po b/rma/i18n/fr.po index 241b0aee..f41c36f0 100644 --- a/rma/i18n/fr.po +++ b/rma/i18n/fr.po @@ -2341,48 +2341,3 @@ msgid "" msgstr "" "{{object.company_id.name}} Votre RMA a été crée avec succès(Ref {{object." "name or 'n/a' }})" - -#~ msgid "" -#~ "" -#~ msgstr "" -#~ "" - -#~ msgid "Alias domain" -#~ msgstr "Domaine de l'alias" - -#~ msgid "Delivered Qty Done" -#~ msgstr "Quantité livrée Terminé" - -#~ msgid "Last Modified on" -#~ msgstr "Dernière Modification le" - -#~ msgid "Main Attachment" -#~ msgstr "Pièce jointe principale" - -#~ msgid "Owner" -#~ msgstr "Propriétaire" - -#~ msgid "RMA Confirmation Email" -#~ msgstr "Email de confirmation RMA" - -#~ msgid "RMA Manual Finalization" -#~ msgstr "Clôture manuelle RMA" - -#~ msgid "RMA Receipt Confirmation Email" -#~ msgstr "Email de confirmation de réception RMA" - -#~ msgid "RMA draft notification Email" -#~ msgstr "Email de notification brouillon RMA" - -#~ msgid "Remaining delivered qty to done" -#~ msgstr "Qté restante à livrer avant de terminer" - -#~ msgid "" -#~ "When the RMA is receive, allow to finsish it manually choosing\n" -#~ " a finalization reason." -#~ msgstr "" -#~ "Quand une RMA est reçue, permet de la terminer manuellement en " -#~ "sélectionnant\n" -#~ " comme motif de clôture." diff --git a/rma/i18n/it.po b/rma/i18n/it.po index 8cd40849..643d0fa6 100644 --- a/rma/i18n/it.po +++ b/rma/i18n/it.po @@ -2351,297 +2351,3 @@ msgid "" msgstr "" "{{object.company_id.name}} La vostra RMA è stata creata con successo (rif. " "{{object.name or 'n/a' }})" - -#~ msgid "SMS Delivery error" -#~ msgstr "Errore consegna SMS" - -#~ msgid "" -#~ "" -#~ msgstr "" -#~ "" - -#~ msgid "Alias domain" -#~ msgstr "Dominio alias" - -#~ msgid "Delivered Qty Done" -#~ msgstr "Quantità consegnata fatta" - -#~ msgid "Last Modified on" -#~ msgstr "Ultima modifica il" - -#~ msgid "Main Attachment" -#~ msgstr "Allegato principale" - -#~ msgid "Owner" -#~ msgstr "Proprietario" - -#~ msgid "RMA Confirmation Email" -#~ msgstr "Email di Conferma RMA" - -#~ msgid "RMA Manual Finalization" -#~ msgstr "Chiusura manuale RMA" - -#~ msgid "RMA Receipt Confirmation Email" -#~ msgstr "E-mail di conferma ricevuta RMA" - -#~ msgid "RMA draft notification Email" -#~ msgstr "E-mail di notifica bozza RMA" - -#~ msgid "Remaining delivered qty to done" -#~ msgstr "Quantità consegnata rimanente da fare" - -#~ msgid "" -#~ "The owner of records created upon receiving emails on this alias. If this " -#~ "field is not set the system will attempt to find the right owner based on " -#~ "the sender (From) address, or will use the Administrator account if no " -#~ "system user is found for that address." -#~ msgstr "" -#~ "Il proprietario dei record creati dopo aver ricevuto email con questo " -#~ "alias. Se questo campo non è impostato il sistema tenterà di trovare il " -#~ "proprietario corretto in base all'indirizzo del mittente (Da) oppure " -#~ "utilizzerà l'account amministratore se non viene trovato alcun utente di " -#~ "sistema per quell'indirizzo." - -#~ msgid "" -#~ "When the RMA is receive, allow to finsish it manually choosing\n" -#~ " a finalization reason." -#~ msgstr "" -#~ "Quando si riceve l'RMA, permetti di chiuderlo manualmente scegliendo\n" -#~ " un motivo per la chiusura." - -#~ msgid "{{(object.name or '')}}" -#~ msgstr "{{(object.name or '')}}" - -#~ msgid "${(object.name or '')}" -#~ msgstr "${(object.name or '')}" - -#~ msgid "${object.company_id.name} RMA (Ref ${object.name or 'n/a' })" -#~ msgstr "${object.company_id.name} RMA (Rif ${object.name or 'n/a' })" - -#~ msgid "" -#~ "${object.company_id.name} RMA (Ref ${object.name or 'n/a' }) products " -#~ "received" -#~ msgstr "" -#~ "${object.company_id.name} RMA (Ref ${object.name or 'n/a' }) prodotti " -#~ "ricevuti" - -#~ msgid "" -#~ "${object.company_id.name} Your RMA has been succesfully created (Ref " -#~ "${object.name or 'n/a' })" -#~ msgstr "" -#~ "${object.company_id.name} Il tuo RMA è stato creato correttamente (Ref " -#~ "${object.name or 'n/a' })" - -#, python-format -#~ msgid "E-mail subject: %s

E-mail body:
%s" -#~ msgstr "Soggetto E-mail: %s

Corpo E-mail:
%s" - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " Here is the RMA ${object.name} from ${object." -#~ "company_id.name}.\n" -#~ "

\n" -#~ " Do not hesitate to contact us if you have any question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Gentile ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " Di seguito l'RMA ${object.name} da ${object." -#~ "company_id.name}.\n" -#~ "

\n" -#~ " Non esiti a contattarci per qualsiasi domanda.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " The products for your RMA ${object.name}\n" -#~ " from ${object.company_id.name} have been received in our warehouse.\n" -#~ "

\n" -#~ " Do not hesitate to contact us if you have any question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Gentile ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " I prodotti del suo RMA ${object.name}\n" -#~ " da ${object.company_id.name} sono stati ricevuti nel nostro " -#~ "magazzino.\n" -#~ "

\n" -#~ " Non esiti a contattarci per qualsiasi domanda.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " You've succesfully placed your RMA ${object.name}\n" -#~ " on ${object.company_id.name}. Our team will check it and will " -#~ "validate\n" -#~ " it as soon as possible.\n" -#~ "

\n" -#~ " Do not hesitate to contact us if you have any question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Gentile ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " ha inserito con successo il suo RMA ${object.name}\n" -#~ " per ${object.company_id.name}. Il nostro team lo verificherà \n" -#~ " il prima possibile.\n" -#~ "

\n" -#~ " Non esiti a contattarci per qualsiasi domanda.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ " Cancelled" -#~ msgstr "" -#~ " Cancellato" - -#~ msgid "" -#~ " Preparation" -#~ msgstr "" -#~ " Preparazione" - -#~ msgid "" -#~ " Shipped" -#~ msgstr "" -#~ " Spedito" - -#~ msgid "" -#~ " Partially Available" -#~ msgstr "" -#~ " Parzialmente disponibile" - -#~ msgid "Delivered qty" -#~ msgstr "Quantità Consegnata" - -#~ msgid "Delivered qty done" -#~ msgstr "Quantità consegnata fatta" - -#~ msgid "Followers (Channels)" -#~ msgstr "Seguito da (canali)" - -#~ msgid "Number of messages which requires an action" -#~ msgstr "Numero di messaggi che richiedono un'azione" - -#~ msgid "Number of unread messages" -#~ msgstr "Numero di messaggi non letti" - -#, python-format -#~ msgid "" -#~ "Quantity to extract cannot be greater than remaining delivery quantity " -#~ "(%s %s)" -#~ msgstr "" -#~ "La quantità da prelevare non può essere superiore alla quantità di " -#~ "consegna rimanente (%s %s)" - -#~ msgid "Refund line" -#~ msgstr "Riga rimborso" - -#, python-format -#~ msgid "" -#~ "Replacement: Move %s (Picking %s) has been created." -#~ msgstr "" -#~ "Sostituzione: Il trasferimento %s (Picking %s) è stato creato." - -#, python-format -#~ msgid "" -#~ "Replacement:
Product %s
Quantity %f %s
This replacement did not " -#~ "create a new move, but one of the previously created moves was updated " -#~ "with this data." -#~ msgstr "" -#~ "Sostituzione:
Il prodotto%s
Quantità%f %s
Questo prodotto " -#~ "non ha generato un nuovo trasferimento, ma uno dei trasferimenti già " -#~ "creati è stato aggiornato con questi dati." - -#, python-format -#~ msgid "" -#~ "Return: %s has been created." -#~ msgstr "" -#~ "Reso: %s è stato creato." - -#, python-format -#~ msgid "" -#~ "Split: %s has " -#~ "been created." -#~ msgstr "" -#~ "Divisione: %s è " -#~ "stato creato." - -#, python-format -#~ msgid "" -#~ "The quantity done for the product '%s' must be equal to its initial " -#~ "demand because the stock move is linked to an RMA (%s)." -#~ msgstr "" -#~ "La quantità completata per il prodotto '%s' deve essere uguale alla " -#~ "quantità iniziale perchè il movimento è legato ad un RMA (%s)." - -#~ msgid "Unread Messages" -#~ msgstr "Messaggi non letti" - -#~ msgid "Unread Messages Counter" -#~ msgstr "Numero messaggi non letti" - -#~ msgid "Users" -#~ msgstr "Utenti" diff --git a/rma/i18n/pt.po b/rma/i18n/pt.po index 4e62e96b..96198c83 100644 --- a/rma/i18n/pt.po +++ b/rma/i18n/pt.po @@ -2205,155 +2205,3 @@ msgid "" "{{object.company_id.name}} Your RMA has been succesfully created (Ref " "{{object.name or 'n/a' }})" msgstr "" - -#~ msgid "" -#~ "" -#~ msgstr "" -#~ "" - -#~ msgid "Alias domain" -#~ msgstr "Domínio do Alias" - -#~ msgid "Last Modified on" -#~ msgstr "Última Modificação Em" - -#~ msgid "Main Attachment" -#~ msgstr "Anexo Principal" - -#~ msgid "Owner" -#~ msgstr "Proprietário" - -#~ msgid "RMA Confirmation Email" -#~ msgstr "E-mail de Confirmação da RMA" - -#~ msgid "Remaining delivered qty to done" -#~ msgstr "Qtd. restante entregue a fazer" - -#~ msgid "" -#~ "The owner of records created upon receiving emails on this alias. If this " -#~ "field is not set the system will attempt to find the right owner based on " -#~ "the sender (From) address, or will use the Administrator account if no " -#~ "system user is found for that address." -#~ msgstr "" -#~ "O proprietário dos registos criados ao receber emails nesse alias. Se " -#~ "esse campo não estiver definido, o sistema tentará encontrar o " -#~ "proprietário certo com base no endereço do remetente (De) ou usará a " -#~ "conta de Administrador se nenhum utilizador do sistema for encontrado " -#~ "para esse endereço." - -#~ msgid "${(object.name or '')}" -#~ msgstr "${(object.name or '')}" - -#~ msgid "${object.company_id.name} RMA (Ref ${object.name or 'n/a' })" -#~ msgstr "${object.company_id.name} RMA (Refª ${object.name or 'n/a' })" - -#~ msgid "" -#~ " Cancelled" -#~ msgstr "" -#~ " Cancelado" - -#~ msgid "" -#~ " Preparation" -#~ msgstr "" -#~ " Preparação" - -#~ msgid "" -#~ " Shipped" -#~ msgstr "" -#~ " Expedido" - -#~ msgid "" -#~ " Partially Available" -#~ msgstr "" -#~ " Parcialmente Disponível" - -#~ msgid "Delivered qty" -#~ msgstr "Quantidade Enviada" - -#~ msgid "Delivered qty done" -#~ msgstr "Quantidade Envidada Concluída" - -#~ msgid "Followers (Channels)" -#~ msgstr "Seguidores (Canais)" - -#~ msgid "Number of messages which requires an action" -#~ msgstr "Número de Mensagens que Requerem a sua Atenção" - -#~ msgid "Number of unread messages" -#~ msgstr "Número de Mensagens Não Lidas" - -#, python-format -#~ msgid "" -#~ "Quantity to extract cannot be greater than remaining delivery quantity " -#~ "(%s %s)" -#~ msgstr "" -#~ "A quantidade a extrair não pode ser maior do que a quantidade restante da " -#~ "entrega (%s %s)" - -#~ msgid "Refund line" -#~ msgstr "Linha de reembolso" - -#, python-format -#~ msgid "" -#~ "Replacement: Move %s (Picking %s) has been created." -#~ msgstr "" -#~ "Substituição: Movimentação %s (A Coleta %s foi criada." - -#, python-format -#~ msgid "" -#~ "Replacement:
Product %s
Quantity %f %s
This replacement did not " -#~ "create a new move, but one of the previously created moves was updated " -#~ "with this data." -#~ msgstr "" -#~ "Substituição:
Produto %s
Quantidade %f%s
Essa " -#~ "substituição não criou uma nova movimentação, mas uma das movimentos " -#~ "criadas anteriormente foi atualizada com esses dados." - -#, python-format -#~ msgid "" -#~ "Return: %s has been created." -#~ msgstr "" -#~ "Devolução: %s foi criada." - -#, python-format -#~ msgid "" -#~ "Split: %s has " -#~ "been created." -#~ msgstr "" -#~ "Divisão: %s foi " -#~ "criada." - -#, python-format -#~ msgid "" -#~ "The quantity done for the product '%s' must be equal to its initial " -#~ "demand because the stock move is linked to an RMA (%s)." -#~ msgstr "" -#~ "A quantidade realizada para o produto '%s' deve ser igual à sua demanda " -#~ "inicial, porque a movimentação do stock está vinculada a uma RMA (%s)." - -#~ msgid "Unread Messages" -#~ msgstr "Mensagens não lidas" - -#~ msgid "Unread Messages Counter" -#~ msgstr "Contador de Mensagens Não Lidas" - -#~ msgid "Users" -#~ msgstr "Utilizadores" diff --git a/rma/i18n/pt_BR.po b/rma/i18n/pt_BR.po index 8463a504..42469749 100644 --- a/rma/i18n/pt_BR.po +++ b/rma/i18n/pt_BR.po @@ -2202,145 +2202,3 @@ msgid "" "{{object.company_id.name}} Your RMA has been succesfully created (Ref " "{{object.name or 'n/a' }})" msgstr "" - -#~ msgid "Alias domain" -#~ msgstr "Domínio do Alias" - -#~ msgid "Last Modified on" -#~ msgstr "Última Modificação Feita em" - -#~ msgid "Main Attachment" -#~ msgstr "Anexo Principal" - -#~ msgid "Owner" -#~ msgstr "Proprietário" - -#~ msgid "Remaining delivered qty to done" -#~ msgstr "Quantidade restante entregue a concluir" - -#~ msgid "" -#~ "The owner of records created upon receiving emails on this alias. If this " -#~ "field is not set the system will attempt to find the right owner based on " -#~ "the sender (From) address, or will use the Administrator account if no " -#~ "system user is found for that address." -#~ msgstr "" -#~ "O proprietário dos registros criados ao receber emails nesse alias. Se " -#~ "esse campo não estiver definido, o sistema tentará encontrar o " -#~ "proprietário certo com base no endereço do remetente (De) ou usará a " -#~ "conta de Administrador se nenhum usuário do sistema for encontrado para " -#~ "esse endereço." - -#~ msgid "${(object.name or '')}" -#~ msgstr "${(object.name or '')}" - -#~ msgid "${object.company_id.name} RMA (Ref ${object.name or 'n/a' })" -#~ msgstr "${object.company_id.name} RMA (Ref ${object.name or 'n/a' })" - -#~ msgid "" -#~ " Cancelled" -#~ msgstr "" -#~ " Cancelado" - -#~ msgid "" -#~ " Preparation" -#~ msgstr "" -#~ " Preparo" - -#~ msgid "" -#~ " Shipped" -#~ msgstr "" -#~ " Embarcado" - -#~ msgid "" -#~ " Partially Available" -#~ msgstr "" -#~ " Parcialmente Disponível" - -#~ msgid "Delivered qty" -#~ msgstr "Quantidade Enviada" - -#~ msgid "Delivered qty done" -#~ msgstr "Quantidade Envidada Concluída" - -#~ msgid "Followers (Channels)" -#~ msgstr "Seguidores (Canais)" - -#~ msgid "Number of messages which requires an action" -#~ msgstr "Número de Mensagens que Requerem sua Atenção" - -#~ msgid "Number of unread messages" -#~ msgstr "Número de Mensagens Não Lidas" - -#, python-format -#~ msgid "" -#~ "Quantity to extract cannot be greater than remaining delivery quantity " -#~ "(%s %s)" -#~ msgstr "" -#~ "A quantidade a extrair não pode ser maior que a quantidade de entrega " -#~ "restante (%s %s)" - -#~ msgid "Refund line" -#~ msgstr "Linha de Restituição" - -#, python-format -#~ msgid "" -#~ "Replacement: Move %s (Picking %s) has been created." -#~ msgstr "" -#~ "Substituição: Movimentação %s (A Coleta %s foi criada." - -#, python-format -#~ msgid "" -#~ "Replacement:
Product %s
Quantity %f %s
This replacement did not " -#~ "create a new move, but one of the previously created moves was updated " -#~ "with this data." -#~ msgstr "" -#~ "Substituição:
Produto %s
Quantidade %f%s
Essa " -#~ "substituição não criou uma nova movimentação, mas uma das movimentos " -#~ "criadas anteriormente foi atualizada com esses dados." - -#, python-format -#~ msgid "" -#~ "Return: %s has been created." -#~ msgstr "" -#~ "Retorno: %s foi criado." - -#, python-format -#~ msgid "" -#~ "Split: %s has " -#~ "been created." -#~ msgstr "" -#~ "Divisão: %s foi " -#~ "criada." - -#, python-format -#~ msgid "" -#~ "The quantity done for the product '%s' must be equal to its initial " -#~ "demand because the stock move is linked to an RMA (%s)." -#~ msgstr "" -#~ "A quantidade realizada para o produto '%s' deve ser igual à sua demanda " -#~ "inicial, porque a movimentação do estoque está vinculada a uma RMA (%s)." - -#~ msgid "Unread Messages" -#~ msgstr "Mensagens não lidas" - -#~ msgid "Unread Messages Counter" -#~ msgstr "Contador de Mensagens Não Lidas" - -#~ msgid "Users" -#~ msgstr "Usuários" diff --git a/rma/i18n/ro.po b/rma/i18n/ro.po index cb1f3a79..861b1135 100644 --- a/rma/i18n/ro.po +++ b/rma/i18n/ro.po @@ -2188,122 +2188,3 @@ msgid "" "{{object.company_id.name}} Your RMA has been succesfully created (Ref " "{{object.name or 'n/a' }})" msgstr "" - -#~ msgid "Last Modified on" -#~ msgstr "Ultima modificare în" - -#~ msgid "Owner" -#~ msgstr "Proprietar" - -#~ msgid "" -#~ "The owner of records created upon receiving emails on this alias. If this " -#~ "field is not set the system will attempt to find the right owner based on " -#~ "the sender (From) address, or will use the Administrator account if no " -#~ "system user is found for that address." -#~ msgstr "" -#~ "Proprietarul înregistrărilor create la primirea e-mailurilor de la acest " -#~ "alias. Dacă acest câmp nu este setat, sistemul va încerca să găsească " -#~ "proprietarul potrivit în funcție de adresa expeditorului (De la) sau va " -#~ "utiliza contul de administrator dacă nu este găsit niciun utilizator de " -#~ "sistem pentru acea adresă." - -#~ msgid "${(object.name or '')}" -#~ msgstr "${(object.name or '')}" - -#~ msgid "${object.company_id.name} RMA (Ref ${object.name or 'n/a' })" -#~ msgstr "${object.company_id.name} Retur (Ref ${object.name or 'n/a' })" - -#, python-format -#~ msgid "E-mail subject: %s

E-mail body:
%s" -#~ msgstr "Subiect e-mail: %s

Conținut e-mail:
%s" - -#~ msgid "" -#~ "
\n" -#~ "

\n" -#~ " Dear ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " Here is the RMA ${object.name} from ${object." -#~ "company_id.name}.\n" -#~ "

\n" -#~ " Do not hesitate to contact us if you have any question.\n" -#~ "

\n" -#~ "
\n" -#~ " " -#~ msgstr "" -#~ "
\n" -#~ "

\n" -#~ " Dragă ${object.partner_id.name}\n" -#~ " % if object.partner_id.parent_id:\n" -#~ " (${object.partner_id.parent_id.name})\n" -#~ " % endif\n" -#~ "

\n" -#~ " Aici este formularul de retur ${object.name} de la " -#~ "${object.company_id.name}.\n" -#~ "

\n" -#~ " Nu ezitați să ne contactați dacă aveți întrebări.\n" -#~ "

\n" -#~ "
\n" -#~ " " - -#~ msgid "" -#~ " Cancelled" -#~ msgstr "" -#~ " Anulat" - -#~ msgid "" -#~ " Preparation" -#~ msgstr "" -#~ " Pregătire" - -#~ msgid "" -#~ " Shipped" -#~ msgstr "" -#~ " Expediat" - -#~ msgid "" -#~ " Partially Available" -#~ msgstr "" -#~ " Disponibil parțial" - -#~ msgid "Delivered qty" -#~ msgstr "Cantitate livrată" - -#~ msgid "Delivered qty done" -#~ msgstr "Cantitate livrată efectivă" - -#~ msgid "Followers (Channels)" -#~ msgstr "Urmăritori (Canale)" - -#, python-format -#~ msgid "" -#~ "Quantity to extract cannot be greater than remaining delivery quantity " -#~ "(%s %s)" -#~ msgstr "" -#~ "Cantitatea de extras nu poate fi mai mare decât cantitatea de livrare " -#~ "rămasă (%s %s)" - -#~ msgid "Refund line" -#~ msgstr "Linie ramburs" - -#, python-format -#~ msgid "" -#~ "Replacement: Move %s (Picking %s) has been created." -#~ msgstr "" -#~ "Înlocuire: Mișcarea %s (Transfer %s) a fost creat." diff --git a/rma/migrations/17.0.1.2.0/post-migration.py b/rma/migrations/17.0.1.2.0/post-migration.py deleted file mode 100644 index 71132ec7..00000000 --- a/rma/migrations/17.0.1.2.0/post-migration.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2024 Tecnativa - Víctor Martínez -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade - - -@openupgrade.migrate() -def migrate(env, version): - """Similar behavior to create_rma_routes of post_init_hook.""" - warehouses = env["stock.warehouse"].search([]) - warehouses = warehouses.with_context(rma_post_init_hook=True) - for wh in warehouses: - if not wh.rma_in_type_id or not wh.rma_out_type_id: - data = wh._create_or_update_sequences_and_picking_types() - wh.write(data) - route_vals = wh._create_or_update_route() - wh.write(route_vals) diff --git a/rma/models/account_move.py b/rma/models/account_move.py index 251f2ff1..de193012 100644 --- a/rma/models/account_move.py +++ b/rma/models/account_move.py @@ -1,7 +1,7 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, fields, models +from odoo import fields, models from odoo.exceptions import ValidationError from odoo.tools import float_compare @@ -33,7 +33,7 @@ class AccountMove(models.Model): """ if self._check_rma_invoice_lines_qty(): raise ValidationError( - _( + self.env._( "There is at least one invoice lines whose quantity is " "less than the quantity specified in its linked RMA." ) diff --git a/rma/models/res_company.py b/rma/models/res_company.py index 2b55930a..77532842 100644 --- a/rma/models/res_company.py +++ b/rma/models/res_company.py @@ -2,7 +2,7 @@ # Copyright 2023 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import api, fields, models class ResCompany(models.Model): @@ -79,7 +79,7 @@ class ResCompany(models.Model): .sudo() .create( { - "name": _("RMA Code"), + "name": self.env._("RMA Code"), "prefix": "RMA", "code": "rma", "padding": 4, diff --git a/rma/models/res_config_settings.py b/rma/models/res_config_settings.py index c06d9e59..43960f8b 100644 --- a/rma/models/res_config_settings.py +++ b/rma/models/res_config_settings.py @@ -21,6 +21,7 @@ class ResConfigSettings(models.TransientModel): ) rma_mail_confirmation_template_id = fields.Many2one( related="company_id.rma_mail_confirmation_template_id", + domain="[('model', '=', 'rma')]", readonly=False, ) send_rma_receipt_confirmation = fields.Boolean( @@ -29,6 +30,7 @@ class ResConfigSettings(models.TransientModel): ) rma_mail_receipt_confirmation_template_id = fields.Many2one( related="company_id.rma_mail_receipt_confirmation_template_id", + domain="[('model', '=', 'rma')]", readonly=False, ) send_rma_draft_confirmation = fields.Boolean( @@ -37,5 +39,6 @@ class ResConfigSettings(models.TransientModel): ) rma_mail_draft_confirmation_template_id = fields.Many2one( related="company_id.rma_mail_draft_confirmation_template_id", + domain="[('model', '=', 'rma')]", readonly=False, ) diff --git a/rma/models/rma.py b/rma/models/rma.py index 9c36e500..d04282f5 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -9,7 +9,7 @@ from itertools import groupby from markupsafe import Markup -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import AccessError, ValidationError from odoo.tools import html2plaintext @@ -40,7 +40,7 @@ class Rma(models.Model): name = fields.Char( index=True, copy=False, - default=lambda self: _("New"), + default=lambda self: self.env._("New"), ) origin = fields.Char( string="Source Document", @@ -314,9 +314,7 @@ class Rma(models.Model): for r in self: r.remaining_qty = r.product_uom_qty - r.delivered_qty - @api.depends( - "state", - ) + @api.depends("state") def _compute_can_be_refunded(self): """Compute 'can_be_refunded'. This field controls the visibility of 'Refund' button in the rma form view and determinates if @@ -497,7 +495,7 @@ class Rma(models.Model): @api.model_create_multi def create(self, vals_list): for vals in vals_list: - if vals.get("name", _("New")) == _("New"): + if vals.get("name", self.env._("New")) == self.env._("New"): ir_sequence = self.env["ir.sequence"] if "company_id" in vals: ir_sequence = ir_sequence.with_company(vals["company_id"]) @@ -514,18 +512,19 @@ class Rma(models.Model): return rmas def copy(self, default=None): - team = super().copy(default) - for follower in self.message_follower_ids: - team.message_subscribe( - partner_ids=follower.partner_id.ids, - subtype_ids=follower.subtype_ids.ids, - ) - return team + new_rmas = super().copy(default) + for old_rma, new_rma in zip(self, new_rmas, strict=False): + for follower in old_rma.message_follower_ids: + new_rma.message_subscribe( + partner_ids=follower.partner_id.ids, + subtype_ids=follower.subtype_ids.ids, + ) + return new_rmas def unlink(self): if self.filtered(lambda r: r.state != "draft"): raise ValidationError( - _("You cannot delete RMAs that are not in draft state") + self.env._("You cannot delete RMAs that are not in draft state") ) return super().unlink() @@ -601,10 +600,6 @@ class Rma(models.Model): if self.partner_id and self.partner_id not in self.message_partner_ids: self.message_subscribe([self.partner_id.id]) - def _product_is_storable(self, product=None): - product = product or self.product_id - return product.type in ["product", "consu"] - def _prepare_procurement_group_vals(self): return { "move_type": "direct", @@ -643,7 +638,7 @@ class Rma(models.Model): procurements = [] group_model = self.env["procurement.group"] for rma in self: - if not rma._product_is_storable(): + if not rma.product_id.is_storable: continue group = rma.procurement_group_id if not group: @@ -824,7 +819,7 @@ class Rma(models.Model): """Invoked when 'Refund' smart button in rma form view is clicked.""" self.ensure_one() return { - "name": _("Refund"), + "name": self.env._("Refund"), "type": "ir.actions.act_window", "view_type": "form", "view_mode": "form", @@ -873,7 +868,7 @@ class Rma(models.Model): ) desc += f"\n{field_record.field_description}" if desc: - raise ValidationError(_("Required field(s):%s") % desc) + raise ValidationError(self.env._("Required field(s):%s") % desc) def _ensure_can_be_returned(self): """This method is intended to be invoked after user click on @@ -888,9 +883,11 @@ class Rma(models.Model): """ if len(self) == 1: if not self.can_be_returned: - raise ValidationError(_("This RMA cannot perform a return.")) + raise ValidationError(self.env._("This RMA cannot perform a return.")) elif not self.filtered("can_be_returned"): - raise ValidationError(_("None of the selected RMAs can perform a return.")) + raise ValidationError( + self.env._("None of the selected RMAs can perform a return.") + ) def _ensure_can_be_replaced(self): """This method is intended to be invoked after user click on @@ -903,10 +900,12 @@ class Rma(models.Model): """ if len(self) == 1: if not self.can_be_replaced: - raise ValidationError(_("This RMA cannot perform a replacement.")) + raise ValidationError( + self.env._("This RMA cannot perform a replacement.") + ) elif not self.filtered("can_be_replaced"): raise ValidationError( - _("None of the selected RMAs can perform a replacement.") + self.env._("None of the selected RMAs can perform a replacement.") ) def _ensure_can_be_split(self): @@ -917,7 +916,7 @@ class Rma(models.Model): """ self.ensure_one() if not self.can_be_split: - raise ValidationError(_("This RMA cannot be split.")) + raise ValidationError(self.env._("This RMA cannot be split.")) def _ensure_qty_to_return(self, qty=None, uom=None): """This method is intended to be invoked after confirm the wizard. @@ -928,7 +927,9 @@ class Rma(models.Model): qty = uom._compute_quantity(qty, self.product_uom) if qty > self.remaining_qty: raise ValidationError( - _("The quantity to return is greater than " "remaining quantity.") + self.env._( + "The quantity to return is greater than " "remaining quantity." + ) ) def _ensure_qty_to_extract(self, qty, uom): @@ -940,7 +941,7 @@ class Rma(models.Model): to_split_uom_qty = uom._compute_quantity(qty, self.product_uom) if to_split_uom_qty > self.remaining_qty: raise ValidationError( - _( + self.env._( "Quantity to extract cannot be greater than remaining" " delivery quantity (%(remaining_qty)s %(product_uom)s)" ) @@ -980,7 +981,7 @@ class Rma(models.Model): ) self.message_post( body=Markup( - _( + self.env._( 'Split: %(name)s has been created.' ) @@ -1103,7 +1104,7 @@ class Rma(models.Model): self._ensure_can_be_returned() self._ensure_qty_to_return(qty, uom) rmas_to_return = self.filtered( - lambda rma: rma.can_be_returned and rma._product_is_storable() + lambda rma: rma.can_be_returned and rma.product_id.is_storable ) procurements = rmas_to_return._prepare_delivery_procurements( scheduled_date, qty, uom @@ -1116,7 +1117,7 @@ class Rma(models.Model): pickings[picking] |= rma rma.message_post( body=Markup( - _( + self.env._( 'Return: %(name)s has been created.' ) @@ -1146,7 +1147,7 @@ class Rma(models.Model): procurements = [] group_model = self.env["procurement.group"] for rma in self: - if not rma._product_is_storable(product): + if not product.is_storable: continue if not rma.procurement_group_id: @@ -1186,7 +1187,7 @@ class Rma(models.Model): # MRP BoM Kits for new_move in new_moves: body += Markup( - _( + self.env._( 'Replacement: Move %(move_name)s (Picking " 'Product %(name)s
' @@ -1255,14 +1256,14 @@ class Rma(models.Model): custom_values = {} subject = msg_dict.get("subject", "") body = html2plaintext(msg_dict.get("body", "")) - desc = _( + desc = self.env._( "E-mail subject: %(subject)s

E-mail" " body:
%(body)s" ) % ({"subject": subject, "body": body}) defaults = { "description": desc, - "name": _("New"), - "origin": _("Incoming e-mail"), + "name": self.env._("New"), + "origin": self.env._("Incoming e-mail"), } if msg_dict.get("author_id"): partner = self.env["res.partner"].browse(msg_dict.get("author_id")) @@ -1298,7 +1299,7 @@ class Rma(models.Model): try: for record in self.filtered("partner_id"): record._message_add_suggested_recipient( - recipients, partner=record.partner_id, reason=_("Customer") + recipients, partner=record.partner_id, reason=self.env._("Customer") ) except AccessError as e: # no read access rights _logger.debug(e) @@ -1307,7 +1308,7 @@ class Rma(models.Model): # Reporting business methods def _get_report_base_filename(self): self.ensure_one() - return "RMA Report - %s" % self.name + return f"RMA Report - {self.name}" # Other business methods diff --git a/rma/models/rma_team.py b/rma/models/rma_team.py index fd624f60..6ba37bb5 100644 --- a/rma/models/rma_team.py +++ b/rma/models/rma_team.py @@ -3,7 +3,7 @@ import ast -from odoo import _, fields, models +from odoo import fields, models class RmaTeam(models.Model): @@ -40,18 +40,17 @@ class RmaTeam(models.Model): ) def copy(self, default=None): - self.ensure_one() - if default is None: - default = {} - if not default.get("name"): - default["name"] = _("%s (copy)") % self.name - team = super().copy(default) - for follower in self.message_follower_ids: - team.message_subscribe( - partner_ids=follower.partner_id.ids, - subtype_ids=follower.subtype_ids.ids, - ) - return team + default = dict(default or {}) + new_teams = super().copy(default) + for old_team, new_team in zip(self, new_teams, strict=False): + if not default.get("name"): + new_team.name = self.env._("%s (copy)") % old_team.name + for follower in old_team.message_follower_ids: + new_team.message_subscribe( + partner_ids=follower.partner_id.ids, + subtype_ids=follower.subtype_ids.ids, + ) + return new_teams def _alias_get_creation_values(self): values = super()._alias_get_creation_values() diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py index 9ea7e1d1..331ffc5f 100644 --- a/rma/models/stock_move.py +++ b/rma/models/stock_move.py @@ -2,7 +2,7 @@ # Copyright 2023 Michael Tietz (MT Software) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import ValidationError from odoo.tools import float_compare @@ -72,7 +72,7 @@ class StockMove(models.Model): != 0 ): raise ValidationError( - _( + self.env._( "The quantity done for the product '%(id)s' must " "be equal to its initial demand because the " "stock move is linked to an RMA (%(name)s)." diff --git a/rma/models/stock_picking.py b/rma/models/stock_picking.py index 070cdabd..157ce63e 100644 --- a/rma/models/stock_picking.py +++ b/rma/models/stock_picking.py @@ -16,18 +16,6 @@ class StockPicking(models.Model): for rec in self: rec.rma_count = len(rec.move_ids.mapped("rma_ids")) - def copy(self, default=None): - self.ensure_one() - if self.env.context.get("set_rma_picking_type"): - location_dest_id = default.get("location_dest_id") - if location_dest_id: - warehouse = self.env["stock.warehouse"].search( - [("rma_loc_id", "parent_of", location_dest_id)], limit=1 - ) - if warehouse: - default["picking_type_id"] = warehouse.rma_in_type_id.id - return super().copy(default) - def action_view_rma(self): self.ensure_one() action = self.env["ir.actions.act_window"]._for_xml_id("rma.rma_action") diff --git a/rma/models/stock_warehouse.py b/rma/models/stock_warehouse.py index 79ad9dbf..9b356d03 100644 --- a/rma/models/stock_warehouse.py +++ b/rma/models/stock_warehouse.py @@ -2,7 +2,7 @@ # Copyright 2023 Michael Tietz (MT Software) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, fields, models +from odoo import fields, models class StockWarehouse(models.Model): @@ -19,17 +19,24 @@ class StockWarehouse(models.Model): rma_in_type_id = fields.Many2one( comodel_name="stock.picking.type", string="RMA In Type", + check_company=True, + copy=False, ) rma_out_type_id = fields.Many2one( comodel_name="stock.picking.type", string="RMA Out Type", + check_company=True, + copy=False, ) rma_loc_id = fields.Many2one( - comodel_name="stock.location", - string="RMA Location", + comodel_name="stock.location", string="RMA Location", check_company=True + ) + rma_in_route_id = fields.Many2one( + "stock.route", "RMA in Route", ondelete="restrict", copy=False + ) + rma_out_route_id = fields.Many2one( + "stock.route", "RMA out Route", ondelete="restrict", copy=False ) - rma_in_route_id = fields.Many2one("stock.route", "RMA in Route") - rma_out_route_id = fields.Many2one("stock.route", "RMA out Route") def _get_rma_location_values(self, vals, code=False): """this method is intended to be used by 'create' method @@ -49,7 +56,6 @@ class StockWarehouse(models.Model): return { "name": view_location.name, "active": True, - "return_location": True, "usage": "internal", "company_id": company_id, "location_id": self.env.ref("rma.stock_location_rma").id, @@ -63,17 +69,19 @@ class StockWarehouse(models.Model): def _get_sequence_values(self, name=False, code=False): values = super()._get_sequence_values(name=name, code=code) + name = name if name else self.name + code = code if code else self.code values.update( { "rma_in_type_id": { - "name": self.name + " " + _("Sequence RMA in"), - "prefix": self.code + "/RMA/IN/", + "name": name + " " + self.env._("Sequence RMA in"), + "prefix": code + "/RMA/IN/", "padding": 5, "company_id": self.company_id.id, }, "rma_out_type_id": { - "name": self.name + " " + _("Sequence RMA out"), - "prefix": self.code + "/RMA/OUT/", + "name": name + " " + self.env._("Sequence RMA out"), + "prefix": code + "/RMA/OUT/", "padding": 5, "company_id": self.company_id.id, }, @@ -96,23 +104,21 @@ class StockWarehouse(models.Model): data.update( { "rma_in_type_id": { - "name": _("RMA Receipts"), + "name": self.env._("RMA Receipts"), "code": "incoming", "use_create_lots": False, "use_existing_lots": True, - "default_location_src_id": False, "default_location_dest_id": self.rma_loc_id.id, "sequence": max_sequence + 1, "sequence_code": "RMA/IN", "company_id": self.company_id.id, }, "rma_out_type_id": { - "name": _("RMA Delivery Orders"), + "name": self.env._("RMA Delivery Orders"), "code": "outgoing", "use_create_lots": False, "use_existing_lots": True, "default_location_src_id": self.rma_loc_id.id, - "default_location_dest_id": False, "sequence": max_sequence + 2, "sequence_code": "RMA/OUT", "company_id": self.company_id.id, diff --git a/rma/security/rma_security.xml b/rma/security/rma_security.xml index 54833bc1..6916e527 100644 --- a/rma/security/rma_security.xml +++ b/rma/security/rma_security.xml @@ -71,25 +71,19 @@ RMA multi-company - ['|',('company_id','=',False),('company_id','in',company_ids)] + [('company_id', 'in', company_ids + [False])] RMA team multi-company - ['|',('company_id','=',False),('company_id','in',company_ids)] + [('company_id', 'in', company_ids + [False])] RMA Finalization Reason multi-company - ['|', ('company_id', 'in', company_ids), ('company_id', '=', False)] + [('company_id', 'in', company_ids + [False])] diff --git a/rma/tests/test_rma.py b/rma/tests/test_rma.py index 1bd39979..046f7d2f 100644 --- a/rma/tests/test_rma.py +++ b/rma/tests/test_rma.py @@ -1,5 +1,6 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # Copyright 2023 Michael Tietz (MT Software) +# Copyright 2025 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.exceptions import UserError, ValidationError @@ -28,7 +29,7 @@ class TestRma(BaseCommon): ) cls.rma_loc = cls.warehouse_company.rma_loc_id cls.product = cls.product_product.create( - {"name": "Product test 1", "type": "product"} + {"name": "Product test 1", "type": "consu", "is_storable": True} ) cls.account_receiv = cls.env["account.account"].create( { @@ -123,7 +124,7 @@ class TestRma(BaseCommon): move.product_uom_qty = 10 with picking_form.move_ids_without_package.new() as move: move.product_id = self.product_product.create( - {"name": "Product 2 test", "type": "product"} + {"name": "Product 2 test", "type": "consu", "is_storable": True} ) move.product_uom_qty = 20 picking = picking_form.save() @@ -169,14 +170,44 @@ class TestRmaCase(TestRma): wizard_form.product_uom_qty = rma.product_uom_qty wizard = wizard_form.save() wizard.action_deliver() - self.assertEqual(rma.delivery_picking_count, 2) - out_pickings = rma.mapped("delivery_move_ids.picking_id") - self.assertIn( - self.warehouse.pick_type_id, out_pickings.mapped("picking_type_id") - ) - self.assertIn( - self.warehouse.out_type_id, out_pickings.mapped("picking_type_id") + out_picking = rma.delivery_move_ids.picking_id + out_picking.move_ids.quantity = 1 + out_picking.button_validate() + self.assertEqual(out_picking.state, "done") + self.assertEqual(out_picking.picking_type_id, self.warehouse.pick_type_id) + next_transfer = out_picking._get_next_transfers() + self.assertEqual(next_transfer.picking_type_id, self.warehouse.out_type_id) + self.assertEqual(rma.delivery_picking_count, 1) + + def test_rma_replace_pick_pack_ship(self): + self.warehouse.write({"delivery_steps": "pick_pack_ship"}) + rma = self._create_rma(self.partner, self.product, 1, self.rma_loc) + rma.action_confirm() + rma.reception_move_id.quantity = 1 + rma.reception_move_id.picking_id.button_validate() + self.assertEqual(rma.reception_move_id.picking_id.state, "done") + self.assertEqual(rma.state, "received") + res = rma.action_replace() + wizard_form = Form(self.env[res["res_model"]].with_context(**res["context"])) + wizard_form.product_id = self.product + wizard_form.product_uom_qty = rma.product_uom_qty + wizard = wizard_form.save() + wizard.action_deliver() + out_picking = rma.delivery_move_ids.picking_id + out_picking.move_ids.quantity = 1 + out_picking.button_validate() + self.assertEqual(out_picking.state, "done") + self.assertEqual(out_picking.picking_type_id, self.warehouse.pick_type_id) + next_transfer = out_picking._get_next_transfers() + self.assertEqual(next_transfer.picking_type_id, self.warehouse.pack_type_id) + next_transfer.move_ids.quantity = 1 + next_transfer.button_validate() + self.assertEqual(next_transfer.state, "done") + next_transfer_extra = next_transfer._get_next_transfers() + self.assertEqual( + next_transfer_extra.picking_type_id, self.warehouse.out_type_id ) + self.assertEqual(rma.delivery_picking_count, 1) def test_computed(self): # If partner changes, the invoice address is set @@ -193,7 +224,12 @@ class TestRmaCase(TestRma): } ) product_2 = self.product_product.create( - {"name": "Product test 2", "type": "product", "uom_id": uom_ten.id} + { + "name": "Product test 2", + "type": "consu", + "is_storable": True, + "uom_id": uom_ten.id, + } ) outgoing_picking_type = self.env["stock.picking.type"].search( [ @@ -305,6 +341,7 @@ class TestRmaCase(TestRma): self.assertEqual(rma_2.state, "received") @users("__system__", "user_rma") + @mute_logger("odoo.models.unlink") def test_action_refund(self): rma = self._create_confirm_receive(self.partner, self.product, 10, self.rma_loc) self.assertEqual(rma.state, "received") @@ -339,6 +376,7 @@ class TestRmaCase(TestRma): self.assertFalse(rma.can_be_returned) self.assertFalse(rma.can_be_replaced) + @mute_logger("odoo.models.unlink") def test_mass_refund(self): # Create, confirm and receive rma_1 rma_1 = self._create_confirm_receive( @@ -351,7 +389,7 @@ class TestRmaCase(TestRma): ) # rma_3: Same partner and different product than rma_1 product = self.product_product.create( - {"name": "Product 2 test", "type": "product"} + {"name": "Product 2 test", "type": "consu", "is_storable": True} ) rma_3 = self._create_confirm_receive(self.partner, product, 20, self.rma_loc) # rma_4: Different partner and same product as rma_1 @@ -424,7 +462,7 @@ class TestRmaCase(TestRma): rma = self._create_confirm_receive(self.partner, self.product, 10, self.rma_loc) # Replace with another product with quantity 2. product_2 = self.product_product.create( - {"name": "Product 2 test", "type": "product"} + {"name": "Product 2 test", "type": "consu", "is_storable": True} ) delivery_form = Form( self.env["rma.delivery.wizard"].with_context( @@ -450,7 +488,7 @@ class TestRmaCase(TestRma): picking = first_move.picking_id # Replace again with another product with the remaining quantity product_3 = self.product_product.create( - {"name": "Product 3 test", "type": "product"} + {"name": "Product 3 test", "type": "consu", "is_storable": True} ) delivery_form = Form( self.env["rma.delivery.wizard"].with_context( @@ -572,7 +610,7 @@ class TestRmaCase(TestRma): ) # rma_3: Same partner and different product than rma_1 product = self.product_product.create( - {"name": "Product 2 test", "type": "product"} + {"name": "Product 2 test", "type": "consu", "is_storable": True} ) rma_3 = self._create_confirm_receive(self.partner, product, 20, self.rma_loc) # rma_4: Different partner and same product as rma_1 @@ -653,7 +691,7 @@ class TestRmaCase(TestRma): ) # rma_3: Same partner and different product than rma_1 product = self.product_product.create( - {"name": "Product 2 test", "type": "product"} + {"name": "Product 2 test", "type": "consu", "is_storable": True} ) rma_3 = self._create_confirm_receive(self.partner, product, 20, self.rma_loc) # rma_4: Different partner and same product as rma_1 @@ -685,7 +723,11 @@ class TestRmaCase(TestRma): stock_return_picking_form.create_rma = True stock_return_picking_form.rma_operation_id = self.operation return_wizard = stock_return_picking_form.save() - picking_action = return_wizard.create_returns() + for move in origin_delivery.move_ids_without_package: + return_wizard.product_return_moves.filtered( + lambda x, move=move: x.move_id == move + ).quantity = move.quantity + picking_action = return_wizard.action_create_returns() # Each origin move is linked to a different RMA origin_moves = origin_delivery.move_ids self.assertTrue(origin_moves[0].rma_ids) diff --git a/rma/views/res_config_settings_views.xml b/rma/views/res_config_settings_views.xml index bccd9b3b..28de3ee9 100644 --- a/rma/views/res_config_settings_views.xml +++ b/rma/views/res_config_settings_views.xml @@ -78,7 +78,6 @@ name="rma_mail_confirmation_template_id" class="oe_inline" required="send_rma_confirmation" - context="{'default_model': 'rma'}" />
@@ -116,7 +115,6 @@ name="rma_mail_receipt_confirmation_template_id" class="oe_inline" required="send_rma_receipt_confirmation" - context="{'default_model': 'rma'}" /> @@ -154,7 +152,6 @@ name="rma_mail_draft_confirmation_template_id" class="oe_inline" required="send_rma_draft_confirmation" - context="{'default_model': 'rma'}" /> diff --git a/rma/views/rma_finalization_views.xml b/rma/views/rma_finalization_views.xml index 463a74e4..c34dd81f 100644 --- a/rma/views/rma_finalization_views.xml +++ b/rma/views/rma_finalization_views.xml @@ -45,11 +45,11 @@ rma.finalization - + - + diff --git a/rma/views/rma_portal_templates.xml b/rma/views/rma_portal_templates.xml index ed82652e..c0c873db 100644 --- a/rma/views/rma_portal_templates.xml +++ b/rma/views/rma_portal_templates.xml @@ -73,7 +73,7 @@ - + @@ -93,251 +93,313 @@ /> - - -
- - RMA Order - - - +
+ + RMA Order - + + + + + + + + + + + + - - - + class="badge badge-pill badge-info label-text-align" + t-esc="tag.name" + /> + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + -
- - -
-
- -
-
- Customer: -
-
-
- Contact - Contact -
-
-
-
-
+ + + + + + + + + + +
+
+
+ +
+
+ Customer: +
+
+
+ Contact
- -
-
- Shipping address: -
-
-
- Contact - Contact -
-
-
-
-
-
- -
-
- Responsible: -
-
-
- Contact - Contact -
-
-
-
-
-
-
-
-
-
-
- Origin delivery -
-
- -
-
- -
-
- Product -
-
- -
-
-
-
- Quantity -
-
- -
-
-
-
- Delivered quantity -
-
- -
-
-
-
-
-
- RMA Date -
-
- -
-
-
-
- Deadline -
-
- -
-
-
-
- Origin -
-
- -
-
+
+
-
+
+
+ Shipping address: +
+
+
+ Contact +
+
+
+
+
+
+ +
+
+ Responsible: +
+
+
+ Contact +
+
+
+
+
+
+
+
+
+
+
+ Origin delivery +
+
+ +
+
+ +
+
+ Product +
+
+ +
+
+
+
+ Quantity +
+
+ +
+
+
+
+ Delivered quantity +
+
+ +
+
+
+
+
+
+ RMA Date +
+
+ +
+
+
+
+ Deadline +
+
+ +
+
+
+
+ Origin +
+
+ +
+
+
+
+
+
+ Reception + + + +
+ + +
+ Date: + +
+
+ + + + Shipped + + + + + + Partially Available + + + + + + Cancelled + + + + + + Preparation + + +
+
+
+ Refund + + + +
+ + +
+ Date: + +
+
+ + + Paid + + + + Waiting Payment + +
+
+
+ Delivery +
    + - Reception - -
-
- Refund - - - -
- - -
- Date: - -
-
- - - Paid - - - - Waiting Payment - -
-
-
- Delivery - -
-
-

Description

-
- -
- - + + + +
+

Description

+
+ +

Communication

diff --git a/rma/views/rma_tag_views.xml b/rma/views/rma_tag_views.xml index 3cd8b915..f62464aa 100644 --- a/rma/views/rma_tag_views.xml +++ b/rma/views/rma_tag_views.xml @@ -37,11 +37,11 @@ rma.tag - + - + diff --git a/rma/views/rma_team_views.xml b/rma/views/rma_team_views.xml index 49a1c76e..ba6fa013 100644 --- a/rma/views/rma_team_views.xml +++ b/rma/views/rma_team_views.xml @@ -5,13 +5,13 @@ rma.team - + - + @@ -52,30 +52,32 @@ - -
-
- Avatar + +
+ +
+ -
- - - -
+
-
+ @@ -115,17 +117,14 @@ -
- - -
+ RMA team rma.team - tree,form + list,form

Click to add a new RMA. diff --git a/rma/views/rma_views.xml b/rma/views/rma_views.xml index bccfd6fa..47020b0c 100644 --- a/rma/views/rma_views.xml +++ b/rma/views/rma_views.xml @@ -103,7 +103,7 @@ rma.view.tree rma - - + @@ -340,11 +340,7 @@ groups="base.group_multi_company" readonly="state in ['locked', 'cancelled']" /> - + @@ -373,7 +369,6 @@ widget="priority" readonly="state != 'draft'" /> - @@ -386,23 +381,8 @@ - - - - - - - - - - - -

- - - -
+
@@ -458,7 +438,7 @@ RMA rma - tree,form,pivot,calendar,activity + list,form,pivot,calendar,activity {}

diff --git a/rma/wizard/rma_delivery.py b/rma/wizard/rma_delivery.py index b47aa75e..b4c7ba28 100644 --- a/rma/wizard/rma_delivery.py +++ b/rma/wizard/rma_delivery.py @@ -1,7 +1,7 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import ValidationError @@ -40,7 +40,7 @@ class RmaReDeliveryWizard(models.TransientModel): self.ensure_one() rma_ids = self.env.context.get("active_ids") if len(rma_ids) == 1 and self.product_uom_qty <= 0: - raise ValidationError(_("Quantity must be greater than 0.")) + raise ValidationError(self.env._("Quantity must be greater than 0.")) @api.model def default_get(self, fields_list): diff --git a/rma/wizard/rma_delivery_views.xml b/rma/wizard/rma_delivery_views.xml index 3209002f..0694e762 100644 --- a/rma/wizard/rma_delivery_views.xml +++ b/rma/wizard/rma_delivery_views.xml @@ -18,7 +18,6 @@ /> - - -

diff --git a/rma/wizard/stock_picking_return.py b/rma/wizard/stock_picking_return.py index 3bed8265..065f7ecd 100644 --- a/rma/wizard/stock_picking_return.py +++ b/rma/wizard/stock_picking_return.py @@ -1,11 +1,12 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # Copyright 2023 Michael Tietz (MT Software) +# Copyright 2025 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from copy import deepcopy -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import ValidationError -from odoo.tools import float_compare +from odoo.tools import float_is_zero class ReturnPickingLine(models.TransientModel): @@ -27,12 +28,13 @@ class ReturnPickingLine(models.TransientModel): def _prepare_rma_vals(self): self.ensure_one() + warehouse = self.move_id.picking_id.picking_type_id.warehouse_id return { "move_id": self.move_id.id, "product_id": self.move_id.product_id.id, "product_uom_qty": self.quantity, "product_uom": self.product_id.uom_id.id, - "location_id": self.wizard_id.location_id.id or self.move_id.location_id.id, + "location_id": warehouse.rma_loc_id.id, "operation_id": self.rma_operation_id.id, } @@ -42,47 +44,17 @@ class ReturnPicking(models.TransientModel): create_rma = fields.Boolean(string="Create RMAs") picking_type_code = fields.Selection(related="picking_id.picking_type_id.code") - rma_location_ids = fields.Many2many( - comodel_name="stock.location", compute="_compute_rma_location_id" - ) rma_operation_id = fields.Many2one( comodel_name="rma.operation", string="Requested operation", ) - # Expand domain for RMAs - location_id = fields.Many2one( - domain="create_rma and [('id', 'child_of', rma_location_ids)]" - "or " - "['|', ('id', '=', original_location_id), '|', '&', " - "('return_location', '=', True), ('company_id', '=', False), '&', " - "('return_location', '=', True), ('company_id', '=', company_id)]" - ) - - @api.depends("picking_id") - def _compute_rma_location_id(self): - for record in self: - record.rma_location_ids = ( - self.env["stock.warehouse"] - .search([("company_id", "=", record.picking_id.company_id.id)]) - .rma_loc_id - ) @api.onchange("create_rma") def _onchange_create_rma(self): if self.create_rma: - warehouse = self.picking_id.picking_type_id.warehouse_id - self.location_id = warehouse.rma_loc_id.id # We want to avoid setting the return move `to_refund` as it will change # the delivered quantities in the sale and set them to invoice. self.product_return_moves.to_refund = False - else: - # If self.create_rma is not True, the value of the location will be the - # same as assigned by default - location_id = self.picking_id.location_id.id - return_picking_type = self.picking_id.picking_type_id.return_picking_type_id - if return_picking_type.default_location_dest_id.return_location: - location_id = return_picking_type.default_location_dest_id.id - self.location_id = location_id def _prepare_rma_partner_values(self): self.ensure_one() @@ -119,10 +91,8 @@ class ReturnPicking(models.TransientModel): for return_picking in self: global_vals = return_picking._prepare_rma_vals() for line in return_picking.product_return_moves: - if ( - not line.move_id - or float_compare(line.quantity, 0, line.product_id.uom_id.rounding) - <= 0 + if not line.move_id or float_is_zero( + line.quantity, precision_rounding=line.uom_id.rounding ): continue vals = deepcopy(global_vals) @@ -130,7 +100,7 @@ class ReturnPicking(models.TransientModel): vals_list.append(vals) return vals_list - def create_returns(self): + def action_create_returns(self): """Override create_returns method for creating one or more 'confirmed' RMAs after return a delivery picking in case 'Create RMAs' checkbox is checked in this wizard. @@ -141,7 +111,7 @@ class ReturnPicking(models.TransientModel): if self.create_rma: if not self.picking_id.partner_id: raise ValidationError( - _( + self.env._( "You must specify the 'Customer' in the " "'Stock Picking' from which RMAs will be created" ) @@ -165,11 +135,11 @@ class ReturnPicking(models.TransientModel): } ) return { - "name": _("Returned Picking"), - "view_mode": "form,tree,calendar", + "name": self.env._("Returned Picking"), + "view_mode": "form,list,calendar", "res_model": "stock.picking", "res_id": picking.id, "type": "ir.actions.act_window", "context": ctx, } - return super().create_returns() + return super().action_create_returns() diff --git a/rma/wizard/stock_picking_return_views.xml b/rma/wizard/stock_picking_return_views.xml index 167519d9..4cc0b1e7 100644 --- a/rma/wizard/stock_picking_return_views.xml +++ b/rma/wizard/stock_picking_return_views.xml @@ -8,7 +8,7 @@ stock.return.picking - + - - - -