Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][MIG] website_sale_credit_point #1002

Open
wants to merge 5 commits into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/website_sale_credit_point/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
51 changes: 51 additions & 0 deletions website_sale_credit_point/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=========================
website_sale_credit_point
=========================

Integrate `sale_credit_point` within Odoo e-shop.

Sale credit point module allows you to buy things based on fixed credit.
This module integrates the latter with the ecommerce
and prevents users to complete checkout in case credit's amount is not ok.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/e-commerce/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.

Contributors
------------

* Simone Orsi <[email protected]>

Do not contact contributors directly about support or help with technical issues.

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
1 change: 1 addition & 0 deletions website_sale_credit_point/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import controllers
19 changes: 19 additions & 0 deletions website_sale_credit_point/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2017 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Ecommerce Sale Credit Point",
"version": "15.0.1.0.0",
"category": "Sales",
"license": "AGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/e-commerce",
"depends": [
"website_sale",
"sale_credit_point",
],
"data": [
"templates/cart.xml",
"templates/navbar_points.xml",
],
}
1 change: 1 addition & 0 deletions website_sale_credit_point/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import website_sale
22 changes: 22 additions & 0 deletions website_sale_credit_point/controllers/website_sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2016 Camptocamp
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.exceptions import UserError
from odoo.http import request

from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteSale(WebsiteSale):
def checkout_redirection(self, order):
"""Don't process checkout if credit check is not satisfied."""
redirection = super(WebsiteSale, self).checkout_redirection(order)
if redirection:
return redirection
else:
try:
order.credit_point_check()
except UserError as exc:
# error msg if not enought points
request.session["credit_point_limit_error"] = exc.args[0]
return request.redirect("/shop/cart/")
20 changes: 20 additions & 0 deletions website_sale_credit_point/templates/cart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<odoo>
<template id="cart" inherit_id="website_sale.cart">
<xpath
expr="//div[hasclass('oe_website_sale')]/div[hasclass('row')][1]"
position="before"
>
<t
t-set="credit_point_limit_error"
t-value="request.session.pop('credit_point_limit_error', None)"
/>
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger" t-if="credit_point_limit_error">
<t t-esc="credit_point_limit_error" />
</div>
</div>
</div>
</xpath>
</template>
</odoo>
15 changes: 15 additions & 0 deletions website_sale_credit_point/templates/navbar_points.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<odoo>

<template id="navbar_points" inherit_id="website_sale.header_cart_link">
<xpath expr="//li[last()]" position="after">
<li t-if="user_id.partner_id" class="nav-item">
<!-- I use an empty <a> tag here to get the styles, used in top menu -->
<span class="nav-link">Credit balance: <span
t-esc="user_id.partner_id.credit_point"
/></span>
</li>
</xpath>
</template>

</odoo>
Loading