From f90dd77fffcac056532a80ba1bee3cecbb8afe18 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 18 Nov 2014 11:18:14 +0100 Subject: [PATCH 1/3] [FIX] doc: double period in footer --- doc/_themes/odoodoc/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/_themes/odoodoc/layout.html b/doc/_themes/odoodoc/layout.html index 1a68d31814a..5235137eddd 100644 --- a/doc/_themes/odoodoc/layout.html +++ b/doc/_themes/odoodoc/layout.html @@ -87,7 +87,7 @@ {%- if show_copyright %}
  • {%- if hasdoc('copyright') %} - {% trans path=pathto('copyright'), copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %} + {% trans path=pathto('copyright'), copyright=copyright|e %}© Copyright {{ copyright }}{% endtrans %} {%- else %} {% trans copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %} {%- endif %} From f0c024a6f751e9f369e82d022b4ba32bc76c8ec6 Mon Sep 17 00:00:00 2001 From: Tymoteusz Motylewski Date: Tue, 18 Nov 2014 10:45:25 +0100 Subject: [PATCH 2/3] [FIX] doc: incorrect class access in new api guide When creating a class with the new API, we should use models.Model instead of just Model. closes #3713 --- doc/reference/orm.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/reference/orm.rst b/doc/reference/orm.rst index cfc465078b1..474f0eee895 100644 --- a/doc/reference/orm.rst +++ b/doc/reference/orm.rst @@ -18,7 +18,7 @@ set of records of the same model. Methods defined on a model are executed on a recordset, and their ``self`` is a recordset:: - class AModel(Model): + class AModel(models.Model): _name = 'a.model' def a_method(self): # self can be anywhere between 0 records and all records in the @@ -279,7 +279,7 @@ Creating Models Model fields are defined as attributes on the model itself:: from openerp import models, fields - class AModel(Model): + class AModel(models.Model): _name = 'a.model.name' field1 = fields.Char() From fc329b6eeb5652487c67e7b558fccaf46c3dad43 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 18 Nov 2014 11:25:31 +0100 Subject: [PATCH 3/3] [FIX] website_forum: use common method to compute tags for orm --- addons/website_forum/controllers/main.py | 26 ++++-------------------- addons/website_forum/models/forum.py | 19 +++++++++++++++++ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index d074c2e6c96..95e604aeda4 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -223,12 +223,7 @@ class WebsiteForum(http.Controller): else: question_tag_ids.append((0, 0, {'name': tag, 'forum_id': forum.id})) elif tag_version == "select2": - tags = filter(None, post.get('question_tags', '').split(',')) - for tag in tags: - if tag.startswith('_'): # it's a new tag - question_tag_ids.append((0, 0, {'name': tag[1:], 'forum_id': forum.id})) - else: - question_tag_ids.append((4, int(tag))) + question_tag_ids = forum._tag_to_write_vals(cr, uid, post.get('question_tags', ''), context=context) new_question_id = request.registry['forum.post'].create( request.cr, request.uid, { @@ -404,7 +399,6 @@ class WebsiteForum(http.Controller): def post_save(self, forum, post, **kwargs): cr, uid, context = request.cr, request.uid, request.context question_tags = [] - User = request.registry['res.users'] Tag = request.registry['forum.tag'] tag_version = kwargs.get('tag_type', 'texttext') if tag_version == "texttext": # old version - retro v8 - #TODO Remove in master @@ -417,24 +411,12 @@ class WebsiteForum(http.Controller): else: new_tag = Tag.create(cr, uid, {'name': tag, 'forum_id': forum.id}, context=context) question_tags.append(new_tag) + tags_val = [(6, 0, question_tags)] elif tag_version == "select2": # new version - for tag in filter(None, kwargs.get('question_tag', '').split(',')): - if tag.startswith('_'): # it's a new tag - # check if user have Karma needed to create need tag - user = User.browse(cr, SUPERUSER_ID, uid, context=context) - if user.exists() and user.karma >= forum.karma_retag: - # check that not arleady created meanwhile and maybe excluded by the limit on the search - tag_ids = Tag.search(cr, uid, [('name', '=', tag[1:])], context=context) - if tag_ids: - new_tag = tag_ids - else: - new_tag = Tag.create(cr, uid, {'name': tag[1:], 'forum_id': forum.id}, context=context) - question_tags.append(new_tag) - else: - question_tags += [int(tag)] + tags_val = forum._tag_to_write_vals(cr, uid, kwargs.get('question_tag', ''), context=context) vals = { - 'tag_ids': [(6, 0, question_tags)], + 'tag_ids': tags_val, 'name': kwargs.get('question_name'), 'content': kwargs.get('content'), } diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 4c36d68ef29..e58b1f6600f 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -119,6 +119,25 @@ class Forum(osv.Model): create_context = dict(context, mail_create_nolog=True) return super(Forum, self).create(cr, uid, values, context=create_context) + def _tag_to_write_vals(self, cr, uid, tags='', context=None): + User = self.pool['res.users'] + Tag = self.pool['forum.tag'] + post_tags = [] + for tag in filter(None, tags.split(',')): + if tag.startswith('_'): # it's a new tag + # check that not arleady created meanwhile or maybe excluded by the limit on the search + tag_ids = Tag.search(cr, uid, [('name', '=', tag[1:])], context=context) + if tag_ids: + post_tags.append((4, int(tag_ids[0]))) + else: + # check if user have Karma needed to create need tag + user = User.browse(cr, uid, uid, context=context) + if user.exists() and user.karma >= self.karma_retag: + post_tags.append((0, 0, {'name': tag[1:], 'forum_id': self.id})) + else: + post_tags.append((4, int(tag))) + return post_tags + class Post(osv.Model): _name = 'forum.post'