Browse Source

Ajout du controle pour passer au paiement

12.0
Juliana 3 years ago
parent
commit
38a8b015a6
  1. 2
      __manifest__.py
  2. BIN
      controllers/__pycache__/main.cpython-37.pyc
  3. 39
      controllers/main.py
  4. BIN
      models/__pycache__/__init__.cpython-37.pyc
  5. BIN
      models/__pycache__/res_config_settings.cpython-37.pyc
  6. BIN
      models/__pycache__/website.cpython-37.pyc
  7. 10
      models/product.py
  8. 17
      views/product_views.xml
  9. 20
      views/template.xml

2
__manifest__.py

@ -1,7 +1,7 @@
{
"name": "VRACOOP - Website Cart Limit",
"summary": "VRACOOP - Website Cart Limit",
"version": "12.0.1.0.1",
"version": "12.0.1.0.0",
"development_status": "Beta",
"author": "Le Filament",
"maintainers": ["remi-filament"],

BIN
controllers/__pycache__/main.cpython-37.pyc

39
controllers/main.py

@ -1,8 +1,8 @@
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import http
from odoo.http import request
from odoo import http, _
from odoo.addons.website_sale.controllers.main import WebsiteSale
from odoo.addons.website_coupon.controllers.main import WebsiteCoupon
@ -22,34 +22,9 @@ class WebsiteCoupon(WebsiteCoupon):
class WebsiteSale(WebsiteSale):
@http.route(['/shop/cart/update_json'], type='json', auth="public", methods=['POST'], website=True, csrf=False)
def cart_update_json(self, product_id, line_id=None, add_qty=None, set_qty=None, display=True):
res = super(WebsiteSale, self).cart_update_json(product_id, line_id, add_qty, set_qty, display)
return res
@http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True, csrf=False)
def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
res = super(WebsiteSale, self).cart_update(product_id, add_qty, set_qty, **kw)
return res
# """This route is called when adding a product to cart (no options)."""
# sale_order = request.website.sale_get_order(force_create=True)
# if sale_order.state != 'draft':
# request.session['sale_order_id'] = None
# sale_order = request.website.sale_get_order(force_create=True)
#
# product_custom_attribute_values = None
# if kw.get('product_custom_attribute_values'):
# product_custom_attribute_values = json.loads(kw.get('product_custom_attribute_values'))
#
# no_variant_attribute_values = None
# if kw.get('no_variant_attribute_values'):
# no_variant_attribute_values = json.loads(kw.get('no_variant_attribute_values'))
#
# sale_order._cart_update(
# product_id=int(product_id),
# add_qty=add_qty,
# set_qty=set_qty,
# product_custom_attribute_values=product_custom_attribute_values,
# no_variant_attribute_values=no_variant_attribute_values
# )
# return request.redirect("/shop/cart")
@http.route(['/shop/checkout'], type='http', auth="public", website=True, sitemap=False)
def checkout(self, **post):
order = request.website.sale_get_order()
if order.amount_total <= request.website.amount_limit:
return request.redirect('/shop/cart')
return super(WebsiteSale, self).checkout(**post)

BIN
models/__pycache__/__init__.cpython-37.pyc

BIN
models/__pycache__/res_config_settings.cpython-37.pyc

BIN
models/__pycache__/website.cpython-37.pyc

10
models/product.py

@ -1,10 +0,0 @@
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class ProductTempleate(models.Model):
_inherit = "product.template"
is_coupon = fields.Boolean('Est une artilce type coupon')

17
views/product_views.xml

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="product_template_form_view">
<field name="name">product.template.product.coupon.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="website_sale.product_template_form_view"/>
<field name="arch" type="xml">
<div name="options" position="inside">
<div>
<field name="is_coupon"/>
</div>
</div>
</field>
</record>
</odoo>

20
views/template.xml

@ -2,18 +2,6 @@
<odoo>
<template id="cart" inherit_id="website_sale.cart">
<xpath expr="//a[hasclass('btn', 'btn-primary', 'float-right', 'd-none', 'd-xl-inline-block')]" position="replace">
<a role="button" t-if="website_sale_order and website_sale_order.website_order_line and not no_pass_payment" class="btn btn-primary float-right d-none d-xl-inline-block" href="/shop/checkout?express=1">
<span class="">Process Checkout</span>
<span class="fa fa-chevron-right" />
</a>
</xpath>
<xpath expr="//a[hasclass('btn', 'btn-primary', 'float-right')]" position="replace">
<a role="button" t-if="website_sale_order and website_sale_order.website_order_line and not no_pass_payment" class="btn btn-primary float-right" href="/shop/checkout?express=1">
<span class="">Process Checkout</span>
<span class="fa fa-chevron-right" />
</a>
</xpath>
<xpath expr="//div[hasclass('mt8', 'mb8', 'alert', 'alert-info')]" position="before">
<div t-if="no_pass_payment" class="alert alert-danger" role="alert">
@ -24,12 +12,4 @@
</xpath>
</template>
<template id="short_cart_summary" inherit_id="website_sale.short_cart_summary">
<xpath expr="//a[hasclass('btn', 'btn-secondary', 'float-right', 'd-none', 'd-xl-inline-block')]" position="replace">
<a role="button" t-if="website_sale_order and website_sale_order.website_order_line and not no_pass_payment" class="btn btn-secondary float-right d-none d-xl-inline-block" href="/shop/checkout?express=1">
<span>Process Checkout</span>
</a>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save