From d34186d12f03a2bf0d0f663c6b0f5c9ad16dfbec Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Fri, 10 Dec 2010 18:54:55 +0100 Subject: [PATCH 1/9] [FIX] crm : next/previous_stage behavior bzr revid: tfr@openerp.com-20101210175455-hvoh7pqjnak6b1wh --- addons/crm/crm.py | 115 ++++++++++++++-------------- addons/crm/crm_lead_data.xml | 14 ++-- addons/crm_claim/crm_claim_data.xml | 2 +- 3 files changed, 65 insertions(+), 66 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index c3a4ef44a9c..a91009583f2 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -22,6 +22,7 @@ import time import base64 import tools + from osv import fields from osv import osv from tools.translate import _ @@ -135,6 +136,57 @@ class crm_case(object): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) return user.context_section_id.id or False + def _find_next_stage(self, cr, uid, stage_list, index, current_seq, stage_pool, context=None): + if index + 1 == len(stage_list): + return False + print "cul" + print index + next_stage_id = stage_list[index + 1] + next_stage = stage_pool.browse(cr, uid, next_stage_id, context=context) + if not next_stage: + return False + + next_seq = next_stage.sequence + if (abs(next_seq - current_seq)) >= 1: + print next_stage + return next_stage + else : + return _find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool) + + def stage_change(self, cr, uid, ids, context=None, order='sequence'): + if not context: + context = {} + stage_pool = self.pool.get('crm.case.stage') + stage_type = context and context.get('stage_type','') + current_seq = False + next_stage_id = False + for case in self.browse(cr, uid, ids, context): + print case + next_stage = False + data = {} + print stage_type + domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] + if case.section_id and case.section_id.stage_ids: + domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) + + stages = stage_pool.search(cr, uid, domain, order=order) + current_seq = case.stage_id.sequence + index = -1 + if case.stage_id and case.stage_id.id in stages: + index = stages.index(case.stage_id.id) + print stages + print "call" + next_stage = self._find_next_stage(cr, uid, stages, index, current_seq, stage_pool, context=context) + if next_stage: + next_stage_id = next_stage.id + data = {'stage_id': next_stage.id} + if next_stage.on_change: + data.update({'probability': next_stage.probability}) + self.write(cr, uid, [case.id], data, context=context) + + return next_stage_id + + def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @@ -143,36 +195,10 @@ class crm_case(object): @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" - if not context: - context = {} - stage_pool = self.pool.get('crm.case.stage') - stage_type = context and context.get('stage_type','') - current_seq = False - for case in self.browse(cr, uid, ids, context): - next_stage = False - data = {} - domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] - if case.section_id and case.section_id.stage_ids: - domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) - stages = stage_pool.search(cr, uid, domain, order='sequence') - index = -1 - if case.stage_id and case.stage_id.id in stages: - index = stages.index(case.stage_id.id) - if index + 1 == len(stages): - return False - else: - next_stage = stages[index + 1] - current_seq = case.stage_id.sequence - if next_stage: - stage = stage_pool.browse(cr, uid, next_stage, context=context) - next_seq = stage.sequence - if current_seq and (next_seq - current_seq) >= 1: - data = {'stage_id': next_stage} - if stage.on_change: - data.update({'probability': stage.probability}) - self.write(cr, uid, [case.id], data, context=context) - return next_stage - + + + return self.stage_change(cr, uid, ids, context=context, order='sequence') + def stage_previous(self, cr, uid, ids, context=None): """This function computes previous stage for case from its current stage using available stage for that case type @@ -181,34 +207,7 @@ class crm_case(object): @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" - if not context: - context = {} - stage_pool = self.pool.get('crm.case.stage') - stage_type = context and context.get('stage_type','') - for case in self.browse(cr, uid, ids, context): - prev_stage = False - data = {} - domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] - if case.section_id and case.section_id.stage_ids: - domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) - stages = stage_pool.search(cr, uid, domain, order='sequence') - index = 0 - if case.stage_id and case.stage_id.id in stages: - index = stages.index(case.stage_id.id) - if index == 0: - return False - else: - prev_stage = stages[index - 1] - current_seq = case.stage_id.sequence - if prev_stage: - stage = stage_pool.browse(cr, uid, prev_stage, context=context) - prev_seq = stage.sequence - if current_seq and (prev_seq - current_seq) <= 1: - data = {'stage_id': prev_stage} - if stage.on_change: - data.update({'probability': stage.probability}) - self.write(cr, uid, [case.id], data, context=context) - return prev_stage + return self.stage_change(cr, uid, ids, context=context, order='sequence desc') def onchange_partner_id(self, cr, uid, ids, part, email=False): """This function returns value of partner address based on partner diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index f10ba72ef8e..3cb34c49299 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -2,7 +2,12 @@ - + + Lost + + + lead + New @@ -40,12 +45,7 @@ lead - - Lost - - - lead - + Sales Department diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index 4d321a42b6e..e917ba5bea6 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -59,7 +59,7 @@ Won't fix - 11 + 0 claim From a01c3728c51caded70cc4980e8d3113ff2de11bb Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Mon, 13 Dec 2010 11:50:58 +0530 Subject: [PATCH 2/9] [IMP] 1) Openlink in Webbrowser with menu 2) Putting Config in Toolbar bzr revid: jam@tinyerp.com-20101213062058-j0cue0r4xtvho8o7 --- .../plugin/openerp-outlook-plugin/addin.py | 8 ++++++++ .../openerp-outlook-plugin/dialogs/dialog_map.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/outlook/plugin/openerp-outlook-plugin/addin.py b/addons/outlook/plugin/openerp-outlook-plugin/addin.py index 2cd8bf565b1..39ea41d7f16 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/addin.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/addin.py @@ -175,6 +175,12 @@ class OutlookAddin: toolbar = bars.Item("Standard") openerp_bar = bars.Item('Open ERP') + item = openerp_bar.Controls.Add(Type = constants.msoControlButton, Temporary = True) + item = self.toolbarButtonConfig = DispatchWithEvents(item, Configuration) + item.Caption = "Configuration" + item.TooltipText = "Click to configure OpenERP." + item.Enabled = True + item = openerp_bar.Controls.Add(Type=constants.msoControlButton, Temporary=True) # Hook events for the item item = self.toolbarButton = DispatchWithEvents(item, ArchiveEvent) @@ -198,6 +204,8 @@ class OutlookAddin: item.TooltipText = "Click to Open Document that has been pushed to server." item.Enabled = True + + # Hook events for the item # item = toolbarweb.Controls.Add(Type = constants.msoControlButton, Temporary = True) # item = self.toolbarButtonPartner = DispatchWithEvents(item, ViewPartners) diff --git a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py index 747915f7181..140c100f229 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py @@ -1406,14 +1406,11 @@ def OpenPartnerForm(txtProcessor,*args): txtProcessor.init_done=True return try: - linktopartner = "http://"+web_server+":"+str(web_server_port)+"/openerp/form/view?model=res.partner&id="+str(vals) - + import urllib + next = urllib.urlencode({'next' : '/openerp/form/view?model=res.partner&id=' +str(vals) }) + weburl = 'http://'+web_server+':'+str(web_server_port)+'/' + linktopartner = weburl + '?' + next win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, str(linktopartner)) -# import urllib -# encode = urllib.urlencode('/openerp/form/view?model=res.partner&id='+str(vals)) -# weburl = 'http://'+web_server+':'+str(web_server_port) -# linktopartner = weburl + "?next=" + encode -# win32gui.SendMessage(partner_link, win32con.WM_SETTEXT, 0, linktopartner) except Exception,e: win32ui.MessageBox("Error While Opening Partner.\n"+str(e),"Open Partner", flag_error) webbrowser.open_new(linktopartner) @@ -1469,7 +1466,10 @@ def SerachOpenDocuemnt(txtProcessor,*args): txtProcessor.init_done=True return try: - linktodoc = "http:\\\\" +web_server+ ":"+str(web_server_port)+"\\openerp\\form\\view?model="+vals[0][1]+"&id="+str(vals[1][1]) + import urllib + next = urllib.urlencode({'next' : '/openerp/form/view?model='+vals[0][1]+'&id='+str(vals[1][1])}) + weburl = 'http://'+web_server+':'+str(web_server_port)+'/' + linktodoc = weburl + '?' + next win32gui.SendMessage(link_box, win32con.WM_SETTEXT, 0, str(linktodoc)) except Exception,e: win32ui.MessageBox("Error While Opening Document.\n"+str(e),"Open Document", flag_error) From 4939946b9f8933f805d6e0dc47196760562ee703 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 13 Dec 2010 10:01:08 +0100 Subject: [PATCH 3/9] [IMP] Improved email and username handling when sending an publisher warranty issue report. bzr revid: nicolas.vanhoren@openerp.com-20101213090108-sy7xuwpptskhha3j --- .../base/publisher_warranty/publisher_warranty.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/addons/base/publisher_warranty/publisher_warranty.py b/bin/addons/base/publisher_warranty/publisher_warranty.py index fb57ed0503c..dad1b2f674d 100644 --- a/bin/addons/base/publisher_warranty/publisher_warranty.py +++ b/bin/addons/base/publisher_warranty/publisher_warranty.py @@ -71,7 +71,7 @@ class publisher_warranty_contract(osv.osv): 'uncovered_modules': list(), } - def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None, email=None): + def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None): """ Method called by the client to send a problem to the publisher warranty server. """ if not remarks: @@ -84,6 +84,9 @@ class publisher_warranty_contract(osv.osv): origin = 'client' dbuuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') db_create_date = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') + user = self.pool.get("res.users").browse(cr, uid, uid) + user_name = user.name + email = user.email msg = {'contract_name': valid_contract.name, 'tb': tb, @@ -95,6 +98,7 @@ class publisher_warranty_contract(osv.osv): 'db_create_date': db_create_date, 'issue_name': issue_name, 'email': email, + 'user_name': user_name, } @@ -242,9 +246,9 @@ class maintenance_contract(osv.osv_memory): def status(self, cr, uid): return self.pool.get("publisher_warranty.contract").status(cr, uid) - def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None, email=None): + def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None): return self.pool.get("publisher_warranty.contract").send(cr, uid, tb, - explanations, remarks, issue_name, email) + explanations, remarks, issue_name) maintenance_contract() From f856489f5b2105f3d50e1c7d93d2711b5b6f1669 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Mon, 13 Dec 2010 10:39:59 +0100 Subject: [PATCH 4/9] [FIX] crm_view.xml : section_ids in view bzr revid: tfr@openerp.com-20101213093959-z97zekyeg75q0svw --- addons/crm/crm.py | 12 ++++-------- addons/crm/crm_lead_view.xml | 6 +++--- addons/crm/crm_view.xml | 1 + 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index a91009583f2..5336bdd23fb 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -139,8 +139,6 @@ class crm_case(object): def _find_next_stage(self, cr, uid, stage_list, index, current_seq, stage_pool, context=None): if index + 1 == len(stage_list): return False - print "cul" - print index next_stage_id = stage_list[index + 1] next_stage = stage_pool.browse(cr, uid, next_stage_id, context=context) if not next_stage: @@ -148,10 +146,9 @@ class crm_case(object): next_seq = next_stage.sequence if (abs(next_seq - current_seq)) >= 1: - print next_stage return next_stage else : - return _find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool) + return self._find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool) def stage_change(self, cr, uid, ids, context=None, order='sequence'): if not context: @@ -161,10 +158,9 @@ class crm_case(object): current_seq = False next_stage_id = False for case in self.browse(cr, uid, ids, context): - print case next_stage = False data = {} - print stage_type + domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) @@ -174,8 +170,7 @@ class crm_case(object): index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) - print stages - print "call" + next_stage = self._find_next_stage(cr, uid, stages, index, current_seq, stage_pool, context=context) if next_stage: next_stage_id = next_stage.id @@ -635,6 +630,7 @@ class crm_case_stage(osv.osv): _columns = { 'section_ids':fields.many2many('crm.case.section', 'section_stage_rel', 'stage_id', 'section_id', 'Sections'), } + crm_case_stage() diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 87eb7ff3bd1..979ab26cfd1 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -57,14 +57,14 @@ - +