diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-12-06 17:24:37 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-12-06 17:24:37 +0100 |
| commit | aec8e2582fff3c60bce67be9dc9124f12f28f528 (patch) | |
| tree | 1abae13fdecbaab33cc3a38602b052cca72d4666 /addons/website/controllers/main.py | |
| parent | 3fc879e3eb16e896bf9e0f50cefa6c911c0abd68 (diff) | |
| parent | 345755e27194c5cd19ce5e6079b0a1dc7cb6e2bd (diff) | |
[MERGE] forward port branch saas-11 up to 345755e
Diffstat (limited to 'addons/website/controllers/main.py')
| -rw-r--r-- | addons/website/controllers/main.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 3a64816a248..fa7b1b12b1f 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -137,6 +137,7 @@ class Website(Home): @http.route('/sitemap.xml', type='http', auth="public", website=True) def sitemap_xml_index(self): + current_website = request.website Attachment = request.env['ir.attachment'].sudo() View = request.env['ir.ui.view'].sudo() mimetype = 'application/xml;charset=utf-8' @@ -150,8 +151,8 @@ class Website(Home): 'name': url, 'url': url, }) - - sitemap = Attachment.search([('url', '=', '/sitemap.xml'), ('type', '=', 'binary')], limit=1) + dom = [('url', '=' , '/sitemap-%d.xml' % current_website.id), ('type', '=', 'binary')] + sitemap = Attachment.search(dom, limit=1) if sitemap: # Check if stored version is still valid create_date = fields.Datetime.from_string(sitemap.create_date) @@ -161,7 +162,9 @@ class Website(Home): if not content: # Remove all sitemaps in ir.attachments as we're going to regenerated them - sitemaps = Attachment.search([('url', '=like', '/sitemap%.xml'), ('type', '=', 'binary')]) + dom = [('type', '=', 'binary'), '|', ('url', '=like' , '/sitemap-%d-%%.xml' % current_website.id), + ('url', '=' , '/sitemap-%d.xml' % current_website.id)] + sitemaps = Attachment.search(dom) sitemaps.unlink() pages = 0 @@ -175,16 +178,17 @@ class Website(Home): if urls.strip(): content = View.render_template('website.sitemap_xml', {'content': urls}) pages += 1 - last_sitemap = create_sitemap('/sitemap-%d.xml' % pages, content) + last_sitemap = create_sitemap('/sitemap-%d-%d.xml' % (current_website.id, pages), content) else: break if not pages: return request.not_found() elif pages == 1: + # rename the -id-page.xml => -id.xml last_sitemap.write({ - 'url': "/sitemap.xml", - 'name': "/sitemap.xml" + 'url': "/sitemap-%d.xml" % current_website.id, + 'name': "/sitemap-%d.xml" % current_website.id, }) else: # Sitemaps must be split in several smaller files with a sitemap index @@ -192,7 +196,7 @@ class Website(Home): 'pages': range(1, pages + 1), 'url_root': request.httprequest.url_root, }) - create_sitemap('/sitemap.xml', content) + create_sitemap('/sitemap-%d.xml' % current_website.id, content) return request.make_response(content, [('Content-Type', mimetype)]) |
