From 1dceb70f3bf281f44cc746263a9a00a0fb6de2d8 Mon Sep 17 00:00:00 2001 From: Rifakat Date: Thu, 13 Jun 2013 15:13:30 +0530 Subject: [PATCH 01/66] [FIX] account: if tax is , total base is applied only on the main tax and does not carry the child tax amount into base, it is compulsory to add child tax amount to tax base becuase the next tax i.e. VAT is applied on total tax base amount --- addons/account/account.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index c2e75e889f0..418a4f7b161 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2088,12 +2088,15 @@ class account_tax(osv.osv): data['balance'] = cur_price_unit amount2 = data.get('amount', 0.0) + amount3 = 0.0 if tax.child_ids: if tax.child_depend: latest = res.pop() amount = amount2 child_tax = self._unit_compute(cr, uid, tax.child_ids, amount, product, partner, quantity) res.extend(child_tax) + for child in child_tax: + amount3 += child.get('amount', 0.0) if tax.child_depend: for r in res: for name in ('base','ref_base'): @@ -2109,7 +2112,7 @@ class account_tax(osv.osv): r['amount'] = data['amount'] latest[name+'_code_id'] = False if tax.include_base_amount: - cur_price_unit+=amount2 + cur_price_unit += amount2 + amount3 return res def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None, force_excluded=False): From 8e3a8bb0feaec9e48bb597caaeda1120d346ce94 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 14 May 2014 13:44:14 +0200 Subject: [PATCH 02/66] [FIX] google maps controller should be for POST only --- addons/website_google_map/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_google_map/controllers/main.py b/addons/website_google_map/controllers/main.py index 01a0cc3b85e..9de241a00fd 100644 --- a/addons/website_google_map/controllers/main.py +++ b/addons/website_google_map/controllers/main.py @@ -28,7 +28,7 @@ class google_map(http.Controller): return partner_obj.google_map_json(request.cr, openerp.SUPERUSER_ID, partner_ids, request.context) - @http.route(['/google_map/set_partner_position'], type='http', auth="public", website=True) + @http.route(['/google_map/set_partner_position'], type='http', methods=['POST'], auth="public", website=True) def google_map_set_partner_position(self, *arg, **post): partner_obj = request.registry['res.partner'] From 1ce14dbe6af78956b4f158e0cdc3b49a211ad104 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 14 May 2014 13:58:34 +0200 Subject: [PATCH 03/66] [FIX] survey route that is only accessed with POST verb --- addons/survey/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index 0e708d96f43..2f65d92cd4c 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -234,7 +234,7 @@ class WebsiteSurvey(http.Controller): # AJAX submission of a page @http.route(['/survey/submit/'], - type='http', auth='public', multilang=True, website=True) + type='http', methods=['POST'], auth='public', multilang=True, website=True) def submit(self, survey, **post): _logger.debug('Incoming data: %s', post) page_id = int(post['page_id']) From ce5ba45d45062f444b772deaa3828c7366f6c2fe Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 14 May 2014 15:41:38 +0200 Subject: [PATCH 04/66] [IMP] gamification: avoid fetching function field while we could reuse the cache system of the browse records (avoid memory errors when updating a large number of records) --- addons/gamification/models/goal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py index b4a47a0d07a..904e6fafa36 100644 --- a/addons/gamification/models/goal.py +++ b/addons/gamification/models/goal.py @@ -349,8 +349,8 @@ class gamification_goal(osv.Model): goal = all_goals[goal_id] # check goal target reached - if (goal.definition_condition == 'higher' and value.get('current', goal.current) >= goal.target_goal) \ - or (goal.definition_condition == 'lower' and value.get('current', goal.current) <= goal.target_goal): + if (goal.definition_id.condition == 'higher' and value.get('current', goal.current) >= goal.target_goal) \ + or (goal.definition_id.condition == 'lower' and value.get('current', goal.current) <= goal.target_goal): value['state'] = 'reached' # check goal failure From a20ccfc7d4328642a50bd8eaab297b7f0f809bbe Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 14 May 2014 15:48:51 +0200 Subject: [PATCH 05/66] [FIX] lazy sitemap with generators --- addons/website/controllers/main.py | 23 ++++++++++++++-------- addons/website/views/website_templates.xml | 3 ++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 5068d7d0e74..c064fdcbcd9 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -4,6 +4,7 @@ import contextlib import hashlib import json import logging +import math import os import datetime import re @@ -75,12 +76,14 @@ class Website(openerp.addons.web.controllers.main.Home): @http.route('/sitemap.xml', type='http', auth="public", website=True) def sitemap_xml_index(self): - pages = list(request.website.enumerate_pages()) - if len(pages)<=LOC_PER_SITEMAP: - return self.__sitemap_xml(pages, 0) + count = 0 + for loc in request.website.enumerate_pages(): + count += 1 + if count <= LOC_PER_SITEMAP: + return self.__sitemap_xml(0) # Sitemaps must be split in several smaller files with a sitemap index values = { - 'pages': range(len(pages)/LOC_PER_SITEMAP+1), + 'pages': range(int(math.ceil(float(count) / LOC_PER_SITEMAP))), 'url_root': request.httprequest.url_root } headers = { @@ -90,12 +93,16 @@ class Website(openerp.addons.web.controllers.main.Home): @http.route('/sitemap-.xml', type='http', auth="public", website=True) def sitemap_xml(self, page): - pages = list(request.website.enumerate_pages()) - return self.__sitemap_xml(pages, page) + return self.__sitemap_xml(page) - def __sitemap_xml(self, pages, index=0): + def __sitemap_xml(self, index=0): + locs = request.website.enumerate_pages() + feed = index * LOC_PER_SITEMAP + for i in xrange(feed): + locs.next() values = { - 'pages': pages[index*LOC_PER_SITEMAP:(index+1)*LOC_PER_SITEMAP], + 'locs': locs, + 'iter': xrange(LOC_PER_SITEMAP), 'url_root': request.httprequest.url_root.rstrip('/') } headers = { diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index b9f33ef1c6b..d79dcbcd32a 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -699,7 +699,8 @@ Sitemap: sitemap.xml