From 06f96e4deaa787e68edfa8fef0c3569802b6e9c3 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 3 Dec 2013 14:33:45 +0100 Subject: [PATCH 01/30] [FIX] website_sale: user going to /shop/payment/validate/ without pass by mycart and add to cart bzr revid: chm@openerp.com-20131203133345-0e7k3ab87u1d3we7 --- addons/website_sale/controllers/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index f160a25cfe1..d44dab901ea 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -675,6 +675,8 @@ class Ecommerce(http.Controller): if transaction_id is None: tx = context.get('website_sale_transaction') + if not tx: + return request.redirect('/shop/') else: tx = request.registry['payment.transaction'].browse(cr, uid, transaction_id, context=context) From 0d79c96ad69badf4585764b566795c8bc570645c Mon Sep 17 00:00:00 2001 From: ddm Date: Tue, 3 Dec 2013 14:40:11 +0100 Subject: [PATCH 02/30] [FIX] Various tour fixes (based on usertests) bzr revid: ddm@openerp.com-20131203134011-caw3x51smrk72fkw --- .../static/src/js/website.tour.banner.js | 2 +- addons/website/static/src/js/website.tour.js | 43 ++++++++++++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index 41c12f7a592..3253bcc957c 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -103,7 +103,7 @@ }, { stepId: 'activate-text-block-title', - element: '#wrap [data-snippet-id=three-columns] .text-center[data-snippet-id=colmd]', + element: '#wrap [data-snippet-id=three-columns]:first .text-center[data-snippet-id=colmd]', placement: 'top', title: "Edit an Area", content: "Select any area of the page to modify it. Click on this subtitle.", diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 3d46e51c28d..ff0b9444cc0 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -38,8 +38,23 @@ self.moveToNextStep(); }); }; - } else { - step.onShow = step.triggers; + } else if (step.triggers) { + step.onShow = (function () { + var executed = false; + return function () { + if (!executed) { + step.triggers(); + executed = true; + } + }; + }()); + } else if (step.reflex) { + step.onShow = function () { + $(step.element).one('click', function () { + self.moveToNextStep(); + }); + }; + delete step.reflex; } return step; })); @@ -77,6 +92,7 @@ this.stop(); } else if (index >= 0) { var self = this; + self.tourStorage.setItem(step.id+'_current_step', index); setTimeout(function () { $('.popover.tour').remove(); self.tour.goto(index); @@ -84,17 +100,18 @@ } }, moveToNextStep: function () { - this.moveToStep(this.currentStepIndex() + 1); + var nextStepIndex = this.currentStepIndex() + 1; + this.moveToStep(nextStepIndex); }, stop: function () { this.tour.end(); }, redirect: function (url) { url = url || new website.UrlParser(window.location.href); - if (this.startPath && url.pathname !== this.startPath) { - var newUrl = this.startPath + (url.search ? (url.search + "&") : "?") + this.id + "=true"; - window.location.replace(newUrl); - } + var path = (this.startPath && url.pathname !== this.startPath) ? this.startPath : url.pathname; + var search = url.addToSearch(this.id + "=true"); + var newUrl = path + search; + window.location.replace(newUrl); }, ended: function () { return this.tourStorage.getItem(this.id+'_end') === "yes"; @@ -146,6 +163,18 @@ this.origin = a.origin; this.search = a.search; this.hash = a.hash; + this.addToSearch= function (query) { + var querystring = _.filter(this.search.split('?'), function (str) { + return str; + }); + if (querystring.length > 0) { + var queries = querystring[0].split("&"); + queries.push(query); + return "?" + _.uniq(queries).join("&"); + } else { + return "?"+query; + } + }; }, }); From 9a3eb7963601e019aa02a0e8628984f445a8cebb Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 3 Dec 2013 14:51:56 +0100 Subject: [PATCH 03/30] [FIX] new fa icons for menu bzr revid: fme@openerp.com-20131203135156-vflspcfkitv667wv --- addons/website/static/src/css/editor.css | 5 +++-- addons/website/static/src/css/editor.sass | 4 ++-- addons/website/static/src/xml/website.menu.xml | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index f8034b52c49..c2ac33008ef 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -1,3 +1,4 @@ +@charset "utf-8"; /* ---- CKEditor Minimal Reset ---- */ .navbar.navbar-inverse .cke_chrome { border: none; @@ -150,10 +151,10 @@ div.oe_menu_buttons { right: -8px; } -ul.oe_menu_editor .icon-home { +ul.oe_menu_editor .fa-home { display: none; } -ul.oe_menu_editor > li:first-child > div > span > .icon-home { +ul.oe_menu_editor > li:first-child > div > span > .fa-home { display: block; } ul.oe_menu_editor .oe_menu_placeholder { diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index cb0876d4212..b44b7c6a4e9 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -120,9 +120,9 @@ div.oe_menu_buttons right: -8px ul.oe_menu_editor - .icon-home + .fa-home display: none - > li:first-child > div > span > .icon-home + > li:first-child > div > span > .fa-home display: block .oe_menu_placeholder outline: 1px dashed #4183C4 diff --git a/addons/website/static/src/xml/website.menu.xml b/addons/website/static/src/xml/website.menu.xml index 2276076550a..9277b0d4bc2 100644 --- a/addons/website/static/src/xml/website.menu.xml +++ b/addons/website/static/src/xml/website.menu.xml @@ -2,16 +2,16 @@
  • - + - + -
    @@ -32,11 +32,11 @@
    - right indent for multi-level menus + right indent for multi-level menus
    From 6745bb3fed6efd87e3e51426a5b305b9186b999e Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 3 Dec 2013 15:16:32 +0100 Subject: [PATCH 04/30] [FIX] font-awesome icons migration to v4 bzr revid: fme@openerp.com-20131203141632-ubc35ca7d4l80s7m --- addons/website/views/website_templates.xml | 20 ++++---- .../views/website_blog_templates.xml | 46 +++++++++---------- addons/website_crm/views/website_crm.xml | 4 +- .../views/website_customer.xml | 4 +- .../views/website_customer.xml | 4 +- addons/website_event/views/website_event.xml | 22 ++++----- .../views/website_hr_recruitment.xml | 8 ++-- .../website_project/views/website_project.xml | 2 +- addons/website_sale/views/website_sale.xml | 20 ++++---- 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 6d7ed2cd1f9..05bb3a8d018 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -162,16 +162,16 @@
  • Contact us
    • -
    • -
    • +
    • +

    - - - - - - + + + + + +

    @@ -201,7 +201,7 @@
  • - + Add a language...
  • @@ -528,7 +528,7 @@ Sitemap: sitemap.xml
    Name

    ✆
    -
    +
    diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml index 958f29c770a..15c4508d504 100644 --- a/addons/website_blog/views/website_blog_templates.xml +++ b/addons/website_blog/views/website_blog_templates.xml @@ -55,25 +55,25 @@   - +
    -   - In +   + In  
    -
    +
    No keywords defined!
    - + comment comments @@ -112,8 +112,8 @@

    - - - - - - + + + + + +

    diff --git a/addons/website_crm/views/website_crm.xml b/addons/website_crm/views/website_crm.xml index f97a3c20ea4..ed7d2b8c6a7 100644 --- a/addons/website_crm/views/website_crm.xml +++ b/addons/website_crm/views/website_crm.xml @@ -73,8 +73,8 @@ If you have an emergency, do not hesitate to contact us by phone:

      -
    • :
    • -
    • :
    • +
    • :
    • +
    • :

    diff --git a/addons/website_customer/views/website_customer.xml b/addons/website_customer/views/website_customer.xml index 818d249196c..002039c84bf 100644 --- a/addons/website_customer/views/website_customer.xml +++ b/addons/website_customer/views/website_customer.xml @@ -134,10 +134,10 @@

    - +
    - + diff --git a/addons/website_customer_crm_partner_assign/views/website_customer.xml b/addons/website_customer_crm_partner_assign/views/website_customer.xml index 95de94c1167..0e65885f72c 100644 --- a/addons/website_customer_crm_partner_assign/views/website_customer.xml +++ b/addons/website_customer_crm_partner_assign/views/website_customer.xml @@ -17,10 +17,10 @@

    - +
    - + diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml index 8b60165efaa..ccc929c0f2a 100644 --- a/addons/website_event/views/website_event.xml +++ b/addons/website_event/views/website_event.xml @@ -81,13 +81,13 @@
    - to + to
    - , + ,
    - +
    @@ -228,11 +228,11 @@

    - to + to

    - + ,

    @@ -326,10 +326,10 @@
    diff --git a/addons/website_hr_recruitment/views/website_hr_recruitment.xml b/addons/website_hr_recruitment/views/website_hr_recruitment.xml index 40b40ce1795..08f22e7b17c 100644 --- a/addons/website_hr_recruitment/views/website_hr_recruitment.xml +++ b/addons/website_hr_recruitment/views/website_hr_recruitment.xml @@ -68,14 +68,14 @@
    - + , not published
    - +
    @@ -125,10 +125,10 @@

    - , + ,
    - +
    diff --git a/addons/website_project/views/website_project.xml b/addons/website_project/views/website_project.xml index b968b415e22..88e048c8979 100644 --- a/addons/website_project/views/website_project.xml +++ b/addons/website_project/views/website_project.xml @@ -36,7 +36,7 @@
    -
    +
    Ending Date:
    diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index 32d43f2dafa..e58adb9ab17 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -8,7 +8,7 @@
  • - + My cart @@ -203,7 +203,7 @@ @@ -423,14 +423,14 @@ @@ -463,8 +463,8 @@ - +
    - +
    Subtotal:
    = 0) { var self = this; - self.tourStorage.setItem(step.id+'_current_step', index); setTimeout(function () { $('.popover.tour').remove(); self.tour.goto(index); From c86e61f8d9dcf5101ac5be4b22da2fbf5bc34185 Mon Sep 17 00:00:00 2001 From: ddm Date: Tue, 3 Dec 2013 15:25:35 +0100 Subject: [PATCH 06/30] [FIX] Revert bad code bzr revid: ddm@openerp.com-20131203142535-w026w2fnfxd15aeb --- addons/website/static/src/js/website.tour.banner.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index c3b3936b8d0..75838ada953 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -32,11 +32,7 @@ title: "Edit this page", content: "Every page of your website can be modified through the Edit button.", triggers: function () { - function advance () { - self.moveToNextStep(); - editor.off('tour:editor_bar_loaded', self, advance); - } - editor.on('tour:editor_bar_loaded', self, advance); + editor.on('tour:editor_bar_loaded', self, self.moveToNextStep); }, }, { From 9d9d3f207e7e6089d01f0b7fe26d7fd9cda0ddce Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 3 Dec 2013 12:13:23 +0100 Subject: [PATCH 07/30] [IMP] cancellation of RTE * rename Cancel to Discard for clarity (user test) * add intermediate dialog in case of mis-click, use 'danger' button style to clearly indicate this is a destructive operation bzr revid: xmo@openerp.com-20131203111323-9mx7aazfpsybe718 --- .../website/static/src/js/website.editor.js | 15 ++++++++++- .../website/static/src/xml/website.editor.xml | 26 ++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index b5caac71d74..5128a3028ce 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -555,7 +555,20 @@ }); }, cancel: function () { - website.reload(); + new $.Deferred(function (d) { + var $dialog = $(openerp.qweb.render('website.editor.discard')).appendTo(document.body); + $dialog.on('click', '.btn-danger', function () { + d.resolve(); + }).on('hidden.bs.modal', function () { + d.reject(); + }); + d.always(function () { + $dialog.remove(); + }); + $dialog.modal('show'); + }).then(function () { + website.reload(); + }) }, new_page: function (ev) { ev.preventDefault(); diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml index 8f749374485..8c1adf1ee27 100644 --- a/addons/website/static/src/xml/website.editor.xml +++ b/addons/website/static/src/xml/website.editor.xml @@ -6,7 +6,7 @@ + class="btn">Discard @@ -170,4 +170,28 @@ + + + + From 16417844c7b16fcbc8946b11603d8e4236d04cae Mon Sep 17 00:00:00 2001 From: ddm Date: Tue, 3 Dec 2013 16:41:42 +0100 Subject: [PATCH 08/30] [FIX] Event track sponsor access rights bzr revid: ddm@openerp.com-20131203154142-ug8hcillq0cb18vb --- addons/website_event_track/security/ir.model.access.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/website_event_track/security/ir.model.access.csv b/addons/website_event_track/security/ir.model.access.csv index 3be605cb252..bfb53b8f1fd 100644 --- a/addons/website_event_track/security/ir.model.access.csv +++ b/addons/website_event_track/security/ir.model.access.csv @@ -9,3 +9,5 @@ access_event_track_tag_public,event.track.tag public,model_event_track_tag,,1,0, access_event_track_tag_manager,event.track.tag manager,model_event_track_tag,event.group_event_user,1,1,1,1 access_event_track_location_public,event.track.location public,model_event_track_location,,1,0,0,0 access_event_track_location_manager,event.track.location manager,model_event_track_location,event.group_event_user,1,1,1,1 +access_event_track_sponsor_type_public,event.track.sponsor.type.public,model_event_sponsor_type,base.group_public,1,0,0,0 +access_event_track_sponsor_public,event.track.sponsor.public,model_event_sponsor,base.group_public,1,0,0,0 From bc4a7c81bc8e1f81fc8adc324572c41975babbee Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 3 Dec 2013 16:44:22 +0100 Subject: [PATCH 09/30] [FIX] website_sale: fixes for access right with public user, and access to shopping cart, checkout... without passed by shop index, change url add_cart bzr revid: chm@openerp.com-20131203154422-cwc12og1bgw9j9a8 --- addons/website_sale/controllers/main.py | 76 ++++++++++++------- addons/website_sale/models/website_sale.py | 3 +- .../static/src/js/website_sale.js | 13 ++-- addons/website_sale/views/website_sale.xml | 15 ++-- 4 files changed, 64 insertions(+), 43 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index d44dab901ea..d8819d3bb89 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -288,26 +288,33 @@ class Ecommerce(http.Controller): request.context = dict(request.context, pricelist=self.get_pricelist()) - quantity = 0 + # set order_line_id and product_id + if order_line_id: + order_line = order_line_obj.browse(request.cr, SUPERUSER_ID, order_line_id, context=request.context) + if order_line.order_id.id == order.id: + product_id = order_line.product_id.id + else: + order_line_id = None + else: + order_line_ids = order_line_obj.search(request.cr, SUPERUSER_ID, + [('order_id', '=', order.id),('product_id', '=', product_id)], context=request.context) + if order_line_ids: + order_line_id = order_line_ids[0] + + if not order_line_id and not product_id: + return 0 # values initialisation + quantity = 0 values = {} - - domain = [('order_id', '=', order.id)] if order_line_id: - domain += [('id', '=', order_line_id)] - else: - domain += [('product_id', '=', product_id)] - - order_line_ids = order_line_obj.search(request.cr, SUPERUSER_ID, domain, context=request.context) - if order_line_ids: - order_line = order_line_obj.read(request.cr, SUPERUSER_ID, order_line_ids, [], context=request.context)[0] + order_line_val = order_line_obj.read(request.cr, SUPERUSER_ID, [order_line_id], [], context=request.context)[0] if not product_id: - product_id = order_line['product_id'][0] + product_id = order_line_val['product_id'][0] if set_number >= 0: quantity = set_number else: - quantity = order_line['product_uom_qty'] + number + quantity = order_line_val['product_uom_qty'] + number if quantity < 0: quantity = 0 else: @@ -316,17 +323,17 @@ class Ecommerce(http.Controller): quantity = 1 # change and record value - vals = order_line_obj._recalculate_product_values(request.cr, request.uid, order_line_ids, product_id, context=request.context) + vals = order_line_obj._recalculate_product_values(request.cr, request.uid, [order_line_id], product_id, context=request.context) values.update(vals) values['product_uom_qty'] = quantity values['product_id'] = product_id values['order_id'] = order.id - if order_line_ids: - order_line_obj.write(request.cr, SUPERUSER_ID, order_line_ids, values, context=request.context) + if order_line_id: + order_line_obj.write(request.cr, SUPERUSER_ID, [order_line_id], values, context=request.context) if not quantity: - order_line_obj.unlink(request.cr, SUPERUSER_ID, order_line_ids, context=request.context) + order_line_obj.unlink(request.cr, SUPERUSER_ID, [order_line_id], context=request.context) else: order_line_id = order_line_obj.create(request.cr, SUPERUSER_ID, values, context=request.context) order_obj.write(request.cr, SUPERUSER_ID, [order.id], {'order_line': [(4, order_line_id)]}, context=request.context) @@ -338,7 +345,7 @@ class Ecommerce(http.Controller): prod_obj = request.registry.get('product.product') # must have a draft sale order with lines at this point, otherwise reset - order = context.get('website_sale_order') + order = request.registry['website'].get_current_order(request.cr, request.uid, context=request.context) if order and order.state != 'draft': request.registry['website'].sale_reset_order(cr, uid, context=context) return request.redirect('/shop/') @@ -367,9 +374,14 @@ class Ecommerce(http.Controller): } return request.website.render("website_sale.mycart", values) - @website.route(['/shop/add_cart/'], type='http', auth="public", multilang=True) - def add_cart(self, product_id=None, order_line_id=None, remove=None, **kw): - self.add_product_to_cart(product_id=product_id and int(product_id), order_line_id=order_line_id and int(order_line_id), number=(remove and -1 or 1)) + @website.route(['/shop/add_cart/', '/shop/add_cart//'], type='http', auth="public", multilang=True, methods=['POST']) + def add_cart(self, product=None, product_id=None, remove=None, **kw): + self.add_product_to_cart(product_id=int(product_id or product.id)) + return request.redirect("/shop/mycart/") + + @website.route(['/shop/change_cart//'], type='http', auth="public", multilang=True) + def add_cart_order_line(self, order_line=None, remove=None, **kw): + self.add_product_to_cart(order_line_id=int(order_line.id), number=(remove and -1 or 1)) return request.redirect("/shop/mycart/") @website.route(['/shop/add_cart_json/'], type='json', auth="public") @@ -390,7 +402,7 @@ class Ecommerce(http.Controller): cr, uid, context, registry = request.cr, request.uid, request.context, request.registry # must have a draft sale order with lines at this point, otherwise reset - order = context.get('website_sale_order') + order = request.registry['website'].get_current_order(request.cr, request.uid, context=request.context) if not order or order.state != 'draft' or not order.order_line: request.registry['website'].sale_reset_order(cr, uid, context=context) return request.redirect('/shop/') @@ -421,14 +433,20 @@ class Ecommerce(http.Controller): checkout = values['checkout'] error = values['error'] - if not request.uid == request.registry['website'].get_public_user(cr, uid, context): + partner = None + public_id = request.registry['website'].get_public_user(cr, uid, context) + if not request.uid == public_id: partner = orm_user.browse(cr, uid, uid, context).partner_id + elif order.partner_id and order.partner_id.id != public_id: + partner = orm_partner.browse(cr, SUPERUSER_ID, order.partner_id.id, context) + + if partner: partner_info = info.from_partner(partner) checkout.update(partner_info) - shipping_ids = orm_partner.search(cr, uid, [("parent_id", "=", partner.id), ('type', "=", 'delivery')], context=context) + shipping_ids = orm_partner.search(cr, SUPERUSER_ID, [("parent_id", "=", partner.id), ('type', "=", 'delivery')], context=context) if shipping_ids: values['shipping'] = "true" - shipping_partner = orm_partner.browse(cr, uid, shipping_ids[0], context) + shipping_partner = orm_partner.browse(cr, SUPERUSER_ID, shipping_ids[0], context) checkout['shipping_name'] = getattr(shipping_partner, 'name') checkout['shipping_phone'] = getattr(shipping_partner, 'phone') checkout['shipping_street'] = getattr(shipping_partner, 'street') @@ -446,6 +464,7 @@ class Ecommerce(http.Controller): @website.route(['/shop/confirm_order/'], type='http', auth="public", multilang=True) def confirm_order(self, **post): cr, uid, context, registry = request.cr, request.uid, request.context, request.registry + order_line_obj = request.registry.get('sale.order') # must have a draft sale order with lines at this point, otherwise redirect to shop order = request.registry['website'].get_current_order(request.cr, request.uid, context=request.context) @@ -470,7 +489,7 @@ class Ecommerce(http.Controller): values = { 'countries': countries, 'states': states, - 'checkout': info.empty(), + 'checkout': info.from_partner( ), 'shipping': post.get("shipping_different"), 'error': {}, } @@ -534,7 +553,8 @@ class Ecommerce(http.Controller): 'partner_shipping_id': shipping_id or partner_id } order_info.update(registry.get('sale.order').onchange_partner_id(cr, SUPERUSER_ID, [], order.partner_id.id, context=context)['value']) - order.write(order_info) + + order_line_obj.write(cr, SUPERUSER_ID, [order.id], order_info, context=context) return request.redirect("/shop/payment/") @@ -553,7 +573,7 @@ class Ecommerce(http.Controller): payment_obj = request.registry.get('payment.acquirer') # if no sale order at this stage: back to checkout beginning - order = context.get('website_sale_order') + order = request.registry['website'].get_current_order(request.cr, request.uid, context=request.context) if not order or not order.state == 'draft' or not order.order_line: request.registry['website'].sale_reset_order(cr, uid, context=context) return request.redirect("/shop/") @@ -681,7 +701,7 @@ class Ecommerce(http.Controller): tx = request.registry['payment.transaction'].browse(cr, uid, transaction_id, context=context) if sale_order_id is None: - order = context.get('website_sale_order') + order = request.registry['website'].get_current_order(request.cr, request.uid, context=request.context) else: order = request.registry['sale.order'].browse(cr, uid, sale_order_id, context=context) diff --git a/addons/website_sale/models/website_sale.py b/addons/website_sale/models/website_sale.py index 8d5404810aa..a2b087b4d7a 100644 --- a/addons/website_sale/models/website_sale.py +++ b/addons/website_sale/models/website_sale.py @@ -41,8 +41,7 @@ class sale_order_line(osv.Model): if context is None: context = {} user_obj = self.pool.get('res.users') - product_id = product_id and int(product_id) or \ - ids and self.browse(cr, uid, ids[0], context=context).product_id.id + product_id = product_id or ids and self.browse(cr, uid, ids[0], context=context).product_id.id return self.product_id_change( cr, SUPERUSER_ID, ids, diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 856c8bd1aa6..20357dd6973 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -45,12 +45,13 @@ $(document).ready(function () { $('.oe_website_sale a.js_add_cart_json').on('click', function (ev) { ev.preventDefault(); var $link = $(ev.currentTarget); - var product = $link.attr("href").match(/product_id=([0-9]+)/); - var product_id = product ? +product[1] : 0; - if (!product) { - var line = $link.attr("href").match(/order_line_id=([0-9]+)/); - order_line_id = line ? +line[1] : 0; - } + var href = $link.attr("href"); + + var add_cart = href.match(/add_cart\/([0-9]+)/); + var product_id = add_cart && +add_cart[1] || false; + + var change_cart = href.match(/change_cart\/([0-9]+)/); + var order_line_id = change_cart && +change_cart[1] || false; openerp.jsonRpc("/shop/add_cart_json/", 'call', { 'product_id': product_id, 'order_line_id': order_line_id, diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index e58adb9ab17..b3fc9862f69 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -202,7 +202,7 @@