From d59518cca0e41aad101e1e21ebbdb3ada900b28f Mon Sep 17 00:00:00 2001 From: docker-odoo Date: Tue, 16 Apr 2024 11:40:57 +0000 Subject: [PATCH] [ADD] website_sale_order_validity: add new module closes ingadhoc/website#279 Signed-off-by: matiasperalta1 --- website_sale_order_validity/README.rst | 56 +++++++++++++++++++ website_sale_order_validity/__init__.py | 6 ++ website_sale_order_validity/__manifest__.py | 32 +++++++++++ .../controllers/__init__.py | 5 ++ .../controllers/main.py | 17 ++++++ website_sale_order_validity/i18n/es_AR.po | 30 ++++++++++ .../models/__init__.py | 4 ++ .../views/templates.xml | 18 ++++++ 8 files changed, 168 insertions(+) create mode 100644 website_sale_order_validity/README.rst create mode 100644 website_sale_order_validity/__init__.py create mode 100644 website_sale_order_validity/__manifest__.py create mode 100644 website_sale_order_validity/controllers/__init__.py create mode 100644 website_sale_order_validity/controllers/main.py create mode 100644 website_sale_order_validity/i18n/es_AR.po create mode 100644 website_sale_order_validity/models/__init__.py create mode 100644 website_sale_order_validity/views/templates.xml diff --git a/website_sale_order_validity/README.rst b/website_sale_order_validity/README.rst new file mode 100644 index 00000000..2cd5e61d --- /dev/null +++ b/website_sale_order_validity/README.rst @@ -0,0 +1,56 @@ +.. |company| replace:: ADHOC SA + +.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png + :alt: ADHOC SA + :target: https://www.adhoc.com.ar + +.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png + +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +================================= +Website Sale Order Validity +================================= + + +Installation +============ + + +Configuration +============= + + +Usage +===== + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* |company| |icon| + +Contributors +------------ + +Maintainer +---------- + +|company_logo| + +This module is maintained by the |company|. + +To contribute to this module, please visit https://www.adhoc.com.ar. diff --git a/website_sale_order_validity/__init__.py b/website_sale_order_validity/__init__.py new file mode 100644 index 00000000..bc704a04 --- /dev/null +++ b/website_sale_order_validity/__init__.py @@ -0,0 +1,6 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import models +from . import controllers diff --git a/website_sale_order_validity/__manifest__.py b/website_sale_order_validity/__manifest__.py new file mode 100644 index 00000000..9434e3de --- /dev/null +++ b/website_sale_order_validity/__manifest__.py @@ -0,0 +1,32 @@ +############################################################################## +# +# Copyright (C) 2015 Moldeo Interactive and ADHOC SA +# All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Website Sale Order Validity', + 'category': 'Hidden', + 'version': "16.0.1.0.0", + 'author': 'ADHOC SA', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'depends': ['website_sale'], + 'data': [ + 'views/templates.xml', + ], + 'installable': True, +} diff --git a/website_sale_order_validity/controllers/__init__.py b/website_sale_order_validity/controllers/__init__.py new file mode 100644 index 00000000..04298136 --- /dev/null +++ b/website_sale_order_validity/controllers/__init__.py @@ -0,0 +1,5 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import main diff --git a/website_sale_order_validity/controllers/main.py b/website_sale_order_validity/controllers/main.py new file mode 100644 index 00000000..6dacd049 --- /dev/null +++ b/website_sale_order_validity/controllers/main.py @@ -0,0 +1,17 @@ +from odoo import http +from odoo.http import request +from werkzeug.utils import redirect + + +class WebsiteSaleController(http.Controller): + @http.route('/update_date_prices_and_validity', type='http', auth='public', website=True) + def update_validity_and_redirect(self): + sale_order_id = request.session.get('sale_order_id') + if sale_order_id: + sale_order = request.env['sale.order'].sudo().browse(sale_order_id) + if request.env['sale.order']._fields.get('validity_days'): + sale_order.update_date_prices_and_validity() + else: + sale_order.action_update_prices() + sale_order._compute_validity_date() + return redirect('/shop/cart') diff --git a/website_sale_order_validity/i18n/es_AR.po b/website_sale_order_validity/i18n/es_AR.po new file mode 100644 index 00000000..c8c88ffe --- /dev/null +++ b/website_sale_order_validity/i18n/es_AR.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_order_validity +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-04-16 16:49+0000\n" +"PO-Revision-Date: 2024-04-16 16:49+0000\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_sale_order_validity +#: model_terms:ir.ui.view,arch_db:website_sale_order_validity.payment_footer +msgid "Update Cart " +msgstr "Actualizar Carrito " + +#. module: website_sale_order_validity +#: model_terms:ir.ui.view,arch_db:website_sale_order_validity.payment_footer +msgid "" +"We inform you that this cart has expired because it has exceeded its " +"validity date. Please click on the \"Update Cart\" button to update the " +"price of your products and finalize your purchase." +msgstr "" +"Le informamos que este carrito ha caducado porque ha excedido su fecha de validez. Por favor, haga clic en el botón \"Actualizar Carrito\" para actualizar el precio de sus productos y finalizar su compra." diff --git a/website_sale_order_validity/models/__init__.py b/website_sale_order_validity/models/__init__.py new file mode 100644 index 00000000..3d8070cd --- /dev/null +++ b/website_sale_order_validity/models/__init__.py @@ -0,0 +1,4 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## diff --git a/website_sale_order_validity/views/templates.xml b/website_sale_order_validity/views/templates.xml new file mode 100644 index 00000000..341e667a --- /dev/null +++ b/website_sale_order_validity/views/templates.xml @@ -0,0 +1,18 @@ + + + +