mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[ADD] website_sale: new module
This module adds a website form to allows to create an RMA from scratch
This commit is contained in:
committed by
Nikolaus Weingartmair
parent
fe7f66a530
commit
1d84cdca60
4
website_rma/__init__.py
Normal file
4
website_rma/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import controllers
|
||||||
|
from . import models
|
||||||
25
website_rma/__manifest__.py
Normal file
25
website_rma/__manifest__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
{
|
||||||
|
"name": "Return Merchandise Authorization Management - Website Form",
|
||||||
|
"summary": "Return Merchandise Authorization (RMA)",
|
||||||
|
"version": "12.0.1.0.0",
|
||||||
|
"development_status": "Production/Stable",
|
||||||
|
"category": "RMA",
|
||||||
|
"website": "https://github.com/OCA/rma",
|
||||||
|
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||||
|
"maintainers": ["ernestotejeda"],
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"depends": [
|
||||||
|
"rma",
|
||||||
|
"website_form",
|
||||||
|
],
|
||||||
|
"data": [
|
||||||
|
"data/ir_model_data.xml",
|
||||||
|
"views/assets.xml",
|
||||||
|
"views/request_rma_form.xml",
|
||||||
|
"views/website_rma_portal_templates.xml",
|
||||||
|
"views/website_templates.xml",
|
||||||
|
"data/website_data.xml",
|
||||||
|
],
|
||||||
|
}
|
||||||
3
website_rma/controllers/__init__.py
Normal file
3
website_rma/controllers/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import main
|
||||||
41
website_rma/controllers/main.py
Normal file
41
website_rma/controllers/main.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
import json
|
||||||
|
from odoo import http
|
||||||
|
from odoo.addons.website_form.controllers.main import WebsiteForm
|
||||||
|
from odoo.http import request
|
||||||
|
|
||||||
|
|
||||||
|
class WebsiteForm(WebsiteForm):
|
||||||
|
|
||||||
|
def insert_record(self, request, model, values, custom, meta=None):
|
||||||
|
if model.model == 'rma':
|
||||||
|
values['partner_id'] = request.env.user.partner_id.id
|
||||||
|
return super(WebsiteForm, self).insert_record(
|
||||||
|
request, model, values, custom, meta=meta)
|
||||||
|
|
||||||
|
|
||||||
|
class WebsiteRMA(http.Controller):
|
||||||
|
|
||||||
|
def _get_website_rma_product_domain(self, q):
|
||||||
|
"""Domain used for the products to be shown in selection of
|
||||||
|
the web form.
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
('name', '=ilike', "%{}%".format(q or '')),
|
||||||
|
("sale_ok", "=", True),
|
||||||
|
]
|
||||||
|
|
||||||
|
@http.route(['/requestrma'], type='http', auth="user", website=True)
|
||||||
|
def request_rma(self, **kw):
|
||||||
|
return http.request.render("website_rma.request_rma", {})
|
||||||
|
|
||||||
|
@http.route('/website_rma/get_products', type='http', auth="user",
|
||||||
|
methods=['GET'], website=True)
|
||||||
|
def rma_product_read(self, q='', l=25, **post):
|
||||||
|
data = request.env['product.product'].sudo().search_read(
|
||||||
|
domain=self._get_website_rma_product_domain(q),
|
||||||
|
fields=['id', 'display_name', 'uom_id'],
|
||||||
|
limit=int(l),
|
||||||
|
)
|
||||||
|
return json.dumps(data)
|
||||||
24
website_rma/data/ir_model_data.xml
Normal file
24
website_rma/data/ir_model_data.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="rma.model_rma" model="ir.model">
|
||||||
|
<field name="website_form_default_field_id" ref="rma.field_rma__description" />
|
||||||
|
<field name="website_form_access">True</field>
|
||||||
|
<field name="website_form_label">Request RMA</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
<function model="ir.model.fields" name="formbuilder_whitelist">
|
||||||
|
<value>rma</value>
|
||||||
|
<value eval="[
|
||||||
|
'partner_id',
|
||||||
|
'product_id',
|
||||||
|
'product_uom_qty',
|
||||||
|
'product_uom',
|
||||||
|
'operation_id',
|
||||||
|
'description',
|
||||||
|
'state',
|
||||||
|
]"/>
|
||||||
|
</function>
|
||||||
|
</odoo>
|
||||||
13
website_rma/data/website_data.xml
Normal file
13
website_rma/data/website_data.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="request_rma_thanks_page" model="website.page">
|
||||||
|
<field name="url">/requestrma-thank-you</field>
|
||||||
|
<field name="website_indexed" eval="False"/>
|
||||||
|
<field name="website_published">True</field>
|
||||||
|
<field name="view_id" ref="request_rma_thanks_page_view"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
138
website_rma/i18n/es.po
Normal file
138
website_rma/i18n/es.po
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * website_rma
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 12.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2020-09-04 17:22+0000\n"
|
||||||
|
"PO-Revision-Date: 2020-09-04 13:34-0400\n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"Language: es\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
"X-Generator: Poedit 2.0.6\n"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "&times;"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Description"
|
||||||
|
msgstr "Descripción"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model:ir.model,name:website_rma.model_ir_model
|
||||||
|
msgid "Models"
|
||||||
|
msgstr "Modelos"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Operation"
|
||||||
|
msgstr "Operación"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Our team will process it an will reach you once it's validated."
|
||||||
|
msgstr "Nuestro equipo lo procesará y le contactará una vez que sea validada."
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Product"
|
||||||
|
msgstr "Producto"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Quantity"
|
||||||
|
msgstr "Cantidad"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Request"
|
||||||
|
msgstr "Solicitar"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
#, fuzzy
|
||||||
|
msgid "Request RMA"
|
||||||
|
msgstr "Solicitar RMA"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "Thanks!"
|
||||||
|
msgstr "¡Gracias!"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "We will get back to you shortly."
|
||||||
|
msgstr "Le contestaremos en breve."
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.contact_us_request_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.portal_my_home_rma
|
||||||
|
msgid "You can request an RMA"
|
||||||
|
msgstr "Puede solicitar"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "Your request has been sent successfully."
|
||||||
|
msgstr "Su solicitud ha sido enviada satisfactoriamente."
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.contact_us_request_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.portal_my_home_rma
|
||||||
|
msgid "here"
|
||||||
|
msgstr "aquí"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.contact_us_request_rma
|
||||||
|
msgid ""
|
||||||
|
"if you do not\n"
|
||||||
|
" know the sales order from which it was "
|
||||||
|
"made.\n"
|
||||||
|
" If you know the sales order, go to it "
|
||||||
|
"and click on the corresponding button."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.portal_my_home_rma
|
||||||
|
msgid ""
|
||||||
|
"if you do not\n"
|
||||||
|
" know the sales order from which it was "
|
||||||
|
"made. If you know\n"
|
||||||
|
" the sales order, go to it and click on "
|
||||||
|
"the corresponding button."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#~ msgid ""
|
||||||
|
#~ "if you do not\n"
|
||||||
|
#~ " know the sales order from which it was made.\n"
|
||||||
|
#~ " If you know the sales order, go to it and "
|
||||||
|
#~ "click on the corresponding button."
|
||||||
|
#~ msgstr ""
|
||||||
|
#~ "directamente una devolución si no conoce\n"
|
||||||
|
#~ " el pedido de venta desde el que se realizó.\n"
|
||||||
|
#~ " Si conoce el pedido, vaya a él y pulse en el "
|
||||||
|
#~ "botón correspondiente."
|
||||||
|
|
||||||
|
#~ msgid ""
|
||||||
|
#~ "if you do not\n"
|
||||||
|
#~ " know the sales order from which it was made. If you "
|
||||||
|
#~ "know\n"
|
||||||
|
#~ " the sales order, go to it and click on the "
|
||||||
|
#~ "corresponding button."
|
||||||
|
#~ msgstr ""
|
||||||
|
#~ "directamente una devolución si no conoce\n"
|
||||||
|
#~ " el pedido de venta desde el que se realizó.\n"
|
||||||
|
#~ " Si conoce el pedido, vaya a él y pulse en el "
|
||||||
|
#~ "botón correspondiente."
|
||||||
105
website_rma/i18n/website_rma.pot
Normal file
105
website_rma/i18n/website_rma.pot
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * website_rma
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 12.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "&times;"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Description"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model:ir.model,name:website_rma.model_ir_model
|
||||||
|
msgid "Models"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Operation"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Our team will process it an will reach you once it's validated."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Product"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Quantity"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Request"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma
|
||||||
|
msgid "Request RMA"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "Thanks!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "We will get back to you shortly."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.contact_us_request_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.portal_my_home_rma
|
||||||
|
msgid "You can request an RMA"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.request_rma_thanks_page_ir_ui_view
|
||||||
|
#: model_terms:website.page,arch_db:website_rma.request_rma_thanks_page
|
||||||
|
msgid "Your request has been sent successfully."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.contact_us_request_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.portal_my_home_rma
|
||||||
|
msgid "here"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.contact_us_request_rma
|
||||||
|
msgid "if you do not\n"
|
||||||
|
" know the sales order from which it was made.\n"
|
||||||
|
" If you know the sales order, go to it and click on the corresponding button."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: website_rma
|
||||||
|
#: model_terms:ir.ui.view,arch_db:website_rma.portal_my_home_rma
|
||||||
|
msgid "if you do not\n"
|
||||||
|
" know the sales order from which it was made. If you know\n"
|
||||||
|
" the sales order, go to it and click on the corresponding button."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
3
website_rma/models/__init__.py
Normal file
3
website_rma/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import ir_model
|
||||||
23
website_rma/models/ir_model.py
Normal file
23
website_rma/models/ir_model.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import api, models
|
||||||
|
|
||||||
|
|
||||||
|
class IrModel(models.Model):
|
||||||
|
_inherit = 'ir.model'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def get_authorized_fields(self, model_name):
|
||||||
|
"""Hack this method to force some rma fields to be authorized in
|
||||||
|
creating an object from a web form using the website_form module.
|
||||||
|
|
||||||
|
Those fields are readonly in all states except 'draft' state,
|
||||||
|
but the main method get_authorized_fields interprets them as
|
||||||
|
readonly always.
|
||||||
|
"""
|
||||||
|
res = super().get_authorized_fields(model_name)
|
||||||
|
if model_name == 'rma':
|
||||||
|
auth_fields = ['product_uom_qty', 'product_uom', 'partner_id']
|
||||||
|
res.update(self.env[model_name].fields_get(auth_fields))
|
||||||
|
return res
|
||||||
5
website_rma/readme/CONTRIBUTORS.rst
Normal file
5
website_rma/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||||
|
|
||||||
|
* Ernesto Tejeda
|
||||||
|
* Pedro M. Baeza
|
||||||
|
* David Vidal
|
||||||
2
website_rma/readme/README.rst
Normal file
2
website_rma/readme/README.rst
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
This module extends the functionality of rma and website to allow you
|
||||||
|
to request an RMA through a form in the website.
|
||||||
12
website_rma/readme/USAGE.rst
Normal file
12
website_rma/readme/USAGE.rst
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
To use this module, you need to:
|
||||||
|
|
||||||
|
#. Go to the website
|
||||||
|
#. Go to *Your username (at the upper-right corner) > My account* or
|
||||||
|
access to <your-url-domain>/my (Example: https://www.odoo.com/my).
|
||||||
|
#. Under your documents list you can see a text with a link to the page
|
||||||
|
where you can create an RMA through a form.
|
||||||
|
#. Click on this link to access to this page or access to
|
||||||
|
<your-url-domain>/requestrma (Example: https://www.odoo.com/requestrma).
|
||||||
|
#. Fill the desired and required fields and click on the button 'Request'.
|
||||||
|
#. If everything is right, a new RMA document will created, you will be
|
||||||
|
redirected to a page with a thank you message.
|
||||||
BIN
website_rma/static/description/icon.png
Normal file
BIN
website_rma/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
45
website_rma/static/src/js/website_rma.js
Normal file
45
website_rma/static/src/js/website_rma.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/* Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
/* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
*/
|
||||||
|
odoo.define('website_rma.website_rma', function(require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
require('web.dom_ready');
|
||||||
|
|
||||||
|
$("#rma_request_form input[name='product_id']").select2({
|
||||||
|
width: '100%',
|
||||||
|
placeholder: 'Select a product',
|
||||||
|
allowClear: true,
|
||||||
|
selection_data: false,
|
||||||
|
ajax: {
|
||||||
|
url: '/website_rma/get_products',
|
||||||
|
dataType: 'json',
|
||||||
|
data: function(term) {
|
||||||
|
return {
|
||||||
|
q: term,
|
||||||
|
l: 50
|
||||||
|
};
|
||||||
|
},
|
||||||
|
results: function(data) {
|
||||||
|
var res = [];
|
||||||
|
_.each(data, function(x) {
|
||||||
|
res.push({
|
||||||
|
id: x.id,
|
||||||
|
text: x.display_name,
|
||||||
|
uom_id: x.uom_id[0],
|
||||||
|
uom_name: x.uom_id[1]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return {results: res};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// Set UoM on selected onchange
|
||||||
|
$("#rma_request_form input[name='product_id']").change(function(){
|
||||||
|
var select2_data = $(this).select2('data');
|
||||||
|
var uom_id = select2_data ? select2_data['uom_id'] : ''
|
||||||
|
var uom_name = select2_data ? select2_data['uom_name'] : ''
|
||||||
|
$("input[name='product_uom']").val(uom_id);
|
||||||
|
$("input[name='product_uom_name']").val(uom_name);
|
||||||
|
});
|
||||||
|
});
|
||||||
45
website_rma/static/src/js/website_rma.tour.js
Normal file
45
website_rma/static/src/js/website_rma.tour.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/* Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
/* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
*/
|
||||||
|
odoo.define('website_sale_vat_required.tour', function(require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var tour = require("web_tour.tour");
|
||||||
|
var base = require("web_editor.base");
|
||||||
|
|
||||||
|
tour.register("request_rma",
|
||||||
|
{
|
||||||
|
test: true,
|
||||||
|
url: "/my",
|
||||||
|
wait_for: base.ready()
|
||||||
|
},
|
||||||
|
[
|
||||||
|
{
|
||||||
|
content: "Click on RMA form page link",
|
||||||
|
trigger: ".o_portal_my_home a[href='/requestrma']",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: 'Click on request button with the form empty',
|
||||||
|
trigger: "a.o_website_form_send",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: 'Fill form',
|
||||||
|
trigger: "#rma_request_form",
|
||||||
|
extra_trigger: "#rma_request_form",
|
||||||
|
run: function (actions) {
|
||||||
|
$("select[name='operation_id'] > option:eq(1)").prop('selected', true);
|
||||||
|
$("textarea[name='description']").val("RMA test from website form");
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: 'Click on request button with the form empty',
|
||||||
|
trigger: "a.o_website_form_send",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
content: "Click on RMA form page link",
|
||||||
|
trigger: "div#request_rma_thanks",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
});
|
||||||
3
website_rma/tests/__init__.py
Normal file
3
website_rma/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from . import test_website_rma
|
||||||
51
website_rma/tests/test_website_rma.py
Normal file
51
website_rma/tests/test_website_rma.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo.tests.common import Form, HttpCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestWebsiteRma(HttpCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
self.product = self.env['product.product'].create({
|
||||||
|
'name': 'Website rma 1',
|
||||||
|
'type': 'product',
|
||||||
|
})
|
||||||
|
picking_type = self.env['stock.picking.type'].search(
|
||||||
|
[
|
||||||
|
('code', '=', 'outgoing'),
|
||||||
|
'|',
|
||||||
|
('warehouse_id.company_id', '=', self.env.user.company_id.id),
|
||||||
|
('warehouse_id', '=', False)
|
||||||
|
],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
picking_form = Form(
|
||||||
|
recordp=self.env['stock.picking'].with_context(
|
||||||
|
default_picking_type_id=picking_type.id),
|
||||||
|
view="stock.view_picking_form",
|
||||||
|
)
|
||||||
|
picking_form.partner_id = self.env.user.partner_id
|
||||||
|
with picking_form.move_ids_without_package.new() as move:
|
||||||
|
move.product_id = self.product
|
||||||
|
move.product_uom_qty = 10
|
||||||
|
picking = picking_form.save()
|
||||||
|
picking.action_confirm()
|
||||||
|
picking.move_lines.quantity_done = 10
|
||||||
|
picking.button_validate()
|
||||||
|
|
||||||
|
def test_website_form_request_rma(self):
|
||||||
|
self.browser_js(
|
||||||
|
url_path="/my",
|
||||||
|
code="odoo.__DEBUG__.services['web_tour.tour']"
|
||||||
|
".run('request_rma')",
|
||||||
|
ready="odoo.__DEBUG__.services['web_tour.tour']"
|
||||||
|
".tours.request_rma.ready",
|
||||||
|
login="admin",
|
||||||
|
)
|
||||||
|
rma = self.env['rma'].search([
|
||||||
|
('operation_id', '!=', False),
|
||||||
|
('description', '=', "RMA test from website form"),
|
||||||
|
])
|
||||||
|
self.assertTrue(bool(rma))
|
||||||
11
website_rma/views/assets.xml
Normal file
11
website_rma/views/assets.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
<template id="website_rma_assets_frontend" inherit_id="website.assets_frontend">
|
||||||
|
<xpath expr="script[last()]" position="after">
|
||||||
|
<script type="text/javascript" src="/website_rma/static/src/js/website_rma.tour.js"></script>
|
||||||
|
<script type="text/javascript" src="/website_rma/static/src/js/website_rma.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
||||||
148
website_rma/views/request_rma_form.xml
Normal file
148
website_rma/views/request_rma_form.xml
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<template id="request_rma" name="Request RMA">
|
||||||
|
<t t-call="website.layout">
|
||||||
|
<div id="wrap">
|
||||||
|
<div class="oe_structure mt-2" id="oe_structure_website_rma_form_request_0"/>
|
||||||
|
<section class="pt8 pb8">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row s_nb_column_fixed">
|
||||||
|
<div class="col-lg-12 s_title pt16 pb16">
|
||||||
|
<h1>Request RMA</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<div class="container mt-2">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<div class="oe_structure mt-2" id="oe_structure_website_rma_form_request_1"/>
|
||||||
|
<section class="s_text_block">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<p>
|
||||||
|
Our team will process it an will reach you once it's validated.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<div class="request_rma_container">
|
||||||
|
<form action="/website_form/"
|
||||||
|
method="post"
|
||||||
|
data-model_name="rma"
|
||||||
|
data-success_page="/requestrma-thank-you"
|
||||||
|
class="s_website_form container-fluid mt32"
|
||||||
|
enctype="multipart/form-data"
|
||||||
|
data-editable-form="false"
|
||||||
|
id="rma_request_form">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-3 col-md-4 col-form-label"
|
||||||
|
for="product_id">
|
||||||
|
Product
|
||||||
|
</label>
|
||||||
|
<div class="col-lg-7 col-md-8">
|
||||||
|
<input type="hidden"
|
||||||
|
name="product_id"
|
||||||
|
class="form-control o_website_form_input"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row form-field o_website_form_required">
|
||||||
|
<label class="col-lg-3 col-md-4 col-form-label"
|
||||||
|
for="product_uom_qty">
|
||||||
|
Quantity
|
||||||
|
</label>
|
||||||
|
<div class="col-lg-4 col-md-5">
|
||||||
|
<input class="form-control o_website_form_input"
|
||||||
|
pattern="^\d*(\.\d{0,3})?$"
|
||||||
|
name="product_uom_qty"
|
||||||
|
required=""
|
||||||
|
t-att-value="request.params.get('product_uom_qty', '1.000')"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3 col-md-3">
|
||||||
|
<input type="hidden" name="product_uom"/>
|
||||||
|
<input type="text"
|
||||||
|
class="form-control o_website_form_input"
|
||||||
|
name="product_uom_name"
|
||||||
|
disabled="true"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row form-field">
|
||||||
|
<label class="col-lg-3 col-md-4 col-form-label" for="operation_id">Operation</label>
|
||||||
|
<div class="col-lg-7 col-md-8">
|
||||||
|
<select name="operation_id"
|
||||||
|
class="form-control custom-select o_website_form_input">
|
||||||
|
<option/>
|
||||||
|
<t t-foreach="request.env['rma.operation'].sudo().search([])" t-as="o">
|
||||||
|
<option t-att-value="o.id">
|
||||||
|
<t t-esc="o.name" />
|
||||||
|
</option>
|
||||||
|
</t>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row form-field o_website_form_required_custom">
|
||||||
|
<label class="col-lg-3 col-md-4 col-form-label" for="description">Description</label>
|
||||||
|
<div class="col-lg-7 col-md-8">
|
||||||
|
<textarea class="form-control o_website_form_input"
|
||||||
|
name="description"
|
||||||
|
required=""><t t-esc="request.params.get('description', '')"/></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="offset-lg-3 offset-md-4 col-md-8 col-lg-7">
|
||||||
|
<a href="#" role="button" class="btn btn-primary btn-lg o_website_form_send">Request</a>
|
||||||
|
<span id="o_website_form_result"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="oe_structure mt-2" id="oe_structure_website_rma_form_request_2"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<t t-call="website.company_description"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="oe_structure mt-2" id="oe_structure_website_rma_form_request_3"/>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<record id="request_rma_thanks_page_view" model="ir.ui.view">
|
||||||
|
<field name="name">Thanks (Request RMA)</field>
|
||||||
|
<field name="type">qweb</field>
|
||||||
|
<field name="key">website_rma.requestrma_thanks</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<t name="Thanks (Request RMA)" t-name="website_crm.requestrma_thanks">
|
||||||
|
<t t-call="website.layout">
|
||||||
|
<div id="wrap">
|
||||||
|
<div class="oe_structure" id="oe_structure_website_rma_request_rma_thanks_1"/>
|
||||||
|
<div class="container" id="request_rma_thanks">
|
||||||
|
<h1>Thanks!</h1>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<div class="alert alert-success" role="status">
|
||||||
|
Your request has been sent successfully.
|
||||||
|
<button type="button" class="close" data-dismiss="alert">&times;</button>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
We will get back to you shortly.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<t t-call="website.company_description"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="oe_structure" id="oe_structure_website_rma_request_rma_thanks_2"/>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
24
website_rma/views/website_rma_portal_templates.xml
Normal file
24
website_rma/views/website_rma_portal_templates.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
<template id="portal_my_home_rma" name="Portal My Home : RMA entries" inherit_id="portal.portal_my_home" priority="30">
|
||||||
|
<xpath expr="//div[hasclass('o_portal_docs')]" position="after">
|
||||||
|
<div class="oe_structure">
|
||||||
|
<section class="s_text_block mt16">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 bg-300">
|
||||||
|
<p style="margin-top: 1rem;">
|
||||||
|
You can request an RMA <strong><a href="/requestrma">here</a></strong> if you do not
|
||||||
|
know the sales order from which it was made. If you know
|
||||||
|
the sales order, go to it and click on the corresponding button.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
||||||
24
website_rma/views/website_templates.xml
Normal file
24
website_rma/views/website_templates.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2020 Tecnativa - Ernesto Tejeda
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
<template id="contact_us_request_rma" name="Request RMA" inherit_id="website.contactus">
|
||||||
|
<xpath expr="//t[@t-call='website.company_description']/../../div[hasclass('col-lg-8')]" position="inside">
|
||||||
|
<div class="oe_structure">
|
||||||
|
<section class="s_text_block">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 bg-300">
|
||||||
|
<p style="margin-top: 1rem;">
|
||||||
|
You can request an RMA <strong><a href="/requestrma">here</a></strong> if you do not
|
||||||
|
know the sales order from which it was made.
|
||||||
|
If you know the sales order, go to it and click on the corresponding button.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user