From 86b9f997c8fff88c5db50ff033362e240819d09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 23 Jan 2014 17:32:43 +0100 Subject: [PATCH 01/17] [IMP] product: supplier_info: when renaming a field, please use @oldname parameter. Therefore added oldname on product_tmpl_id that was once known as product.id. bzr revid: tde@openerp.com-20140123163243-ct1vde3luoypj5qx --- addons/product/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index 0bd3d43ecea..e62df2ceec5 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -988,7 +988,7 @@ class product_supplierinfo(osv.osv): 'product_uom': fields.related('product_tmpl_id', 'uom_po_id', type='many2one', relation='product.uom', string="Supplier Unit of Measure", readonly="1", help="This comes from the product form."), 'min_qty': fields.float('Minimal Quantity', required=True, help="The minimal quantity to purchase to this supplier, expressed in the supplier Product Unit of Measure if not empty, in the default unit of measure of the product otherwise."), 'qty': fields.function(_calc_qty, store=True, type='float', string='Quantity', multi="qty", help="This is a quantity which is converted into Default Unit of Measure."), - 'product_tmpl_id' : fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade', select=True), + 'product_tmpl_id' : fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade', select=True, oldname='product_id'), 'delay' : fields.integer('Delivery Lead Time', required=True, help="Lead time in days between the confirmation of the purchase order and the reception of the products in your warehouse. Used by the scheduler for automatic computation of the purchase order planning."), 'pricelist_ids': fields.one2many('pricelist.partnerinfo', 'suppinfo_id', 'Supplier Pricelist'), 'company_id':fields.many2one('res.company','Company',select=1), From c08b9a7b036675205d9f0ac3a2497ca5725fff18 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 23 Jan 2014 17:37:46 +0100 Subject: [PATCH 02/17] [FIX] event_sale: improve usage of get_object() bzr revid: rco@openerp.com-20140123163746-9p5zz3ntn6908tfi --- addons/event_sale/event_sale.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/event_sale/event_sale.py b/addons/event_sale/event_sale.py index aa02d26e4b2..ba8250b0978 100644 --- a/addons/event_sale/event_sale.py +++ b/addons/event_sale/event_sale.py @@ -117,16 +117,16 @@ class event_event(osv.osv): return result def _get_tickets(self, cr, uid, context={}): - md = self.pool.get('ir.model.data') + imd = self.pool.get('ir.model.data') try: - dummy, res_id = md.get_object_reference(cr, uid, 'event_sale', 'product_product_event') + product = imd.get_object(cr, uid, 'event_sale', 'product_product_event') except ValueError: return [] return [{ - 'name': _('Subscription'), - 'product_id': res_id, - 'price': 0, - }] + 'name': _('Subscription'), + 'product_id': product.id, + 'price': 0, + }] _columns = { 'event_ticket_ids': fields.one2many('event.event.ticket', "event_id", "Event Ticket"), @@ -196,13 +196,14 @@ class event_ticket(osv.osv): 'register_prospect': fields.function(_get_register, string='Unconfirmed Registrations', type='integer', multi='register_numbers'), 'register_attended': fields.function(_get_register, string='# of Participations', type='integer', multi='register_numbers'), } + def _default_product_id(self, cr, uid, context={}): - md = self.pool.get('ir.model.data') + imd = self.pool.get('ir.model.data') try: - dummy, res_id = md.get_object_reference(cr, uid, 'event_sale', 'product_product_event') + product = imd.get_object(cr, uid, 'event_sale', 'product_product_event') except ValueError: return False - return res_id + return product.id _defaults = { 'product_id': _default_product_id From eb0a81dc93e645025132bbf0d2ca90ea0fc40c52 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 23 Jan 2014 18:23:02 +0100 Subject: [PATCH 03/17] [IMP] delivery: _delivery_unset make only one call to unlink. [IMP] delivery: do not browse grid as superuser. [IMP] delivery: code clean: remove unused import, remove commented code, use osv.Model instead of deprecated osv.osv class bzr revid: chs@openerp.com-20140123172302-ran1vpfibeixv9xe --- addons/delivery/sale.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/addons/delivery/sale.py b/addons/delivery/sale.py index 146b517f7b3..57c12dfbb0e 100644 --- a/addons/delivery/sale.py +++ b/addons/delivery/sale.py @@ -22,13 +22,11 @@ import time from openerp.addons import decimal_precision -from openerp.addons.sale.sale import sale_order as OriginalSaleOrder from openerp.osv import fields, osv from openerp.tools.translate import _ -from openerp import SUPERUSER_ID -class sale_order_line(osv.osv): +class sale_order_line(osv.Model): _inherit = 'sale.order.line' _columns = { @@ -92,9 +90,9 @@ class sale_order(osv.Model): return result def _delivery_unset(self, cr, uid, order, context=None): - for line in order.order_line: - if line.is_delivery: - self.pool.get('sale.order.line').unlink(cr, uid, [line.id], context=context) + line_ids = [line.id for line in order.order_line if line.is_delivery] + self.pool['sale.order.line'].unlink(cr, uid, line_ids, context=context) + order.refresh() return True def delivery_set(self, cr, uid, ids, context=None): @@ -102,17 +100,17 @@ class sale_order(osv.Model): grid_obj = self.pool.get('delivery.grid') carrier_obj = self.pool.get('delivery.carrier') acc_fp_obj = self.pool.get('account.fiscal.position') + for order in self.browse(cr, uid, ids, context=context): self._delivery_unset(cr, uid, order, context=context) - for order in self.browse(cr, uid, ids, context=context): grid_id = carrier_obj.grid_get(cr, uid, [order.carrier_id.id], order.partner_shipping_id.id) if not grid_id: raise osv.except_osv(_('No Grid Available!'), _('No grid matching for this carrier!')) - if not order.state in ('draft'): + if order.state != 'draft': raise osv.except_osv(_('Order not in Draft State!'), _('The order state have to be draft to add delivery lines.')) - grid = grid_obj.browse(cr, SUPERUSER_ID, grid_id, context=context) + grid = grid_obj.browse(cr, uid, grid_id, context=context) taxes = grid.carrier_id.product_id.taxes_id fpos = order.fiscal_position or False @@ -129,6 +127,3 @@ class sale_order(osv.Model): 'type': 'make_to_stock', 'is_delivery': True }) - # remove the value of the carrier_id field on the sale order - # TDE NOTE: why removing it ?? seems weird - # return self.write(cr, uid, ids, {'carrier_id': False}, context=context) From 8c8b20bc661cb1d2df7a26a32f16930be8f1f86f Mon Sep 17 00:00:00 2001 From: "ddm@openerp.com" <> Date: Thu, 23 Jan 2014 18:24:55 +0100 Subject: [PATCH 04/17] [IMP] add link to payment acquirers in website settings bzr revid: ddm@openerp.com-20140123172455-7prrhpxfakgg0zv4 --- addons/website_payment/__openerp__.py | 1 + .../views/website_settings_payment.xml | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 addons/website_payment/views/website_settings_payment.xml diff --git a/addons/website_payment/__openerp__.py b/addons/website_payment/__openerp__.py index ab214ae4cd7..54e3cd35de6 100644 --- a/addons/website_payment/__openerp__.py +++ b/addons/website_payment/__openerp__.py @@ -13,6 +13,7 @@ ], 'data': [ 'views/website_payment_templates.xml', + 'views/website_settings_payment.xml', ], 'auto_install': False, } diff --git a/addons/website_payment/views/website_settings_payment.xml b/addons/website_payment/views/website_settings_payment.xml new file mode 100644 index 00000000000..688cdd1f610 --- /dev/null +++ b/addons/website_payment/views/website_settings_payment.xml @@ -0,0 +1,22 @@ + + + + + website.form + website + + + +
+ + +
+
+
+
+
+
From 0aba10073e6cfff312f1fba07b55fad3410a8470 Mon Sep 17 00:00:00 2001 From: "ddm@openerp.com" <> Date: Thu, 23 Jan 2014 18:25:43 +0100 Subject: [PATCH 05/17] [IMP] add 'Website Settings' to customize menu bzr revid: ddm@openerp.com-20140123172543-3k7w0221ssjsserr --- addons/website/static/src/js/website.editor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 7cd3a4be67b..eaa64de085d 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -423,6 +423,7 @@ menu.append('
  • HTML Editor
  • '); menu.append('
  • Change Theme
  • '); menu.append('
  • Install Apps
  • '); + menu.append('
  • Website Settings
  • '); self.trigger('rte:customize_menu_ready'); } ); From e42d639c872f24af4f0e332a34dc974749091b16 Mon Sep 17 00:00:00 2001 From: "ddm@openerp.com" <> Date: Thu, 23 Jan 2014 18:27:14 +0100 Subject: [PATCH 06/17] [FIX] indentation bzr revid: ddm@openerp.com-20140123172714-0fumk1t7hjoz1506 --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index eaa64de085d..fcc7dbb6294 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -420,7 +420,7 @@ }); // Adding Static Menus menu.append('
  • '); - menu.append('
  • HTML Editor
  • '); + menu.append('
  • HTML Editor
  • '); menu.append('
  • Change Theme
  • '); menu.append('
  • Install Apps
  • '); menu.append('
  • Website Settings
  • '); From 2090330b67f276bd5dede7b138cd9664d59ba7a7 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 23 Jan 2014 18:42:08 +0100 Subject: [PATCH 07/17] [FIX] move function field `amount_delivery` from delivery module to website_sale_delivery module bzr revid: chs@openerp.com-20140123174208-yzlod98ez4xn72lv --- addons/delivery/sale.py | 31 ------------------- .../models/sale_order.py | 29 +++++++++++++++++ 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/addons/delivery/sale.py b/addons/delivery/sale.py index 57c12dfbb0e..dbebd01ef1e 100644 --- a/addons/delivery/sale.py +++ b/addons/delivery/sale.py @@ -20,8 +20,6 @@ ############################################################################## import time - -from openerp.addons import decimal_precision from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -40,39 +38,10 @@ class sale_order_line(osv.Model): class sale_order(osv.Model): _inherit = 'sale.order' - - def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None): - """ Wrapper because of direct method passing as parameter for function fields """ - return self._amount_all(cr, uid, ids, field_name, arg, context=context) - - def _amount_all(self, cr, uid, ids, field_name, arg, context=None): - res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context=context) - Currency = self.pool.get('res.currency') - for order in self.browse(cr, uid, ids, context=context): - line_amount = sum([line.price_subtotal for line in order.order_line if line.is_delivery]) - currency = order.pricelist_id.currency_id - res[order.id]['amount_delivery'] = Currency.round(cr, uid, currency, line_amount) - return res - - def _get_order(self, cr, uid, ids, context=None): - result = {} - for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): - result[line.order_id.id] = True - return result.keys() - _columns = { 'carrier_id': fields.many2one( "delivery.carrier", string="Delivery Method", help="Complete this field if you plan to invoice the shipping based on picking."), - 'amount_delivery': fields.function( - _amount_all_wrapper, type='float', digits_compute=decimal_precision.get_precision('Account'), - string='Delivery Amount', - store={ - 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), - 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10), - }, - multi='sums', help="The amount without tax.", track_visibility='always' - ), } def onchange_partner_id(self, cr, uid, ids, part, context=None): diff --git a/addons/website_sale_delivery/models/sale_order.py b/addons/website_sale_delivery/models/sale_order.py index 0a663654c30..0313c586770 100644 --- a/addons/website_sale_delivery/models/sale_order.py +++ b/addons/website_sale_delivery/models/sale_order.py @@ -2,6 +2,7 @@ from openerp.osv import orm, fields from openerp import SUPERUSER_ID +from openerp.addons import decimal_precision class delivery_carrier(orm.Model): @@ -18,7 +19,35 @@ class delivery_carrier(orm.Model): class SaleOrder(orm.Model): _inherit = 'sale.order' + def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None): + """ Wrapper because of direct method passing as parameter for function fields """ + return self._amount_all(cr, uid, ids, field_name, arg, context=context) + + def _amount_all(self, cr, uid, ids, field_name, arg, context=None): + res = super(SaleOrder, self)._amount_all(cr, uid, ids, field_name, arg, context=context) + Currency = self.pool.get('res.currency') + for order in self.browse(cr, uid, ids, context=context): + line_amount = sum([line.price_subtotal for line in order.order_line if line.is_delivery]) + currency = order.pricelist_id.currency_id + res[order.id]['amount_delivery'] = Currency.round(cr, uid, currency, line_amount) + return res + + def _get_order(self, cr, uid, ids, context=None): + result = {} + for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): + result[line.order_id.id] = True + return result.keys() + _columns = { + 'amount_delivery': fields.function( + _amount_all_wrapper, type='float', digits_compute=decimal_precision.get_precision('Account'), + string='Delivery Amount', + store={ + 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), + 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10), + }, + multi='sums', help="The amount without tax.", track_visibility='always' + ), 'website_order_line': fields.one2many( 'sale.order.line', 'order_id', string='Order Lines displayed on Website', readonly=True, From a7e920aee27472234ba72652a9356959f89824fb Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 23 Jan 2014 18:50:54 +0100 Subject: [PATCH 08/17] [FIX] edi: only catch ValueError when getting record from xmlid bzr revid: chs@openerp.com-20140123175054-r2zq9elx23t6p0cv --- addons/edi/models/res_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/edi/models/res_partner.py b/addons/edi/models/res_partner.py index 3c3ca45949f..057e84b5541 100644 --- a/addons/edi/models/res_partner.py +++ b/addons/edi/models/res_partner.py @@ -55,7 +55,7 @@ class res_partner(osv.osv, EDIMixin): res_partner_bank_type = self.pool.get('res.partner.bank.type') try: return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'bank_normal', context=context).code - except: + except ValueError: pass # second option: create a new custom type for EDI or use it if already created, as IBAN type is # not always appropriate: we need a free-form bank type for max flexibility (users can correct From 2cf97c76d39c8c15820ca1486c3c2fea48107eaa Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 23 Jan 2014 19:32:08 +0100 Subject: [PATCH 09/17] [IMP] product: correct copy() of products variants bzr revid: chs@openerp.com-20140123183208-jg76zjt7tzd1fl75 --- addons/product/product.py | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index e62df2ceec5..b6493eb512e 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -854,36 +854,29 @@ class product_product(osv.osv): def copy(self, cr, uid, id, default=None, context=None): if context is None: - context={} + context = {} if not default: default = {} # Craft our own ` (copy)` in en_US (self.copy_translation() # will do the other languages). - context_wo_lang = context.copy() + context_wo_lang = dict(context) context_wo_lang.pop('lang', None) - product = self.read(cr, uid, id, ['name', 'list_price', 'standard_price', 'categ_id', 'variants', 'product_tmpl_id'], context=context_wo_lang) - default = default.copy() - if product['variants']: - default.update(variants=_("%s (copy)") % (product['variants']), product_tmpl_id=product['product_tmpl_id'][0]) - else: - default.update(name=_("%s (copy)") % (product['name']), list_price=product['list_price'], standard_price=product['standard_price'], categ_id=product['categ_id'][0], product_tmpl_id=None) + product = self.read(cr, uid, id, ['name', 'variants', 'product_tmpl_id'], context=context_wo_lang) + default = dict(default) + if product['variants'] or context.get('variant'): + # if we copy a variant or create one, we keep the same template + name = default.pop('name', None) + variant = product['variants'] or name or product['name'] + default.update({ + 'variants': _("%s (copy)") % (variant,), + 'product_tmpl_id': product['product_tmpl_id'][0], + }) + elif 'name' not in default: + default['name'] = _("%s (copy)") % (product['name'],) - if context.get('variant',False): - fields = ['product_tmpl_id', 'active', 'variants', 'default_code', - 'price_margin', 'price_extra'] - data = self.read(cr, uid, id, fields=fields, context=context) - for f in fields: - if f in default: - data[f] = default[f] - data['product_tmpl_id'] = data.get('product_tmpl_id', False) \ - and data['product_tmpl_id'][0] - del data['id'] - return self.create(cr, uid, data) - else: - return super(product_product, self).copy(cr, uid, id, default=default, - context=context) + return super(product_product, self).copy(cr, uid, id, default=default, context=context) def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if context is None: From f45e0198a5a25527235f27ac5000b94c752650f3 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 23 Jan 2014 19:35:48 +0100 Subject: [PATCH 10/17] [FIX] website: tour bzr revid: chm@openerp.com-20140123183548-3s842ye1whbvmrq0 --- addons/website/static/src/js/website.tour.js | 119 +++++++++++------- .../static/src/js/website.tour.event.js | 9 +- 2 files changed, 76 insertions(+), 52 deletions(-) diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 35cc77474f6..5453c68c866 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -47,24 +47,6 @@ } localStorage.setItem("website-reloads", JSON.stringify(stack)); }; - } else if (step.trigger.url) { - step.triggers = function (callback) { - var stack = JSON.parse(localStorage.getItem("website-geturls")) || []; - var id = step.trigger.url.toString(); - var index = stack.indexOf(id); - if (index !== -1) { - var url = new website.UrlParser(window.location.href); - var test = typeof step.trigger.url === "string" ? - step.trigger.url == url.pathname+url.search : - step.trigger.url.test(url.pathname+url.search); - if (!test) return; - stack.splice(index,1); - (callback || self.moveToNextStep).apply(self); - } else { - stack.push(id); - } - localStorage.setItem("website-geturls", JSON.stringify(stack)); - }; } else if (step.trigger === 'drag') { step.triggers = function (callback) { self.onSnippetDragged(callback || self.moveToNextStep); @@ -86,8 +68,27 @@ }); }; } - } else if (step.trigger.modal) { + } else if (step.trigger.url) { step.triggers = function (callback) { + var stack = JSON.parse(localStorage.getItem("website-geturls")) || []; + var id = step.trigger.url.toString(); + var index = stack.indexOf(id); + if (index !== -1) { + var url = new website.UrlParser(window.location.href); + var test = typeof step.trigger.url === "string" ? + step.trigger.url == url.pathname+url.search : + step.trigger.url.test(url.pathname+url.search); + if (!test) return; + stack.splice(index,1); + (callback || self.moveToNextStep).apply(self); + } else { + stack.push(id); + } + localStorage.setItem("website-geturls", JSON.stringify(stack)); + return index !== -1; + }; + } else if (step.trigger.modal) { + step.triggers = function (callback, auto) { var $doc = $(document); function onStop () { if (step.trigger.modal.stopOnClose) { @@ -98,7 +99,10 @@ $doc.one('shown.bs.modal', function () { $('.modal button.btn-primary').one('click', function () { $doc.off('hide.bs.modal', onStop); - (callback || self.moveToNextStep).apply(self, [step.trigger.modal.afterSubmit]); + console.log(callback); + if (!callback) { + self.moveToStep(step.trigger.modal.afterSubmit); + } }); (callback || self.moveToNextStep).apply(self); }); @@ -199,16 +203,19 @@ }, onSnippetDragged: function (callback) { var self = this; - function beginDrag () { + var selector = '#website-top-navbar [data-snippet-id].ui-draggable'; + var beginDrag = function beginDrag () { $('.popover.tour').remove(); - function advance () { + var advance = function advance () { if (_.isFunction(callback)) { callback.apply(self); } - } + $(selector).off('mouseup', advance); + }; $(document.body).one('mouseup', advance); - } - $('#website-top-navbar [data-snippet-id].ui-draggable').one('mousedown', beginDrag); + $(selector).off('mousedown', beginDrag); + }; + $(selector).one('mousedown', beginDrag); }, onSnippetDraggedAdvance: function () { onSnippetDragged(self.moveToNextStep); @@ -280,7 +287,7 @@ function actualDragAndDrop ($thumbnail) { var thumbnailPosition = $thumbnail.position(); $thumbnail.trigger($.Event("mousedown", { which: 1, pageX: thumbnailPosition.left, pageY: thumbnailPosition.top })); - $thumbnail.trigger($.Event("mousemove", { which: 1, pageX: thumbnailPosition.left, pageY: thumbnailPosition.top+500 })); + $thumbnail.trigger($.Event("mousemove", { which: 1, pageX: document.body.scrollWidth/2, pageY: document.body.scrollHeight/2 })); var $dropZone = $(".oe_drop_zone").first(); var dropPosition = $dropZone.position(); $dropZone.trigger($.Event("mouseup", { which: 1, pageX: dropPosition.left, pageY: dropPosition.top })); @@ -327,7 +334,8 @@ var self = this; var testId = 'test_'+tour.id+'_tour'; this.tours.push(tour); - var defaultDelay = 1000; //ms + var defaultDelay = 250; //ms + var defaultDelayReload = 1500; //ms var overlapsCrash; var test = { id: tour.id, @@ -346,50 +354,67 @@ test.reset(); throw message; } - function executeStep (step) { - // check if they are a cycle + function initReport () { + // set last time for report + if (!window.localStorage.getItem("test-last-time")) { + window.localStorage.setItem("test-last-time", new Date().getTime()); + } + } + function setReport (step) { + var report = JSON.parse(window.localStorage.getItem("test-report")) || {}; + report[step.stepId] = (new Date().getTime() - window.localStorage.getItem("test-last-time")) + " ms"; + window.localStorage.setItem("test-report", JSON.stringify(report)); + } + function testCycling (step) { var lastStep = window.localStorage.getItem(testId); var tryStep = lastStep != step.stepId ? 0 : (+(window.localStorage.getItem("test-last-"+testId) || 0) + 1); window.localStorage.setItem("test-last-"+testId, tryStep); if (tryStep > 2) { throwError("Test: '" + testId + "' cycling step: '" + step.stepId + "'"); } + return tryStep; + } + function getDelay (step) { + return step.delay || + ((step.trigger === 'reload' || (step.trigger && step.trigger.url)) + ? defaultDelayReload + : defaultDelay); + } + function executeStep (step) { + if (testCycling(step) === 0) initReport(); + + var delay = getDelay (step); + + overlapsCrash = setTimeout(function () { + throwError("Test: '" + testId + "' can't resolve step: '" + step.stepId + "'"); + }, delay + 1000); - // set last time for report - if (tryStep == 0 || !window.localStorage.getItem("test-last-time")) { - window.localStorage.setItem("test-last-time", new Date().getTime()); - } var _next = false; window.localStorage.setItem(testId, step.stepId); function next () { _next = true; + clearTimeout(overlapsCrash); - // set report - var report = JSON.parse(window.localStorage.getItem("test-report")) || {}; - report[step.stepId] = (new Date().getTime() - window.localStorage.getItem("test-last-time")) + " ms"; - window.localStorage.setItem("test-report", JSON.stringify(report)); + setReport(step); var nextStep = actionSteps.shift(); + if (nextStep) { setTimeout(function () { executeStep(nextStep); - }, step.delay || defaultDelay); + }, delay); } else { - clearTimeout(overlapsCrash); window.localStorage.removeItem(testId); } } - setTimeout(function () { - clearTimeout(overlapsCrash); - overlapsCrash = setTimeout(function () { - throwError("Test: '" + testId + "' can't resolve step: '" + step.stepId + "'"); - }, (step.delay || defaultDelay) + 1000); + setTimeout(function () { var $element = $(step.element); - if (step.triggers) { + var flag = step.triggers && (!step.trigger || !step.trigger.modal); + if (flag) { try { - step.triggers(next); + step.triggers(next, true); } catch (e) { throwError(e); } @@ -414,7 +439,7 @@ $element.trigger($.Event("mouseup", { srcElement: $element })); } } - if (!step.triggers) next(); + if (!flag) next(); },0); } var url = new website.UrlParser(window.location.href); diff --git a/addons/website_event/static/src/js/website.tour.event.js b/addons/website_event/static/src/js/website.tour.event.js index 39f5a997024..7f3c62c88e2 100644 --- a/addons/website_event/static/src/js/website.tour.event.js +++ b/addons/website_event/static/src/js/website.tour.event.js @@ -43,7 +43,7 @@ modal: { stopOnClose: true, afterSubmit: 'event-page', - } + }, }, }, { @@ -60,8 +60,8 @@ placement: 'right', title: "Create Event", content: "Click Continue to create the event.", - trigger: { - url: /event\/[0-9]+\/register/ + trigger: { + url: /event\/[0-9]+\/register/ }, }, { @@ -148,11 +148,10 @@ title: "Publish your event", content: "Click to publish your event.", trigger: 'click', - delay: 5000, }, { stepId: 'customize-event', - element: '.js_publish_management button#dopprod-8', + element: '.js_publish_management button[data-toggle="dropdown"]', placement: 'left', title: "Customize your event", content: "Click here to customize your event further.", From 8c5dda24801d5b95a6dc42ff30ded6fd699aba8c Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 24 Jan 2014 10:28:53 +0100 Subject: [PATCH 11/17] [FIX] website css: rev/fix: Page under construction css; Add a choice 'non' for background snippet bzr revid: chm@openerp.com-20140124092853-taal585yz4v7fh20 --- addons/website/static/src/css/website.css | 19 +++++++++++++++---- addons/website/static/src/css/website.sass | 20 +++++++++++++++----- addons/website/views/snippets.xml | 1 + 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/addons/website/static/src/css/website.css b/addons/website/static/src/css/website.css index ba04fed56f0..da599752679 100644 --- a/addons/website/static/src/css/website.css +++ b/addons/website/static/src/css/website.css @@ -1,3 +1,4 @@ +@charset "utf-8"; /* THIS CSS FILE IS FOR WEBSITE THEMING CUSTOMIZATION ONLY * * css for editor buttons, openerp widget included in the website and other @@ -162,19 +163,29 @@ footer { background-image: url("/website/static/src/img/drag_here.png"); } +.oe_structure.oe_empty:empty, [data-oe-type=html]:empty, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child { + background-image: none; + background-repeat: no-repeat; + background-position: center; + height: 220px !important; +} + .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child { position: static; } -.oe_structure.oe_editable.oe_empty:empty:before, .oe_editable[data-oe-type=html]:empty:before, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before { - content: "Drag Building Blocks Here"; -} - .oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before { content: " "; + text-align: center; display: block; padding-top: 160px; padding-bottom: 30px; + color: grey; + font-size: 24px; +} + +.oe_structure.oe_editable.oe_empty:empty:before, .oe_editable[data-oe-type=html]:empty:before, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before { + content: "Drag Building Blocks Here"; } .css_editable_display { diff --git a/addons/website/static/src/css/website.sass b/addons/website/static/src/css/website.sass index fe85e5bdd4c..fe3bc6fde56 100644 --- a/addons/website/static/src/css/website.sass +++ b/addons/website/static/src/css/website.sass @@ -122,17 +122,27 @@ footer .oe_structure.oe_editable.oe_empty:empty, .oe_editable[data-oe-type=html]:empty, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child background-image: url('/website/static/src/img/drag_here.png') +.oe_structure.oe_empty:empty, [data-oe-type=html]:empty, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child + background-image: none /*url('/website/static/src/img/under_construction.png')*/ + background-repeat: no-repeat + background-position: center + height: 220px !important + .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child position: static +.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before + content: ' ' + text-align: center + display: block + padding-top: 160px + padding-bottom: 30px + color: grey + font-size: 24px + .oe_structure.oe_editable.oe_empty:empty:before, .oe_editable[data-oe-type=html]:empty:before, .oe_structure.oe_editable.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before content: 'Drag Building Blocks Here' -.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before - content: ' ' - display: block - padding-top: 160px - padding-bottom: 30px .css_editable_display display: none diff --git a/addons/website/views/snippets.xml b/addons/website/views/snippets.xml index bc8abd9bb66..d788f2ecb68 100644 --- a/addons/website/views/snippets.xml +++ b/addons/website/views/snippets.xml @@ -942,6 +942,7 @@
  • Quote
  • +
  • None
  • Choose an image...
  • From 41210f45df94340143082782a8bb43227ce3224e Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 24 Jan 2014 10:34:21 +0100 Subject: [PATCH 12/17] [FIX] website snippet: When you click on the drag and drop arrow of a block without actually dragging, you shouldn't go to the top of the page. bzr revid: chm@openerp.com-20140124093421-o1rhe3p44ewwek9u --- addons/website/static/src/js/website.snippets.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 7bf540f9c16..8a3e7a4421d 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -375,7 +375,7 @@ }); }, stop: function(ev, ui){ - if (action === 'insert' && ! dropped && $('.oe_drop_zone')) { + if (action === 'insert' && ! dropped && $('.oe_drop_zone') && ui.position.top > 50) { var el = $('.oe_drop_zone').nearest({x: ui.position.left, y: ui.position.top}).first(); if (el.length) { el.after($toInsert); From 8a5844d1912a17d872595d4d8d5dae6236e8882c Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 24 Jan 2014 10:42:41 +0100 Subject: [PATCH 13/17] [IMP] website_sale: hide test tour from help menu bzr revid: chm@openerp.com-20140124094241-z1pf5895w2f2sfrh --- addons/website_sale/static/src/js/website.tour.shop.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/static/src/js/website.tour.shop.js b/addons/website_sale/static/src/js/website.tour.shop.js index f6b64342c58..c7540563d93 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -6,8 +6,9 @@ website.EditorBar.include({ start: function () { this.registerTour(new website.EditorShopTour(this)); + var res = this._super(); this.registerTour(new website.EditorShopTest(this)); - return this._super(); + return res; }, }); From 15c1d052e32bf3778531a5c9859e719cf71a2b54 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Fri, 24 Jan 2014 11:46:10 +0100 Subject: [PATCH 14/17] [IMP] Ensure slug validity otherwise redirect bzr revid: fme@openerp.com-20140124104610-lzsomdyl10ens0av --- addons/website/models/ir_http.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index 79db7aa4628..a4c4d5e3dab 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import logging +import re import traceback import werkzeug @@ -13,6 +14,10 @@ from openerp.osv import orm logger = logging.getLogger(__name__) +class RequestUID(object): + def __init__(self, **kw): + self.__dict__.update(kw) + class ir_http(orm.AbstractModel): _inherit = 'ir.http' @@ -79,6 +84,22 @@ class ir_http(orm.AbstractModel): return self._dispatch() + def _postprocess_args(self, arguments): + url = request.httprequest.url + for arg in arguments.itervalues(): + if isinstance(arg, orm.browse_record) and isinstance(arg._uid, RequestUID): + placeholder = arg._uid + arg._uid = request.uid + try: + good_slug = slug(arg) + if str(arg.id) != placeholder.value and placeholder.value != good_slug: + # TODO: properly recompose the url instead of using replace() + url = url.replace(placeholder.value, good_slug) + except KeyError: + return self._handle_exception(werkzeug.exceptions.NotFound()) + if url != request.httprequest.url: + werkzeug.exceptions.abort(werkzeug.utils.redirect(url)) + def _handle_exception(self, exception=None, code=500): if isinstance(exception, werkzeug.exceptions.HTTPException) and exception.response: return exception.response @@ -131,6 +152,12 @@ class ModelConverter(ir.ir_http.ModelConverter): def to_url(self, value): return slug(value) + def to_python(self, value): + m = re.match(self.regex, value) + _uid = RequestUID(value=value, match=m, converter=self) + return request.registry[self.model].browse( + request.cr, _uid, int(m.group(1)), context=request.context) + def generate(self, cr, uid, query=None, context=None): return request.registry[self.model].name_search( cr, uid, name=query or '', context=context) From cc978e14900958eb3e79acf58705bf884736868a Mon Sep 17 00:00:00 2001 From: "ddm@openerp.com" <> Date: Fri, 24 Jan 2014 12:05:52 +0100 Subject: [PATCH 15/17] [FIX] event tour edit bzr revid: ddm@openerp.com-20140124110552-ai7bfobl72n97bz1 --- addons/website_event/static/src/js/website.tour.event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_event/static/src/js/website.tour.event.js b/addons/website_event/static/src/js/website.tour.event.js index 7f3c62c88e2..cbfbda93170 100644 --- a/addons/website_event/static/src/js/website.tour.event.js +++ b/addons/website_event/static/src/js/website.tour.event.js @@ -159,7 +159,7 @@ }, { stepId: 'edit-event-backend', - element: '.js_publish_management ul>li>a', + element: '.js_publish_management ul>li>a:last', placement: 'left', title: "Customize your event", content: "Click here to edit your event in the backend.", From 33eeff44487603a0b5aca73b96be16d8b5e33b72 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 24 Jan 2014 12:42:24 +0100 Subject: [PATCH 16/17] [IMP] website_crm, website_sale: add a Website sale team and new lead and order to this sale team [FIX] website_sale: remove auto assignation to administrator from website lead and order bzr revid: chm@openerp.com-20140124114224-w80wd2ea0bx20ldk --- addons/website_crm/controllers/main.py | 18 ++++++++++++++++-- addons/website_crm/data/website_crm_data.xml | 8 ++++++++ addons/website_sale/controllers/main.py | 3 +-- addons/website_sale/data/website_sale_data.xml | 7 +++++++ addons/website_sale/models/website.py | 8 ++++++++ .../static/src/js/website_sale_payment.js | 2 +- 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/addons/website_crm/controllers/main.py b/addons/website_crm/controllers/main.py index 65b38d3b09f..738db6e4ba9 100644 --- a/addons/website_crm/controllers/main.py +++ b/addons/website_crm/controllers/main.py @@ -16,9 +16,16 @@ class contactus(http.Controller): return url @http.route(['/crm/contactus'], type='http', auth="public", website=True, multilang=True) - def contactus(self, *arg, **post): + def contactus(self, description=None, partner_name=None, phone=None, contact_name=None, email_from=None, name=None): + post = {} + post['description'] = description + post['partner_name'] = partner_name + post['phone'] = phone + post['contact_name'] = contact_name + post['email_from'] = email_from + post['name'] = name + required_fields = ['contact_name', 'email_from', 'description'] - post['user_id'] = False error = set() values = dict((key, post.get(key)) for key in post) values['error'] = error @@ -34,6 +41,13 @@ class contactus(http.Controller): if not post.get('name'): post['name'] = post.get('contact_name') + section_ids = request.registry["crm.case.section"].search( + request.cr, SUPERUSER_ID, [("code", "=", "Website")], context=request.context) + if section_ids: + post['section_id'] = section_ids[0] + + post['user_id'] = False + request.registry['crm.lead'].create(request.cr, SUPERUSER_ID, post, request.context) company = request.website.company_id values = { diff --git a/addons/website_crm/data/website_crm_data.xml b/addons/website_crm/data/website_crm_data.xml index b35813cdabf..22fdbd607b6 100644 --- a/addons/website_crm/data/website_crm_data.xml +++ b/addons/website_crm/data/website_crm_data.xml @@ -12,5 +12,13 @@ open + + Website + Website + True + Website + + + diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 32a9a91c620..4a2c0f95bf5 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -517,9 +517,8 @@ class Ecommerce(http.Controller): 'partner_invoice_id': partner_id, 'partner_shipping_id': shipping_id or partner_id } - print order_info order_info.update(registry.get('sale.order').onchange_partner_id(cr, SUPERUSER_ID, [], partner_id, context=context)['value']) - print order_info + order_info.pop('user_id') order_line_obj.write(cr, SUPERUSER_ID, [order.id], order_info, context=context) diff --git a/addons/website_sale/data/website_sale_data.xml b/addons/website_sale/data/website_sale_data.xml index fcb62312275..d54b25fad0b 100644 --- a/addons/website_sale/data/website_sale_data.xml +++ b/addons/website_sale/data/website_sale_data.xml @@ -32,5 +32,12 @@ oe_image_full + + Website + Website + Website + + + diff --git a/addons/website_sale/models/website.py b/addons/website_sale/models/website.py index f52a409d244..6a16a5d9543 100644 --- a/addons/website_sale/models/website.py +++ b/addons/website_sale/models/website.py @@ -145,6 +145,14 @@ class Website(orm.Model): """ Create a new quotation used in the ecommerce (event, sale) """ SaleOrder = self.pool.get('sale.order') quotation_values = self._ecommerce_get_quotation_values(cr, uid, context=context) + + section_ids = request.registry["crm.case.section"].search( + request.cr, SUPERUSER_ID, [("code", "=", "Website")], context=context) + if section_ids: + quotation_values['section_id'] = section_ids[0] + + quotation_values['user_id'] = False + return SaleOrder.create(cr, SUPERUSER_ID, quotation_values, context=context) def ecommerce_get_new_order(self, cr, uid, context=None): diff --git a/addons/website_sale/static/src/js/website_sale_payment.js b/addons/website_sale/static/src/js/website_sale_payment.js index 20461a7c07e..d20f00d0305 100644 --- a/addons/website_sale/static/src/js/website_sale_payment.js +++ b/addons/website_sale/static/src/js/website_sale_payment.js @@ -7,6 +7,6 @@ $(document).ready(function () { $("div.oe_sale_acquirer_button[data-id]", $payment).addClass("hidden"); $("div.oe_sale_acquirer_button[data-id='"+payment_id+"']", $payment).removeClass("hidden"); }) - .find("#payment_method input[name='acquirer']:checked").click(); + .find("input[name='acquirer']:checked").click(); }); From 6f859860e9aa856b62db8b8803708ad1bfd75b7f Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 24 Jan 2014 12:57:23 +0100 Subject: [PATCH 17/17] [FIX] website_sale_delivery: don't raise (for the website customer) if they are no carrier; return true if they aren't need of carrier or if the carrier is good bzr revid: chm@openerp.com-20140124115723-nblyb3qknxym9817 --- addons/website_sale_delivery/models/website.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/website_sale_delivery/models/website.py b/addons/website_sale_delivery/models/website.py index ab3c6e39a6b..8502bc539a1 100644 --- a/addons/website_sale_delivery/models/website.py +++ b/addons/website_sale_delivery/models/website.py @@ -18,7 +18,7 @@ class Website(orm.Model): context=context) order = self.ecommerce_get_current_order(cr, uid, context=context) return self._check_carrier_quotation(cr, uid, order, context=context) and quantity or None - + def _check_carrier_quotation(self, cr, uid, order, context=None): # check to add or remove carrier_id carrier_id = False @@ -30,11 +30,14 @@ class Website(orm.Model): if not carrier_id: order.write({'carrier_id': None}, context=context) self.pool['sale.order']._delivery_unset(cr, SUPERUSER_ID, order, context=context) - return None + return True elif not order.carrier_id: carrier_ids = self.pool.get('delivery.carrier').search(cr, uid, [], context=context) - order.write({'carrier_id': carrier_ids[0]}, context=context) - order.delivery_set(context=context) - return None + carrier_id = carrier_ids and carrier_ids[0] + order.write({'carrier_id': carrier_id}, context=context) + if carrier_id: + order.delivery_set(context=context) + else: + self.pool['sale.order']._delivery_unset(cr, SUPERUSER_ID, order, context=context) - return carrier_id + return bool(carrier_id)