From 18b5cdb61c65f23c715039599c0fae24308283d8 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 16 Mar 2010 18:54:12 +0530 Subject: [PATCH 01/20] [IMP]: crm: Added osv wizard objects in access csv bzr revid: rpa@tinyerp.com-20100316132412-5zlim4qhhmnozyab --- addons/crm/security/ir.model.access.csv | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/crm/security/ir.model.access.csv b/addons/crm/security/ir.model.access.csv index c3888951d4c..a5a82bf62db 100644 --- a/addons/crm/security/ir.model.access.csv +++ b/addons/crm/security/ir.model.access.csv @@ -32,4 +32,11 @@ "access_crm_phonecall_report_user","crm.phonecall.report","model_crm_phonecall_report","crm.group_crm_user",1,0,0,0 "access_crm_opportunity_report_user","crm.opportunity.report","model_crm_opportunity_report","crm.group_crm_user",1,0,0,0 "access_report_crm_case_service_dashboard","report.crm.case.service.dashboard","model_report_crm_case_service_dashboard","crm.group_crm_user",1,0,0,0 - +"access_crm_lead2partner","crm.lead2partner","model_crm_lead2partner","crm.group_crm_user",1,0,0,0 +"access_crm_lead2opportunity","crm.lead2opportunity","model_crm_lead2opportunity","crm.group_crm_user",1,0,0,0 +"access_crm_opportunity2meeting","crm.opportunity2meeting","model_crm_opportunity2meeting","crm.group_crm_user",1,0,0,0 +"access_crm_opportunity2phonecall","crm.opportunity2phonecall","model_crm_opportunity2phonecall","crm.group_crm_user",1,0,0,0 +"access_crm_phonecall2phonecall","crm.phonecall2phonecall","model_crm_phonecall2phonecall","crm.group_crm_user",1,0,0,0 +"access_crm_phonecall2partner","crm.phonecall2partner","model_crm_phonecall2partner","crm.group_crm_user",1,0,0,0 +"access_crm_phonecall2meeting","crm.phonecall2meeting","model_crm_phonecall2meeting","crm.group_crm_user",1,0,0,0 +"access_crm_phonecall2opportunity","crm.phonecall2opportunity","model_crm_phonecall2opportunity","crm.group_crm_user",1,0,0,0 From 7c5449a692442562fde55e2749b4f2911839a8b2 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 16 Mar 2010 19:31:43 +0530 Subject: [PATCH 02/20] [IMP]: wiki: code optimization and apply doc string bzr revid: ksa@tinyerp.co.in-20100316140143-vzcfcealogprk210 --- addons/wiki/wiki.py | 11 +++- addons/wiki/wiki_view.xml | 51 +++++++++++-------- addons/wiki/wizard/wiki_create_menu.py | 11 ++-- addons/wiki/wizard/wiki_create_menu_view.xml | 3 ++ addons/wiki/wizard/wiki_make_index.py | 4 +- addons/wiki/wizard/wiki_make_index_view.xml | 3 ++ addons/wiki/wizard/wiki_wiki_help_open.py | 2 + .../wiki/wizard/wiki_wiki_help_open_view.xml | 3 ++ addons/wiki/wizard/wiki_wiki_page_open.py | 4 +- .../wiki/wizard/wiki_wiki_page_open_view.xml | 3 ++ 10 files changed, 64 insertions(+), 31 deletions(-) diff --git a/addons/wiki/wiki.py b/addons/wiki/wiki.py index db6fcadac92..70511d3e56f 100644 --- a/addons/wiki/wiki.py +++ b/addons/wiki/wiki.py @@ -36,6 +36,7 @@ class Wiki(osv.osv): Wiki() class WikiGroup(osv.osv): + """ Wiki Groups """ _name = "wiki.groups" _description="Wiki Groups" _order = 'name' @@ -54,7 +55,9 @@ class WikiGroup(osv.osv): } WikiGroup() + class GroupLink(osv.osv): + """ Apply Group Link """ _name = "wiki.groups.link" _description="Wiki Groups Links" _rec_name = 'action_id' @@ -64,6 +67,7 @@ class GroupLink(osv.osv): } GroupLink() + class Wiki(osv.osv): _inherit="wiki.wiki" _description="Wiki Page" @@ -86,7 +90,7 @@ class Wiki(osv.osv): 'parent_id':fields.many2one('wiki.wiki', 'Parent Page'), 'child_ids':fields.one2many('wiki.wiki', 'parent_id', 'Child Pages'), } - + def onchange_group_id(self, cr, uid, ids, group_id, content, context={}): if (not group_id) or content: return {} @@ -141,7 +145,9 @@ class Wiki(osv.osv): Wiki() + class History(osv.osv): + """ Wiki History """ _name="wiki.wiki.history" _description="Wiki History" _rec_name="date_time" @@ -157,6 +163,7 @@ class History(osv.osv): _defaults = { 'write_uid': lambda obj,cr,uid,context: uid, } + def getDiff(self, cr, uid, v1, v2, context={}): import difflib history_pool = self.pool.get('wiki.wiki.history') @@ -166,5 +173,7 @@ class History(osv.osv): line2 = text2.splitlines(1) diff = difflib.HtmlDiff() return diff.make_file(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=False) + History() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/wiki/wiki_view.xml b/addons/wiki/wiki_view.xml index ec738a5a91f..07f89257dbd 100644 --- a/addons/wiki/wiki_view.xml +++ b/addons/wiki/wiki_view.xml @@ -1,12 +1,22 @@ - - - - + - + + + + + + + + + wiki.groups.tree wiki.groups tree @@ -26,8 +36,8 @@ - - + @@ -52,10 +62,7 @@ form tree,form - + wiki.groups tree - + + wiki.wiki.tree.childs @@ -147,6 +152,8 @@ + + Search Pages wiki.wiki @@ -156,9 +163,13 @@ {'section':'1'} - - + + + + Pages Waiting Review wiki.wiki @@ -170,6 +181,8 @@ + + wiki.wiki.history.tree wiki.wiki.history @@ -205,10 +218,6 @@ form tree,form - + + + Create Menu wiki.create.menu diff --git a/addons/wiki/wizard/wiki_make_index.py b/addons/wiki/wizard/wiki_make_index.py index 78964743a8b..ea180597c3d 100644 --- a/addons/wiki/wizard/wiki_make_index.py +++ b/addons/wiki/wizard/wiki_make_index.py @@ -22,6 +22,7 @@ from osv import fields, osv class wiki_make_index(osv.osv_memory): + """ Create Index For Selected Page """ _name = "wiki.make.index" _description = "Create Index" _columns = { @@ -34,10 +35,11 @@ class wiki_make_index(osv.osv_memory): @param ids: List of wiki index’s IDs """ + data = context and context.get('active_ids', []) or [] for index_obj in self.browse(cr,uid,ids): wiki_pool = self.pool.get('wiki.wiki') cr.execute("Select id, section from wiki_wiki where id = ANY(%s) \ - order by section " ,(context['active_ids'],)) + order by section " ,(data,)) lst0 = cr.fetchall() lst = [] s_ids = {} diff --git a/addons/wiki/wizard/wiki_make_index_view.xml b/addons/wiki/wizard/wiki_make_index_view.xml index 1138afc908a..183a61183ef 100644 --- a/addons/wiki/wizard/wiki_make_index_view.xml +++ b/addons/wiki/wizard/wiki_make_index_view.xml @@ -1,6 +1,9 @@ + + + Create Index wiki.make.index diff --git a/addons/wiki/wizard/wiki_wiki_help_open.py b/addons/wiki/wizard/wiki_wiki_help_open.py index 934d5fdccb7..37f3a3a6eb0 100644 --- a/addons/wiki/wizard/wiki_wiki_help_open.py +++ b/addons/wiki/wizard/wiki_wiki_help_open.py @@ -23,10 +23,12 @@ from osv import fields, osv class wiki_wiki_help_open(osv.osv_memory): + """ Basic Wiki Editing """ _name = "wiki.wiki.help.open" _description = "Basic Wiki Editing" _columns = { } + def open_wiki_page(self, cr, uid, ids, context): """ Opens Wiki Page for Editing @param cr: the current row, from the database cursor, diff --git a/addons/wiki/wizard/wiki_wiki_help_open_view.xml b/addons/wiki/wizard/wiki_wiki_help_open_view.xml index 76e96664f3d..79007eb68d0 100644 --- a/addons/wiki/wizard/wiki_wiki_help_open_view.xml +++ b/addons/wiki/wizard/wiki_wiki_help_open_view.xml @@ -1,6 +1,9 @@ + + + Basic Wiki Editing wiki.wiki.help.open diff --git a/addons/wiki/wizard/wiki_wiki_page_open.py b/addons/wiki/wizard/wiki_wiki_page_open.py index 37b31a10ead..2b9675009ce 100644 --- a/addons/wiki/wizard/wiki_wiki_page_open.py +++ b/addons/wiki/wizard/wiki_wiki_page_open.py @@ -22,11 +22,13 @@ from osv import fields, osv class wiki_wiki_page_open(osv.osv_memory): + """ wizard Open Page """ _name = "wiki.wiki.page.open" _description = "wiz open page" _columns = { } + def open_wiki_page(self, cr, uid, ids, context): """ Opens Wiki Page of Group @param cr: the current row, from the database cursor, @@ -36,8 +38,6 @@ class wiki_wiki_page_open(osv.osv_memory): """ for group in self.pool.get('wiki.groups').browse(cr, uid,ids): - for openpage in self.pool.get('wiki.wiki.page.open').browse(cr, uid,ids): - value = { 'domain': "[('group_id','=',%d)]" % (group.id), 'name': 'Wiki Page', diff --git a/addons/wiki/wizard/wiki_wiki_page_open_view.xml b/addons/wiki/wizard/wiki_wiki_page_open_view.xml index 6df047882a4..b0f3da5899a 100644 --- a/addons/wiki/wizard/wiki_wiki_page_open_view.xml +++ b/addons/wiki/wizard/wiki_wiki_page_open_view.xml @@ -1,6 +1,9 @@ + + + Open Page wiki.wiki.page.open From 0a46449d0a6b5b3fb6d3e9d3e9270d97b976c7a1 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 16 Mar 2010 19:32:07 +0530 Subject: [PATCH 03/20] [IMP]: idea: code optimization and apply doc string bzr revid: ksa@tinyerp.co.in-20100316140207-32167zmiorb79959 --- addons/idea/idea.py | 68 +++++++++++++--------- addons/idea/idea_view.xml | 37 +++++++++--- addons/idea/wizard/idea_post_vote.py | 25 ++++---- addons/idea/wizard/idea_post_vote_view.xml | 23 +++----- 4 files changed, 92 insertions(+), 61 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index d487c1875e7..270fdc87605 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -21,10 +21,12 @@ from osv import osv, fields -VoteValues = [('-1','Not Voted'),('0','Very Bad'),('25', 'Bad'),('50','Normal'),('75','Good'),('100','Very Good') ] +VoteValues = [('-1', 'Not Voted'), ('0', 'Very Bad'), ('25', 'Bad'), \ + ('50', 'Normal'), ('75', 'Good'), ('100', 'Very Good') ] DefaultVoteValue = '50' class idea_category(osv.osv): + """ Category of Idea """ _name = "idea.category" _description = "Category for an idea" _columns = { @@ -37,17 +39,20 @@ class idea_category(osv.osv): ('name', 'unique(parent_id,name)', 'The name of the category must be unique' ) ] _order = 'parent_id,name asc' + idea_category() + class idea_idea(osv.osv): _name = 'idea.idea' _rec_name = 'title' def _vote_avg_compute(self, cr, uid, ids, name, arg, context = None): - if not len(ids): + """ compute average for voting """ + if not ids: return {} - sql = """SELECT i.id, avg(v.score::integer) + sql = """SELECT i.id, avg(v.score::integer) FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id WHERE i.id = ANY(%s) GROUP BY i.id @@ -57,10 +62,11 @@ class idea_idea(osv.osv): return dict(cr.fetchall()) def _vote_count(self,cr,uid,ids,name,arg,context=None): - if not len(ids): + """ count number of vote """ + if not ids: return {} - sql = """SELECT i.id, COUNT(1) + sql = """SELECT i.id, COUNT(1) FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id WHERE i.id = ANY(%s) GROUP BY i.id @@ -70,10 +76,11 @@ class idea_idea(osv.osv): return dict(cr.fetchall()) def _comment_count(self,cr,uid,ids,name,arg,context=None): - if not len(ids): + """ count number of comment """ + if not ids: return {} - sql = """SELECT i.id, COUNT(1) + sql = """SELECT i.id, COUNT(1) FROM idea_idea i LEFT OUTER JOIN idea_comment c ON i.id = c.idea_id WHERE i.id = ANY(%s) GROUP BY i.id @@ -88,7 +95,8 @@ class idea_idea(osv.osv): res[id] = '-1' vote_obj = self.pool.get('idea.vote') votes_ids = vote_obj.search(cr, uid, [('idea_id', 'in', ids), ('user_id', '=', uid)]) - for vote in vote_obj.browse(cr, uid, votes_ids, context): + vote_obj_id = vote_obj.browse(cr, uid, votes_ids, context) + for vote in vote_obj_id: res[vote.idea_id.id] = vote.score return res @@ -98,12 +106,12 @@ class idea_idea(osv.osv): textual_value = str(field_value) if vote: if int(field_value)>=0: - vote_obj.write(cr,uid, vote, { 'score' : textual_value }) + vote_obj.write(cr,uid,vote,{'score': textual_value }) else: - vote_obj.unlink(cr,uid, vote) + vote_obj.unlink(cr,uid,vote) else: if int(field_value)>=0: - vote_obj.create(cr,uid, { 'idea_id' : id, 'user_id' : uid, 'score' : textual_value }) + vote_obj.create(cr,uid, {'idea_id': id,'user_id': uid,'score': textual_value }) _columns = { @@ -111,14 +119,14 @@ class idea_idea(osv.osv): 'title': fields.char('Idea Summary', size=64, required=True), 'description': fields.text('Description', required=True, help='Content of the idea'), 'comment_ids': fields.one2many('idea.comment', 'idea_id', 'Comments'), - 'create_date' : fields.datetime( 'Creation date', readonly=True), - 'vote_ids' : fields.one2many('idea.vote', 'idea_id', 'Vote'), - 'my_vote' : fields.function(_vote_read, fnct_inv = _vote_save, string="My Vote", method=True, type="selection", selection=VoteValues), - 'vote_avg' : fields.function(_vote_avg_compute, method=True, string="Average Score", type="float"), - 'count_votes' : fields.function(_vote_count, method=True, string="Count of votes", type="integer"), + 'create_date': fields.datetime( 'Creation date', readonly=True), + 'vote_ids': fields.one2many('idea.vote', 'idea_id', 'Vote'), + 'my_vote': fields.function(_vote_read, fnct_inv = _vote_save, string="My Vote", method=True, type="selection", selection=VoteValues), + 'vote_avg': fields.function(_vote_avg_compute, method=True, string="Average Score", type="float"), + 'count_votes': fields.function(_vote_count, method=True, string="Count of votes", type="integer"), 'count_comments': fields.function(_comment_count, method=True, string="Count of comments", type="integer"), 'category_id': fields.many2one('idea.category', 'Category', required=True ), - 'state': fields.selection([('draft','Draft'),('open','Opened'),('close','Accepted'),('cancel','Cancelled')], 'State', readonly=True, + 'state': fields.selection([('draft','Draft'),('open','Opened'),('close','Accepted'),('cancel','Cancelled')], 'State', readonly=True, help='When the Idea is created the state is \'Draft\'.\n It is opened by the user, the state is \'Opened\'.\ \nIf the idea is accepted, the state is \'Accepted\'.'), 'stat_vote_ids': fields.one2many('idea.vote.stat', 'idea_id', 'Statistics', readonly=True), @@ -132,31 +140,33 @@ class idea_idea(osv.osv): _order = 'id desc' def idea_cancel(self, cr, uid, ids): - self.write(cr, uid, ids, { 'state' : 'cancel' }) + self.write(cr, uid, ids, { 'state': 'cancel' }) return True def idea_open(self, cr, uid, ids): - self.write(cr, uid, ids, { 'state' : 'open' }) + self.write(cr, uid, ids, { 'state': 'open' }) return True def idea_close(self, cr, uid, ids): - self.write(cr, uid, ids, { 'state' : 'close' }) + self.write(cr, uid, ids, { 'state': 'close' }) return True def idea_draft(self, cr, uid, ids): - self.write(cr, uid, ids, { 'state' : 'draft' }) + self.write(cr, uid, ids, { 'state': 'draft' }) return True idea_idea() + class idea_comment(osv.osv): + """ Apply Idea for Comment """ _name = 'idea.comment' _description = 'Comments' _rec_name = 'content' _columns = { 'idea_id': fields.many2one('idea.idea', 'Idea', required=True, ondelete='cascade' ), 'user_id': fields.many2one('res.users', 'User', required=True ), - 'content': fields.text( 'Comment', required=True ), - 'create_date' : fields.datetime( 'Creation date', readonly=True), + 'content': fields.text('Comment', required=True ), + 'create_date' : fields.datetime('Creation date', readonly=True), } _defaults = { 'user_id': lambda self, cr, uid, context: uid @@ -164,8 +174,11 @@ class idea_comment(osv.osv): _order = 'id desc' idea_comment() + class idea_vote(osv.osv): + """ Apply Idea for Vote """ _name = 'idea.vote' + _description = 'Vote for Idea' _rec_name = 'score' _columns = { 'user_id': fields.many2one( 'res.users', 'User'), @@ -173,22 +186,24 @@ class idea_vote(osv.osv): 'score': fields.selection( VoteValues, 'Score', required=True) } _defaults = { - #'user_id': lambda self, cr, uid, context: uid, 'score': lambda *a: DefaultVoteValue, } idea_vote() + class idea_vote_stat(osv.osv): + """ Idea votes Statistics """ _name = 'idea.vote.stat' _description = 'Idea Votes Statistics' _auto = False _rec_name = 'idea_id' _columns = { 'idea_id': fields.many2one('idea.idea', 'Idea', readonly=True), - 'score': fields.selection( VoteValues, 'Score', readonly=True), + 'score': fields.selection(VoteValues, 'Score', readonly=True), 'nbr': fields.integer('Number of Votes', readonly=True), } - def init(self, cr): + + def init(self,cr): """ initialize the sql view for the stats @@ -207,6 +222,7 @@ class idea_vote_stat(osv.osv): GROUP BY i.id, v.score, i.id ) """) + idea_vote_stat() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml index 9ccc56464d0..88c196b2e43 100644 --- a/addons/idea/idea_view.xml +++ b/addons/idea/idea_view.xml @@ -1,6 +1,9 @@ + + + idea.category.form @@ -34,9 +37,11 @@ - + - + + Ideas by Categories @@ -44,12 +49,15 @@ tree [('parent_id','=',False)] + + + Open Ideas @@ -66,6 +74,8 @@ + + idea.stat.form idea.stat @@ -79,6 +89,8 @@ + + idea.vote.tree idea.vote @@ -104,6 +116,8 @@ + + idea.idea.form idea.idea @@ -115,7 +129,6 @@ - @@ -171,6 +184,8 @@ + + idea.idea.search idea.idea @@ -180,8 +195,10 @@ - - + + @@ -191,6 +208,8 @@ + + idea.comment.tree idea.comment @@ -265,17 +284,19 @@ graph,tree - + - + - + Idea's vote idea.vote form tree,form + diff --git a/addons/idea/wizard/idea_post_vote.py b/addons/idea/wizard/idea_post_vote.py index 901f2c0a28d..858f85f214a 100644 --- a/addons/idea/wizard/idea_post_vote.py +++ b/addons/idea/wizard/idea_post_vote.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,24 +15,24 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## from osv import fields, osv class idea_post_vote(osv.osv_memory): - + _name = "idea.post.vote" _description = "Post vote" _columns = { - 'vote': fields.selection([('-1', 'Not Voted'), - ('0', 'Very Bad'), - ('25', 'Bad'), - ('50', 'Normal'), - ('75', 'Good'), + 'vote': fields.selection([('-1', 'Not Voted'), + ('0', 'Very Bad'), + ('25', 'Bad'), + ('50', 'Normal'), + ('75', 'Good'), ('100', 'Very Good') ], 'Post Vote', required=True) } - + def do_vote(self, cr, uid, ids, context): """ Create idea vote. @@ -41,10 +41,11 @@ class idea_post_vote(osv.osv_memory): @param ids: List of Idea Post vote’s IDs. @return: Dictionary {} """ + data = context and context.get('active_id', False) or False vote_obj = self.pool.get('idea.vote') - for data in self.read(cr, uid, ids): - score = str(data['vote']) - dic = {'idea_id': context['active_id'], 'user_id': uid, 'score': score } + for dovote_obj in self.read(cr, uid, ids): + score = str(dovote_obj['vote']) + dic = {'idea_id': data, 'user_id': uid, 'score': score } vote = vote_obj.create(cr, uid, dic) return {} diff --git a/addons/idea/wizard/idea_post_vote_view.xml b/addons/idea/wizard/idea_post_vote_view.xml index 7316340723c..fecefacba1f 100644 --- a/addons/idea/wizard/idea_post_vote_view.xml +++ b/addons/idea/wizard/idea_post_vote_view.xml @@ -1,6 +1,9 @@ + + + idea.post.vote.form idea.post.vote @@ -18,32 +21,22 @@ - + Vote idea.post.vote form tree,form - + new {'record_id':active_id} - - - + - - + + From 5b77ed421c72f23b21c926844e726915909386f9 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 16 Mar 2010 19:32:30 +0530 Subject: [PATCH 04/20] [IMP]: olap: code optimization and apply doc string bzr revid: ksa@tinyerp.co.in-20100316140230-fl6bloz1sieipnbp --- addons/olap/data/olap_cube_view.xml | 133 ++--- addons/olap/data/olap_view.xml | 21 +- addons/olap/olap.py | 519 ++++++++---------- addons/olap/wizard/olap_load_column.py | 6 +- addons/olap/wizard/olap_load_column_view.xml | 5 +- addons/olap/wizard/olap_query_logs_clear.py | 3 +- .../wizard/olap_query_logs_clear_view.xml | 9 +- 7 files changed, 301 insertions(+), 395 deletions(-) diff --git a/addons/olap/data/olap_cube_view.xml b/addons/olap/data/olap_cube_view.xml index 4fa62e32185..05be10fd8a5 100644 --- a/addons/olap/data/olap_cube_view.xml +++ b/addons/olap/data/olap_cube_view.xml @@ -2,11 +2,8 @@ - -Wizard view for the load data - ---> bi.load.db.form bi.load.db.wizard @@ -37,9 +34,8 @@ Wizard view for the load data - + + Olap Warehouse olap.warehouse.wizard @@ -69,10 +65,8 @@ Wizard For Olap Warehouse sequence="51" parent="base.next_id_50" /> - + Parameters Configuration @@ -116,11 +110,7 @@ Wizard View for the parameters wizard - + bi.auto.configure.form @@ -176,20 +166,25 @@ Wizard view for the Auto Configuring the data