Juliana
5 years ago
13 changed files with 432 additions and 287 deletions
-
5__manifest__.py
-
19controllers/main.py
-
144controllers/main2.py
-
14datas/vracoop.time.csv
-
3models/__init__.py
-
10models/delivery.py
-
1models/sale_order.py
-
213models/vracoop_point_retrait.py
-
37static/src/js/vracoop_retrait.js
-
18static/src/scss/style.css
-
15views/delivery_views.xml
-
2views/vracoop_retrait_views.xml
-
238views/vracoop_templates.xml
@ -1,144 +0,0 @@ |
|||
# © 2019 Le Filament (<http://www.le-filament.com>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import fields, http, tools, _ |
|||
from odoo.http import request |
|||
from odoo.addons.website_sale.controllers.main import WebsiteSale |
|||
|
|||
|
|||
class VracoopWebsiteSale(WebsiteSale): |
|||
|
|||
@http.route(['/shop/retrait'], type='http', auth="public", website=True) |
|||
def retrait(self, **post): |
|||
points_retrait = request.env['vracoop.point.retrait'].search([]) |
|||
print("--- points_retrait ---", str(points_retrait)) |
|||
order = request.website.sale_get_order() |
|||
# redirection = self.checkout_redirection(order) |
|||
# if redirection: |
|||
# return redirection |
|||
render_values = { |
|||
'points_retrait': points_retrait, |
|||
} |
|||
# render_values = self._get_shop_payment_values(order, **post) |
|||
# render_values['only_services'] = order and order.only_services or False |
|||
|
|||
# if render_values['errors']: |
|||
# render_values.pop('acquirers', '') |
|||
# render_values.pop('tokens', '') |
|||
|
|||
return request.render("vracoop_click_and_collect.vracoop_retrait", render_values) |
|||
|
|||
@http.route(['/shop/checkout'], type='http', auth="public", website=True) |
|||
def checkout(self, **post): |
|||
res = super(VracoopWebsiteSale, self).checkout(**post) |
|||
order = request.website.sale_get_order() |
|||
|
|||
redirection = self.checkout_redirection(order) |
|||
if redirection: |
|||
return redirection |
|||
|
|||
if order.partner_id.id == request.website.user_id.sudo().partner_id.id: |
|||
return request.redirect('/shop/address') |
|||
|
|||
for f in self._get_mandatory_billing_fields(): |
|||
if not order.partner_id[f]: |
|||
return request.redirect('/shop/address?partner_id=%d' % order.partner_id.id) |
|||
|
|||
values = self.checkout_values(**post) |
|||
|
|||
if post.get('express'): |
|||
return request.redirect('/shop/retrait') |
|||
|
|||
values.update({'website_sale_order': order}) |
|||
|
|||
# Avoid useless rendering if called in ajax |
|||
if post.get('xhr'): |
|||
return 'ok' |
|||
return request.render("website_sale.checkout", values) |
|||
|
|||
|
|||
@http.route(['/shop/address'], type='http', methods=['GET', 'POST'], auth="public", website=True) |
|||
def address(self, **kw): |
|||
res = super(VracoopWebsiteSale, self).address(**kw) |
|||
Partner = request.env['res.partner'].with_context(show_address=1).sudo() |
|||
order = request.website.sale_get_order() |
|||
|
|||
redirection = self.checkout_redirection(order) |
|||
if redirection: |
|||
return redirection |
|||
|
|||
mode = (False, False) |
|||
can_edit_vat = False |
|||
def_country_id = order.partner_id.country_id |
|||
values, errors = {}, {} |
|||
|
|||
partner_id = int(kw.get('partner_id', -1)) |
|||
|
|||
# IF PUBLIC ORDER |
|||
if order.partner_id.id == request.website.user_id.sudo().partner_id.id: |
|||
mode = ('new', 'billing') |
|||
can_edit_vat = True |
|||
country_code = request.session['geoip'].get('country_code') |
|||
if country_code: |
|||
def_country_id = request.env['res.country'].search([('code', '=', country_code)], limit=1) |
|||
else: |
|||
def_country_id = request.website.user_id.sudo().country_id |
|||
# IF ORDER LINKED TO A PARTNER |
|||
else: |
|||
if partner_id > 0: |
|||
if partner_id == order.partner_id.id: |
|||
mode = ('edit', 'billing') |
|||
can_edit_vat = order.partner_id.can_edit_vat() |
|||
else: |
|||
shippings = Partner.search([('id', 'child_of', order.partner_id.commercial_partner_id.ids)]) |
|||
if partner_id in shippings.mapped('id'): |
|||
mode = ('edit', 'shipping') |
|||
else: |
|||
return Forbidden() |
|||
if mode: |
|||
values = Partner.browse(partner_id) |
|||
elif partner_id == -1: |
|||
mode = ('new', 'shipping') |
|||
else: # no mode - refresh without post? |
|||
return request.redirect('/shop/checkout') |
|||
|
|||
# IF POSTED |
|||
if 'submitted' in kw: |
|||
pre_values = self.values_preprocess(order, mode, kw) |
|||
errors, error_msg = self.checkout_form_validate(mode, kw, pre_values) |
|||
post, errors, error_msg = self.values_postprocess(order, mode, pre_values, errors, error_msg) |
|||
|
|||
if errors: |
|||
errors['error_message'] = error_msg |
|||
values = kw |
|||
else: |
|||
partner_id = self._checkout_form_save(mode, post, kw) |
|||
if mode[1] == 'billing': |
|||
order.partner_id = partner_id |
|||
order.onchange_partner_id() |
|||
if not kw.get('use_same'): |
|||
kw['callback'] = kw.get('callback') or \ |
|||
(not order.only_services and (mode[0] == 'edit' and '/shop/checkout' or '/shop/address')) |
|||
elif mode[1] == 'shipping': |
|||
order.partner_shipping_id = partner_id |
|||
|
|||
order.message_partner_ids = [(4, partner_id), (3, request.website.partner_id.id)] |
|||
if not errors: |
|||
return request.redirect(kw.get('callback') or '/shop/retrait') |
|||
|
|||
country = 'country_id' in values and values['country_id'] != '' and request.env['res.country'].browse(int(values['country_id'])) |
|||
country = country and country.exists() or def_country_id |
|||
render_values = { |
|||
'website_sale_order': order, |
|||
'partner_id': partner_id, |
|||
'mode': mode, |
|||
'checkout': values, |
|||
'can_edit_vat': can_edit_vat, |
|||
'country': country, |
|||
'countries': country.get_website_sale_countries(mode=mode[1]), |
|||
"states": country.get_website_sale_states(mode=mode[1]), |
|||
'error': errors, |
|||
'callback': kw.get('callback'), |
|||
'only_services': order and order.only_services, |
|||
} |
|||
return request.render("website_sale.address", render_values) |
@ -1,8 +1,8 @@ |
|||
id,name,first_noon_heure,first_morning_heure,last_noon_heure,last_morning_heure,availability_time,preparation_time |
|||
__export__.vracoop_time_lundi,Lundi,14.0,9.0,17.0,12.0,3.0,0.30 |
|||
__export__.vracoop_time_mardi,Mardi,14.0,9.0,17.0,12.0,3.0,0.30 |
|||
__export__.vracoop_time_mercredi,Mercredi,14.0,9.0,17.0,12.0,3.0,0.30 |
|||
__export__.vracoop_time_jeudi,Jeudi,14.0,9.0,17.0,12.0,3.0,0.30 |
|||
__export__.vracoop_time_vendredi,Vendredi,14.0,9.0,17.0,12.0,3.0,0.30 |
|||
__export__.vracoop_time_samedi,Samedi,14.0,9.0,17.0,12.0,3.0,0.30 |
|||
__export__.vracoop_time_dimanche,Dimanche,14.0,9.0,17.0,12.0,3.0,0.30 |
|||
__export__.vracoop_time_lundi,Lundi,14.0,9.0,17.0,12.0,2.0,1.0 |
|||
__export__.vracoop_time_mardi,Mardi,14.0,9.0,17.0,12.0,2.0,1.0 |
|||
__export__.vracoop_time_mercredi,Mercredi,14.0,9.0,17.0,12.0,2.0,1.0 |
|||
__export__.vracoop_time_jeudi,Jeudi,14.0,9.0,17.0,12.0,2.0,1.0 |
|||
__export__.vracoop_time_vendredi,Vendredi,14.0,9.0,17.0,12.0,2.0,1.0 |
|||
__export__.vracoop_time_samedi,Samedi,14.0,9.0,17.0,12.0,2.0,1.0 |
|||
__export__.vracoop_time_dimanche,Dimanche,14.0,9.0,17.0,12.0,2.0,1.0 |
@ -0,0 +1,10 @@ |
|||
# © 2019 Le Filament (<http://www.le-filament.com>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import fields, models |
|||
|
|||
|
|||
class VracoopDeliveryCarrier(models.Model): |
|||
_inherit = 'delivery.carrier' |
|||
|
|||
point_retrait = fields.Boolean(string='Point retrait') |
@ -0,0 +1,15 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="vracoop_view_delivery_carrier_form" model="ir.ui.view"> |
|||
<field name="name">vracoop.delivery.carrier.website.form</field> |
|||
<field name="model">delivery.carrier</field> |
|||
<field name="inherit_id" ref="delivery.view_delivery_carrier_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//group//group" position="inside"> |
|||
<field name="point_retrait"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue