Skip to content

Commit

Permalink
[ADD] website_sale_order_validity: add new module
Browse files Browse the repository at this point in the history
closes #279

Signed-off-by: matiasperalta1 <[email protected]>
  • Loading branch information
lef-adhoc committed Apr 25, 2024
1 parent 1753ed7 commit d59518c
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 0 deletions.
56 changes: 56 additions & 0 deletions website_sale_order_validity/README.rst
Original file line number Diff line number Diff line change
@@ -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
<https://github.com/ingadhoc/website/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.
6 changes: 6 additions & 0 deletions website_sale_order_validity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import models
from . import controllers
32 changes: 32 additions & 0 deletions website_sale_order_validity/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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,
}
5 changes: 5 additions & 0 deletions website_sale_order_validity/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import main
17 changes: 17 additions & 0 deletions website_sale_order_validity/controllers/main.py
Original file line number Diff line number Diff line change
@@ -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')
30 changes: 30 additions & 0 deletions website_sale_order_validity/i18n/es_AR.po
Original file line number Diff line number Diff line change
@@ -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 <i class=\"fa fa-refresh\"/>"
msgstr "Actualizar Carrito <i class=\"fa fa-refresh\"/>"

#. 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."
4 changes: 4 additions & 0 deletions website_sale_order_validity/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
18 changes: 18 additions & 0 deletions website_sale_order_validity/views/templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template name="Payment" id="payment_footer" inherit_id="website_sale.payment_footer">
<button name="o_payment_submit_button" position="attributes">
<attribute name="t-if">website_sale_order.validity_date and website_sale_order.validity_date &gt;= datetime.datetime.now().date()</attribute>
</button>
<button name="o_payment_submit_button" position="after">
<a t-if="website_sale_order.validity_date and website_sale_order.validity_date &lt; datetime.datetime.now().date()" href="/update_date_prices_and_validity" class="btn btn-primary">
Update Cart <i class="fa fa-refresh"/>
</a>
</button>
<xpath expr="//div[hasclass('float-end')]" position="after">
<div class="alert alert-warning text-center" role="alert" style="margin-top:4rem;" t-if="website_sale_order.validity_date and website_sale_order.validity_date &lt; datetime.datetime.now().date()">
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.
</div>
</xpath>
</template>
</odoo>

0 comments on commit d59518c

Please sign in to comment.