From 481c22f9db961704d34a40bb5e503a151187647d Mon Sep 17 00:00:00 2001 From: Ernesto Tejeda Date: Wed, 19 Aug 2020 00:19:25 -0400 Subject: [PATCH] [FIX+IMP] rma, rma_sale: fix bugs and add improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix thrown error when trying to download a picking from the portal. - Add the hook method to prepare RMA values ​​from the return pick wizard. - Add the access rule for portal users. - Show the portal 'Request RMAs' button on the sales page only to users related to the sales order. [UPD] Update rma.pot rma 12.0.1.3.0 Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: rma-12.0/rma-12.0-rma Translate-URL: https://translation.odoo-community.org/projects/rma-12-0/rma-12-0-rma/ --- rma/__manifest__.py | 2 +- rma/controllers/main.py | 16 ++++++++-------- rma/data/mail_data.xml | 2 +- rma/i18n/es.po | 21 ++++++++++++--------- rma/i18n/pt_BR.po | 21 ++++++++++++--------- rma/i18n/rma.pot | 18 +++++++++--------- rma/models/rma.py | 6 ++++++ rma/models/stock_move.py | 26 ++++++++++++++++++++++++++ rma/models/stock_warehouse.py | 2 +- rma/security/rma_security.xml | 11 +++++++++-- rma/views/rma_portal_templates.xml | 4 ++-- rma/views/rma_views.xml | 2 +- rma/wizard/stock_picking_return.py | 27 ++++----------------------- 13 files changed, 92 insertions(+), 66 deletions(-) diff --git a/rma/__manifest__.py b/rma/__manifest__.py index 469596da..c55334f1 100644 --- a/rma/__manifest__.py +++ b/rma/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Return Merchandise Authorization Management", "summary": "Return Merchandise Authorization (RMA)", - "version": "12.0.1.2.0", + "version": "12.0.1.3.0", "development_status": "Beta", "category": "RMA", "website": "https://github.com/OCA/rma", diff --git a/rma/controllers/main.py b/rma/controllers/main.py index f53942f1..aeb6d1c8 100644 --- a/rma/controllers/main.py +++ b/rma/controllers/main.py @@ -102,13 +102,13 @@ class PortalRma(CustomerPortal): values = self._rma_get_page_view_values(rma_sudo, access_token, **kw) return request.render("rma.portal_rma_page", values) - @http.route(['/my/rma/picking/pdf/'], + @http.route(['/my/rma/picking/pdf//'], type='http', auth="public", website=True) - def portal_my_rma_picking_report(self, picking_id, access_token=None, - **kw): + def portal_my_rma_picking_report(self, rma_id, picking_id, + access_token=None, **kw): try: - picking_sudo = self._stock_picking_check_access( - picking_id, access_token=access_token) + picking_sudo = self._picking_check_access( + rma_id, picking_id, access_token=access_token) except exceptions.AccessError: return request.redirect('/my') report_sudo = request.env.ref('stock.action_report_delivery').sudo() @@ -119,14 +119,14 @@ class PortalRma(CustomerPortal): ] return request.make_response(pdf, headers=pdfhttpheaders) - def _stock_picking_check_access(self, picking_id, access_token=None): + def _picking_check_access(self, rma_id, picking_id, access_token=None): + rma = request.env['rma'].browse([rma_id]) picking = request.env['stock.picking'].browse([picking_id]) picking_sudo = picking.sudo() try: picking.check_access_rights('read') picking.check_access_rule('read') except exceptions.AccessError: - if not access_token or not consteq( - picking_sudo.sale_id.access_token, access_token): + if not access_token or not consteq(rma.access_token, access_token): raise return picking_sudo diff --git a/rma/data/mail_data.xml b/rma/data/mail_data.xml index 207747bc..7c118726 100644 --- a/rma/data/mail_data.xml +++ b/rma/data/mail_data.xml @@ -5,7 +5,7 @@ Draft RMA rma - New RMA in draft state + RMA in draft state diff --git a/rma/i18n/es.po b/rma/i18n/es.po index e778d696..6a157e2f 100644 --- a/rma/i18n/es.po +++ b/rma/i18n/es.po @@ -537,7 +537,7 @@ msgid "Draft RMA" msgstr "RMA en estado Borrador" #. module: rma -#: code:addons/rma/models/rma.py:1091 +#: code:addons/rma/models/rma.py:1097 #, python-format msgid "" "E-mail subject: %s\n" @@ -640,7 +640,7 @@ msgstr "" "sin eliminarlo." #. module: rma -#: code:addons/rma/models/rma.py:1095 +#: code:addons/rma/models/rma.py:1101 #, python-format msgid "Incoming e-mail" msgstr "Correo electrónico entrante" @@ -747,16 +747,11 @@ msgstr "Nombre" #. module: rma #: code:addons/rma/models/rma.py:31 code:addons/rma/models/rma.py:495 -#: code:addons/rma/models/rma.py:1094 +#: code:addons/rma/models/rma.py:1100 #, python-format msgid "New" msgstr "Nuevo" -#. module: rma -#: model:mail.message.subtype,description:rma.mt_rma_draft -msgid "New RMA in draft state" -msgstr "Nuevo RMA en estado Borrador" - #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__activity_date_deadline msgid "Next Activity Deadline" @@ -1073,6 +1068,11 @@ msgstr "Equipo de RMA del cual el usuario es miembro." msgid "RMA count" msgstr "Cantidad de RMAs" +#. module: rma +#: model:mail.message.subtype,description:rma.mt_rma_draft +msgid "RMA in draft state" +msgstr "" + #. module: rma #: model:ir.model.fields,field_description:rma.field_stock_move__rma_receiver_ids msgid "RMA receivers" @@ -1606,7 +1606,7 @@ msgid "You cannot delete RMAs that are not in draft state" msgstr "No puede " #. module: rma -#: code:addons/rma/wizard/stock_picking_return.py:56 +#: code:addons/rma/wizard/stock_picking_return.py:55 #, python-format msgid "" "You must specify the 'Customer' in the 'Stock Picking' from which RMAs will " @@ -1635,3 +1635,6 @@ msgid "" msgstr "" "El usuario tendrá acceso a la configuración de RMA y a los informes " "estadísticos." + +#~ msgid "New RMA in draft state" +#~ msgstr "Nuevo RMA en estado Borrador" diff --git a/rma/i18n/pt_BR.po b/rma/i18n/pt_BR.po index a64ce479..f3feed42 100644 --- a/rma/i18n/pt_BR.po +++ b/rma/i18n/pt_BR.po @@ -535,7 +535,7 @@ msgid "Draft RMA" msgstr "Rascunho do RMA" #. module: rma -#: code:addons/rma/models/rma.py:1091 +#: code:addons/rma/models/rma.py:1097 #, python-format msgid "" "E-mail subject: %s\n" @@ -638,7 +638,7 @@ msgstr "" "sem removê-lo." #. module: rma -#: code:addons/rma/models/rma.py:1095 +#: code:addons/rma/models/rma.py:1101 #, python-format msgid "Incoming e-mail" msgstr "E-mail recebido" @@ -745,16 +745,11 @@ msgstr "Nome" #. module: rma #: code:addons/rma/models/rma.py:31 code:addons/rma/models/rma.py:495 -#: code:addons/rma/models/rma.py:1094 +#: code:addons/rma/models/rma.py:1100 #, python-format msgid "New" msgstr "Novo(a)" -#. module: rma -#: model:mail.message.subtype,description:rma.mt_rma_draft -msgid "New RMA in draft state" -msgstr "Novo Rascunho de RMA" - #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__activity_date_deadline msgid "Next Activity Deadline" @@ -1071,6 +1066,11 @@ msgstr "Equipe de RMA da qual o usuário é membro." msgid "RMA count" msgstr "Contagem de RMA" +#. module: rma +#: model:mail.message.subtype,description:rma.mt_rma_draft +msgid "RMA in draft state" +msgstr "" + #. module: rma #: model:ir.model.fields,field_description:rma.field_stock_move__rma_receiver_ids msgid "RMA receivers" @@ -1602,7 +1602,7 @@ msgid "You cannot delete RMAs that are not in draft state" msgstr "Você não pode apagar RMAs que não estejam na situação \"Rascunho\"" #. module: rma -#: code:addons/rma/wizard/stock_picking_return.py:56 +#: code:addons/rma/wizard/stock_picking_return.py:55 #, python-format msgid "" "You must specify the 'Customer' in the 'Stock Picking' from which RMAs will " @@ -1630,3 +1630,6 @@ msgid "" msgstr "" "o usuário terá acesso à configuração RMA, bem como aos relatórios " "estatísticos." + +#~ msgid "New RMA in draft state" +#~ msgstr "Novo Rascunho de RMA" diff --git a/rma/i18n/rma.pot b/rma/i18n/rma.pot index 6eac770e..a7f7ba9b 100644 --- a/rma/i18n/rma.pot +++ b/rma/i18n/rma.pot @@ -486,7 +486,7 @@ msgid "Draft RMA" msgstr "" #. module: rma -#: code:addons/rma/models/rma.py:1091 +#: code:addons/rma/models/rma.py:1097 #, python-format msgid "E-mail subject: %s\n" "\n" @@ -576,7 +576,7 @@ msgid "If the active field is set to false, it will allow you to hide the RMA Te msgstr "" #. module: rma -#: code:addons/rma/models/rma.py:1095 +#: code:addons/rma/models/rma.py:1101 #, python-format msgid "Incoming e-mail" msgstr "" @@ -684,16 +684,11 @@ msgstr "" #. module: rma #: code:addons/rma/models/rma.py:31 #: code:addons/rma/models/rma.py:495 -#: code:addons/rma/models/rma.py:1094 +#: code:addons/rma/models/rma.py:1100 #, python-format msgid "New" msgstr "" -#. module: rma -#: model:mail.message.subtype,description:rma.mt_rma_draft -msgid "New RMA in draft state" -msgstr "" - #. module: rma #: model:ir.model.fields,field_description:rma.field_rma__activity_date_deadline msgid "Next Activity Deadline" @@ -989,6 +984,11 @@ msgstr "" msgid "RMA count" msgstr "" +#. module: rma +#: model:mail.message.subtype,description:rma.mt_rma_draft +msgid "RMA in draft state" +msgstr "" + #. module: rma #: model:ir.model.fields,field_description:rma.field_stock_move__rma_receiver_ids msgid "RMA receivers" @@ -1468,7 +1468,7 @@ msgid "You cannot delete RMAs that are not in draft state" msgstr "" #. module: rma -#: code:addons/rma/wizard/stock_picking_return.py:56 +#: code:addons/rma/wizard/stock_picking_return.py:55 #, python-format msgid "You must specify the 'Customer' in the 'Stock Picking' from which RMAs will be created" msgstr "" diff --git a/rma/models/rma.py b/rma/models/rma.py index 8a9ddcd8..ab95a420 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -1080,6 +1080,12 @@ class Rma(models.Model): } # Mail business methods + def _track_subtype(self, init_values): + self.ensure_one() + if 'state' in init_values and self.state == 'draft': + return 'rma.mt_rma_draft' + return super()._track_subtype(init_values) + def message_new(self, msg_dict, custom_values=None): """Extract the needed values from an incoming rma emails data-set to be used to create an RMA. diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py index 8ab511ce..c20e64c6 100644 --- a/rma/models/stock_move.py +++ b/rma/models/stock_move.py @@ -88,6 +88,32 @@ class StockMove(models.Model): res['rma_id'] = self.rma_id.id return res + def _prepare_return_rma_vals(self, original_picking): + """ hook method for preparing an RMA from the 'return picking wizard'. + """ + self.ensure_one() + partner = original_picking.partner_id + if hasattr(original_picking, 'sale_id') and original_picking.sale_id: + partner_invoice_id = original_picking.sale_id.partner_invoice_id.id + else: + partner_invoice_id = partner.address_get( + ['invoice']).get('invoice', False), + return { + 'user_id': self.env.user.id, + 'partner_id': partner.id, + 'partner_invoice_id': partner_invoice_id, + 'origin': original_picking.name, + 'picking_id': original_picking.id, + 'move_id': self.origin_returned_move_id.id, + 'product_id': self.origin_returned_move_id.product_id.id, + 'product_uom_qty': self.product_uom_qty, + 'product_uom': self.product_uom.id, + 'reception_move_id': self.id, + 'company_id': self.company_id.id, + 'location_id': self.location_dest_id.id, + 'state': 'confirmed', + } + class StockRule(models.Model): _inherit = 'stock.rule' diff --git a/rma/models/stock_warehouse.py b/rma/models/stock_warehouse.py index 7c0716d2..5896accd 100644 --- a/rma/models/stock_warehouse.py +++ b/rma/models/stock_warehouse.py @@ -62,7 +62,7 @@ class StockWarehouse(models.Model): sequence_data = warehouse._get_sequence_values() warehouse.rma_in_type_id.sequence_id.write( sequence_data['rma_in_type_id']) - warehouse.rma_in_type_id.sequence_id.write( + warehouse.rma_out_type_id.sequence_id.write( sequence_data['rma_out_type_id']) def _get_picking_type_create_values(self, max_sequence): diff --git a/rma/security/rma_security.xml b/rma/security/rma_security.xml index 5a8037c9..6604005f 100644 --- a/rma/security/rma_security.xml +++ b/rma/security/rma_security.xml @@ -30,16 +30,23 @@ Personal RMAs - + ['|',('user_id','=',user.id),('user_id','=',False)] All RMAs - + [(1,'=',1)] + + + RMA portal users + + [('message_partner_ids', 'child_of', [user.partner_id.commercial_partner_id.id])] + + RMA multi-company diff --git a/rma/views/rma_portal_templates.xml b/rma/views/rma_portal_templates.xml index e4ae704e..9219c044 100644 --- a/rma/views/rma_portal_templates.xml +++ b/rma/views/rma_portal_templates.xml @@ -191,7 +191,7 @@
Reception - +