[MERGE] merged from lp:~openerp-commiter/openobject-addons/crm-improvement

bzr revid: hmo@tinyerp.com-20100316131328-lgttnpy712rqr7ga
This commit is contained in:
Harry (Open ERP)
2010-03-16 18:43:28 +05:30
170 changed files with 3933 additions and 2241 deletions
+1
View File
@@ -31,6 +31,7 @@
'depends': ['base'],
'init_xml': [],
'update_xml': [
'wizard/audittrail_view_log_view.xml',
'audittrail_view.xml',
'security/ir.model.access.csv',
'security/audittrail_security.xml'
+2 -2
View File
@@ -124,8 +124,8 @@
</record>
<menuitem name="Logs" id="menu_action_audittrail_log_tree" action="action_audittrail_log_tree" parent="menu_action_audittrail"/>
<wizard string="View log" menu="False" model="audittrail.log" name="audittrail.view.log" id="wizard_audittrail_log"/>
<menuitem name="View Logs" id="menu_action_log_tree2" action="wizard_audittrail_log" type="wizard" parent="menu_action_audittrail"/>
<!-- <wizard string="View log" menu="False" model="audittrail.log" name="audittrail.view.log" id="wizard_audittrail_log"/>-->
<menuitem name="View Logs" id="menu_action_log_tree2" action="action_audittrail_view_log" parent="menu_action_audittrail"/>
</data>
</openerp>
+1 -1
View File
@@ -19,6 +19,6 @@
#
##############################################################################
import wizard_view_log
import audittrail_view_log
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class audittrail_view_log(osv.osv_memory):
_name = "audittrail.view.log"
_description = "View Log"
_columns ={
'from':fields.datetime('Log From'),
'to':fields.datetime('Log To', required = True)
}
_defaults = {
'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
}
def log_open_window(self, cr, uid, ids, context):
"""
Open Log form from given date range..
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of audittrail view log’s IDs.
@return: Dictionary of audittrail log form on given date range.
"""
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
log_obj= self.pool.get(result['res_model'])
log_id = log_obj.search(cr, uid, [])
log_model=log_obj.read(cr, uid,log_id,['object_id'])
for datas in self.read(cr, uid, ids):
if not datas['from']:
if datas['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
result['domain'] = str([('timestamp', '<',datas['to'])])
else:
pass
else:
result['domain'] = str([('timestamp', '>',datas['from']),('timestamp', '<',datas['to'])])
return result
audittrail_view_log()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_audittrail_view_log" model="ir.ui.view">
<field name="name">audittrail.view.log.form</field>
<field name="model">audittrail.view.log</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Audit Logs">
<group colspan="4" >
<field name="from" colspan="4"/>
<newline/>
<field name="to" colspan="4"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-open" string="Open Logs" name="log_open_window" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_audittrail_view_log" model="ir.actions.act_window">
<field name="name">View log</field>
<field name="res_model">audittrail.view.log</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_audittrail_view_log"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,81 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
import time
class wizard_view_log(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="Audit Logs">
<field name="from" colspan="4"/>
<newline/>
<field name="to" colspan="4"/>
</form>'''
form1_fields = {
'from': {
'string': 'Log From',
'type': 'datetime',
},
'to': {
'string': 'Log To',
'type': 'datetime',
'default': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
'required':True
},
}
def _log_open_window(self, cr, uid, data, context):
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
log_obj= pooler.get_pool(cr.dbname).get(result['res_model'])
log_id = log_obj.search(cr, uid, [])
log_model=log_obj.read(cr, uid,log_id,['object_id'])
if not data['form']['from']:
if data['form']['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
result['domain'] = str([('timestamp', '<',data['form']['to'])])
else:
pass
else:
result['domain'] = str([('timestamp', '>',data['form']['from']),('timestamp', '<',data['form']['to'])])
return result
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel'), ('open', 'Open Logs')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action':_log_open_window, 'state':'end'}
}
}
wizard_view_log('audittrail.view.log')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -1
View File
@@ -40,7 +40,8 @@
],
"demo_xml" : [],
"update_xml" : [
'security/ir.model.access.csv',
'security/ir.model.access.csv',
'wizard/calendar_event_edit_all_view.xml',
'base_calendar_view.xml'
],
"installable" : True,
+1 -1
View File
@@ -775,7 +775,7 @@ rule or repeating pattern for anexception to a recurrence set"),
'base_calendar_alarm_id': fields.many2one('calendar.alarm', 'Alarm'),
'recurrent_uid': fields.integer('Recurrent ID'),
'recurrent_id': fields.datetime('Recurrent ID date'),
'vtimezone': fields.related('user_id', 'context_tz', type='char', size=24, string='Timezone'),
'vtimezone': fields.related('user_id', 'context_tz', type='char', size=24, string='Timezone', store=True),
'user_id': fields.many2one('res.users', 'Responsible'),
'freq': fields.selection([('None', 'No Repeat'), \
('secondly', 'Secondly'), \
+1 -1
View File
@@ -82,7 +82,7 @@
<field name="event_date" />
<field name="event_end_date" />
<field name="language"/>
<field name="ref" colspan="4"/>
<field name="ref" colspan="4" readonly="1"/>
</group>
</page>
<page string="Delegation Info">
+2 -1
View File
@@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard_cal_edit_event
import calendar_event_edit_all
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
class calendar_event_edit_all(osv.osv_memory):
def _default_values(self, cr, uid, context={}):
"""
@Return : Get Default value for Start Date
"""
if context.get('date'):
return context.get('date')
else:
model = context.get('model')
model_obj = self.pool.get(model)
event = model_obj.read(cr, uid, context['active_id'], ['name', 'location', 'alarm_id'])
return event['date']
def _default_deadline(self, cr, uid, context={}):
"""
@return : Get Default value for End Date
"""
if context.get('date_deadline'):
return context.get('date_deadline')
else:
model = context.get('model')
model_obj = self.pool.get(model)
event = model_obj.read(cr, uid, context['active_id'], ['name', 'location', 'alarm_id'])
return event['date_deadline']
def modify_this(self, cr, uid, ids, context=None):
"""
Modify All event for Crm Meeting.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of calendar event edit all’s IDs
"""
for datas in self.read(cr, uid, ids):
model = context.get('model')
model_obj = self.pool.get(model)
model_obj.modify_all(cr, uid, [context['active_id']], datas, context)
return {}
_name = "calendar.event.edit.all"
_description = "Calendar Edit all event"
_columns ={
'name':fields.char('Title', size=64, required=True),
'date':fields.datetime('Start Date', required=True),
'date_deadline':fields.datetime('End Date', required=True),
'location':fields.char('Location', size=124),
'alarm_id':fields.many2one('res.alarm', 'Reminder'),
}
_defaults = {
'date':_default_values,
'date_deadline':_default_deadline
}
calendar_event_edit_all()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_calendar_event_edit_all" model="ir.ui.view">
<field name="name">calendar.event.edit.all.form</field>
<field name="model">calendar.event.edit.all</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Edit all Occurrences">
<group colspan="4" >
<separator string="" colspan="4" />
<newline/>
<field name='name' colspan="4" />
<newline />
<field name='location' colspan="4" />
<newline />
<field name='date' />
<field name='date_deadline' />
<newline />
<field name='alarm_id'/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-save" string="_Save" name="modify_this" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_calendar_event_edit_all" model="ir.actions.act_window">
<field name="name">Edit all events</field>
<field name="res_model">calendar.event.edit.all</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_calendar_event_edit_all"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,78 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
class event_edit_all(wizard.interface):
event_form = """<?xml version="1.0"?>
<form string="Edit all Occurrences">
<separator string="" colspan="4" />
<newline />
<field name='name' colspan="4" />
<newline />
<field name='location' colspan="4" />
<newline />
<field name='date' />
<field name='date_deadline' />
<newline />
<field name='alarm_id'/>
</form>"""
event_fields = {
'name': {'string': 'Title', 'type': 'char', 'size': 64, 'required': True},
'date': {'string': 'Start Date', 'type': 'datetime', 'required': True},
'date_deadline': {'string': 'End Date', 'type': 'datetime', 'required': True},
'location': {'string': 'Location', 'type': 'char', 'size': 124},
'alarm_id': {'string': 'Reminder', 'type': 'many2one', 'relation': 'res.alarm'},
}
def _default_values(self, cr, uid, data, context=None):
model = data.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
event = model_obj.read(cr, uid, data['id'], ['name', 'location', 'alarm_id'])
event.update({
'date': context.get('date'),
'date_deadline': context.get('date_deadline')
})
return event
def _modify_all(self, cr, uid, datas, context=None):
model = datas.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
model_obj.modify_all(cr, uid, datas['id'], datas['form'], context)
return {}
states = {
'init': {
'actions': [_default_values],
'result': {'type': 'form', 'arch': event_form, 'fields': event_fields,
'state': [('end', 'Cancel', 'gtk-cancel'), ('edit', '_Save', 'gtk-save')]}
},
'edit': {
'actions': [],
'result': {'type': 'action', 'action': _modify_all, 'state': 'end'}
}
}
event_edit_all('calendar.event.edit.all')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -37,6 +37,7 @@ the "Dashboard" menu.
'init_xml': [],
'update_xml': [
'security/ir.model.access.csv',
'wizard/report_menu_create_view.xml',
'base_report_creator_wizard.xml',
'base_report_creator_view.xml'
],
@@ -41,7 +41,7 @@
<field name="model_ids" colspan="4" context="{'model_ids':model_ids}"/>
<separator string="State" colspan="4"/>
<field name="state"/>
<button string="Create Menu" name="%(wizard_menu_create)d" type="action" colspan="2" icon="gtk-justify-fill"/>
<button string="Create Menu" name="%(action_report_menu_create)d" type="action" colspan="2" icon="gtk-justify-fill"/>
</page><page string="View parameters">
<separator string="Used View" colspan="4"/>
<field name="view_type1"/>
@@ -1,13 +1,8 @@
<?xml version="1.0"?>
<openerp>
<data>
<wizard
id="wizard_set_filter_fields"
string="Set Filter Fields"
name="base_report_creator.report_filter.fields"/>
<wizard
id="wizard_menu_create"
string="Create Menu for Report"
name="base_report_creator.report.menu.create"/>
</data>
<data>
<wizard id="wizard_set_filter_fields" string="Set Filter Fields"
name="base_report_creator.report_filter.fields" />
</data>
</openerp>
@@ -22,5 +22,6 @@
import wiz_set_filter_fields
import base_report_creator_open
import report_menu_create
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -20,62 +20,55 @@
##############################################################################
import time
import wizard
import osv
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
section_form = '''<?xml version="1.0"?>
<form string="Create Menu For This Report">
<separator string="Menu Information" colspan="4"/>
<field name="menu_name"/>
<field name="menu_parent_id"/>
</form>'''
section_fields = {
'menu_name': {'string':'Menu Name', 'type':'char', 'required':True, 'size':64},
'menu_parent_id': {'string':'Parent Menu', 'type':'many2one', 'relation':'ir.ui.menu', 'required':True},
}
def report_menu_create(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
board = pool.get('base_report_creator.report').browse(cr, uid, data['id'])
view = board.view_type1
if board.view_type2:
view+=','+board.view_type2
if board.view_type3:
view+=','+board.view_type3
action_id = pool.get('ir.actions.act_window').create(cr, uid, {
'name': board.name,
'view_type':'form',
'view_mode':view,
'context': "{'report_id':%d}" % (board.id,),
'res_model': 'base_report_creator.report'
})
pool.get('ir.ui.menu').create(cr, uid, {
'name': data['form']['menu_name'],
'parent_id': data['form']['menu_parent_id'],
'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,'+str(action_id)
}, context)
return {}
class wizard_section_menu_create(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]}
},
'create_menu': {
'actions': [report_menu_create],
'result': {
'type':'state',
'state':'end'
}
}
}
wizard_section_menu_create('base_report_creator.report.menu.create')
class report_menu_create(osv.osv_memory):
"""
Create Menu
"""
_name = "report.menu.create"
_description = "Menu Create"
_columns ={
'menu_name':fields.char('Menu Name', size=64, required=True),
'menu_parent_id':fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
}
def report_menu_create(self, cr, uid, ids, context):
"""
Create Menu.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Report Menu Create's IDs
"""
board = self.pool.get('base_report_creator.report').browse(cr, uid, context['active_id'])
view = board.view_type1
if board.view_type2:
view+=','+board.view_type2
if board.view_type3:
view+=','+board.view_type3
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
'name': board.name,
'view_type':'form',
'view_mode':view,
'context': "{'report_id':%d}" % (board.id,),
'res_model': 'base_report_creator.report'
})
for data in self.read(cr, uid, ids):
self.pool.get('ir.ui.menu').create(cr, uid, {
'name': data['menu_name'],
'parent_id': data['menu_parent_id'],
'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,'+str(action_id)
}, context)
return {}
report_menu_create()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_report_menu_create" model="ir.ui.view">
<field name="name">report.menu.create.form</field>
<field name="model">report.menu.create</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create Menu For This Report">
<group colspan="4" >
<separator string="Menu Information" colspan="4"/>
<field name="menu_name"/>
<field name="menu_parent_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-save" string="Create Menu" name="report_menu_create" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_report_menu_create" model="ir.actions.act_window">
<field name="name">Create Menu for Report</field>
<field name="res_model">report.menu.create</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_report_menu_create"/>
<field name="target">new</field>
</record>
</data>
</openerp>
+1 -1
View File
@@ -27,7 +27,7 @@
'description': """Base module for all dashboards.""",
'author': 'Tiny',
'depends': ['base'],
'update_xml': ['security/ir.model.access.csv', 'board_view.xml'],
'update_xml': ['security/ir.model.access.csv', 'wizard/board_menu_create_view.xml', 'board_view.xml'],
'demo_xml': [],
'installable': True,
'active': False,
+2 -2
View File
@@ -34,7 +34,7 @@
<field name="view_mode">form,tree</field>
</record>
<wizard id="wizard_board_create_menu" model="board.board" multi="True" name="board.board.menu.create" string="Create Board Menu" />
<!-- <wizard id="wizard_board_create_menu" model="board.board" multi="True" name="board.board.menu.create" string="Create Board Menu" /> -->
<record id="view_board_tree" model="ir.ui.view">
<field name="name">board.board.tree</field>
@@ -54,7 +54,7 @@
<field name="arch" type="xml">
<form string="Dashboard">
<field name="name" select="1"/>
<button colspan="2" name="%(wizard_board_create_menu)d" string="Create Menu" type="action" icon="gtk-justify-fill"/>
<button colspan="2" name="%(action_board_menu_create)d" string="Create Menu" type="action" icon="gtk-justify-fill"/>
<field colspan="4" name="line_ids">
<tree string="Dashboard View">
<field name="name"/>
+1 -1
View File
@@ -19,7 +19,7 @@
#
##############################################################################
import board_wizard
import board_menu_create
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+74
View File
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
class board_menu_create(osv.osv_memory):
"""
Create Menu
"""
def check_views(self, cr, uid, context):
board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
if not board.line_ids:
raise osv.except_osv(_('User Error!'), _('Please Insert Dashboard View(s) !'))
return False
def board_menu_create(self, cr, uid, ids, context):
"""
Create Menu.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Board Menu Create's IDs
@return : Dictionary {}.
"""
board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
'name': board.name,
'view_type':'form',
'view_mode':'form',
'res_model': 'board.board',
'view_id': board.view_id.id,
})
for data in self.read(cr, uid, ids):
self.pool.get('ir.ui.menu').create(cr, uid, {
'name': data['menu_name'],
'parent_id': data['menu_parent_id'],
'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,'+str(action_id)
}, context)
return {}
_name = "board.menu.create"
_description = "Menu Create"
_columns = {
'menu_name':fields.char('Menu Name', size=64, required=True),
'menu_parent_id':fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
}
_defaults = {
'menu_name':check_views,
}
board_menu_create()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_board_menu_create" model="ir.ui.view">
<field name="name">board.menu.create.form</field>
<field name="model">board.menu.create</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create Menu For Dashboard">
<group colspan="4" >
<separator string="Menu Information" colspan="4"/>
<field name="menu_name"/>
<field name="menu_parent_id"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-save" string="Create Menu" name="board_menu_create" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_board_menu_create" model="ir.actions.act_window">
<field name="name">Create Board Menu</field>
<field name="res_model">board.menu.create</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_board_menu_create"/>
<field name="target">new</field>
</record>
</data>
</openerp>
-86
View File
@@ -1,86 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import wizard
import osv
import pooler
from tools.translate import _
section_form = '''<?xml version="1.0"?>
<form string="Create Menu For Dashboard">
<separator string="Menu Information" colspan="4"/>
<field name="menu_name"/>
<field name="menu_parent_id"/>
</form>'''
section_fields = {
'menu_name': {'string':'Menu Name', 'type':'char', 'required':True, 'size':64},
'menu_parent_id': {'string':'Parent Menu', 'type':'many2one', 'relation':'ir.ui.menu', 'required':True},
}
def check_views(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
board = pool.get('board.board').browse(cr, uid, data['id'])
if not board.line_ids:
raise wizard.except_wizard(_('User Error!'),_('Please Insert Dashboard View(s) !'))
return data['form']
def board_menu_create(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
board = pool.get('board.board').browse(cr, uid, data['id'])
action_id = pool.get('ir.actions.act_window').create(cr, uid, {
'name': board.name,
'view_type':'form',
'view_mode':'form',
'res_model': 'board.board',
'view_id': board.view_id.id,
})
pool.get('ir.ui.menu').create(cr, uid, {
'name': data['form']['menu_name'],
'parent_id': data['form']['menu_parent_id'],
'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,'+str(action_id)
}, context)
return {}
class wizard_section_menu_create(wizard.interface):
states = {
'init': {
'actions': [check_views],
'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]}
},
'create_menu': {
'actions': [board_menu_create],
'result': {
'type':'state',
'state':'end'
}
}
}
wizard_section_menu_create('board.board.menu.create')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -21,7 +21,7 @@
{
'name': 'Dashboard for CRM Configuration',
'name': 'Dashboard for CRM',
'version': '1.0',
'category': 'Board/CRM',
'description': """
@@ -31,10 +31,10 @@ This module implements a dashboard for CRM that includes:
* My Meetings (list)
* Sales Pipeline by Stage (graph)
* My Cases (list)
* Jobs Tracking (graph)
* Leads of the month by user (list)
""",
'author': 'Tiny',
'depends': ['board', 'crm', 'report_crm'],
'depends': ['board', 'crm'],
'update_xml': ['board_crm_statistical_view.xml', 'board_crm_view.xml'],
'demo_xml': ['board_crm_demo.xml'],
'installable': True,
@@ -6,40 +6,38 @@
-->
<record model="ir.ui.view" id="view_crm_lead_stage_graph1">
<field name="name">Leads By Stage - Graph</field>
<field name="model">report.crm.lead.section.stage</field>
<field name="model">crm.lead.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Leads By Stage" type="pie">
<field name="stage_id"/>
<field name="nbr" operator="+"/>
<field name="state" group="True"/>
</graph>
</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_categ_graph">
<field name="name">report.crm.opportunity.categ.graph</field>
<field name="model">report.crm.opportunity.categ</field>
<field name="name">crm.opportunity.report.graph</field>
<field name="model">crm.opportunity.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Opportunity by Sections and Categories" type="bar" orientation="horizontal">
<graph string="Opportunities" type="bar" orientation="horizontal">
<field name="categ_id"/>
<field name="nbr" operator="+"/>
<field name="state" group="True"/>
</graph>
</field>
</record>
<act_window name="Opportunities By Categories"
domain="[('state','!=','done'),('state','!=','cancel')]"
res_model="report.crm.opportunity.categ"
res_model="crm.opportunity.report"
view_type="form"
view_mode="graph,tree,form"
view_id="view_crm_opportunity_categ_graph"
id="act_oppor_categ"/>
<record model="ir.actions.act_window" id="act_leads_state">
<field name="res_model">report.crm.lead.section.stage</field>
<field name="res_model">crm.lead.report</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree,form</field>
<field name="view_id" ref="view_crm_lead_stage_graph1"/>
@@ -47,8 +45,8 @@
</record>
<act_window name="Leads Of The Month By User"
domain="[('month','=',time.strftime('%%m')),('state','!=','cancel')]"
res_model="report.crm.lead.user"
domain="[('month','=',time.strftime('%%m')),('state','!=','cancel'),('user_id','=',uid)]"
res_model="crm.lead.report"
view_type="form"
view_mode="graph,tree,form"
view_id="view_crm_lead_stage_graph1"
@@ -63,14 +61,14 @@
<hpaned>
<child1>
<action
string="Opportunities By Categories"
string="Opportunities"
name="%(act_oppor_categ)d"
colspan="4"
height="200"
width="250"/>
<action
string="Leads By Stage"
string="Leads"
name="%(act_leads_state)d"
height="200"
colspan="4"/>
@@ -100,7 +98,7 @@
<menuitem icon="terp-graph" id="base.dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>
<menuitem
name="CRM Configuration" parent="base.dashboard"
name="CRM" parent="base.dashboard"
id="menu_board_crm_config"
groups="crm.group_crm_manager"/>
<menuitem
@@ -2,12 +2,12 @@
<openerp>
<data>
<record model="board.note.type" id="note_crm_type">
<field name="name">CRM Configuration</field>
<field name="name">CRM</field>
</record>
<record model="ir.ui.view" id="view_crm_opportunity_user_graph1">
<field name="name">crm.opportunity.user.graph1</field>
<field name="model">report.crm.opportunity.user</field>
<field name="name">crm.opportunity.report.graph1</field>
<field name="model">crm.opportunity.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Opportunities by User and Section" type="pie">
@@ -41,7 +41,7 @@
id="act_my_cases"/>
<record model="ir.actions.act_window" id="act_my_leads_stage">
<field name="res_model">report.crm.lead.section.stage</field>
<field name="res_model">crm.lead.report</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree,form</field>
<field name="view_id" ref="view_crm_lead_stage_graph1"/>
@@ -49,7 +49,7 @@
</record>
<record model="ir.actions.act_window" id="act_sales_pipeline">
<field name="res_model">report.crm.opportunity.user</field>
<field name="res_model">crm.opportunity.report</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree,form</field>
<field name="view_id" ref="view_crm_opportunity_user_graph1"/>
+4 -4
View File
@@ -20,10 +20,10 @@
##############################################################################
import caldav
import caldav_cache
import caldav_fs
import caldav_node
import webdav_server
#import caldav_cache
#import caldav_fs
#import caldav_node
#import webdav_server
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+3 -1
View File
@@ -49,7 +49,9 @@
"demo_xml" : [],
"update_xml" : [
'security/ir.model.access.csv',
'caldav_wizard.xml',
'wizard/calendar_event_export_view.xml',
'wizard/calendar_event_import_view.xml',
'wizard/calendar_event_subscribe_view.xml',
'caldav_view.xml'
],
"installable" : True,
+3 -1
View File
@@ -207,6 +207,7 @@ class CalDAV(object):
def create_ics(self, cr, uid, datas, name, ical, context=None):
if not datas:
return
timezones = []
for data in datas:
tzval = None
vevent = ical.add(name)
@@ -246,11 +247,12 @@ class CalDAV(object):
alarm_obj = self.pool.get('basic.calendar.alarm')
vevent = alarm_obj.export_cal(cr, uid, model, \
data[map_field][0], vevent, context=ctx)
elif field == 'vtimezone' and data[map_field]:
elif field == 'vtimezone' and data[map_field] and data[map_field] not in timezones:
tzval = data[map_field]
tz_obj = self.pool.get('basic.calendar.timezone')
ical = tz_obj.export_cal(cr, uid, None, \
data[map_field], ical, context=context)
timezones.append(data[map_field])
elif data[map_field]:
if map_type in ("char", "text"):
if field in ('exdate'):
-19
View File
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard string="Import .ics File" model="basic.calendar"
name="calendar.event.import" id="wizard_cal_event_import" />
<wizard string="Subscribe"
model="basic.calendar" name="calendar.event.subscribe"
id="wizard_cal_event_subscribe" multi="True" />
<wizard string="Export .ics File" model="basic.calendar"
name="calendar.event.export" id="wizard_cal_event_export" />
<wizard string="Edit this event" model="basic.calendar.event"
name="calendar.event.edit.this" id="wizard_edit_this_event"
menu="False" />
</data>
</openerp>
+3 -4
View File
@@ -19,9 +19,8 @@
#
##############################################################################
import wizard_cal_export
import wizard_cal_import
import wizard_cal_subscribe
import calendar_event_export
import calendar_event_import
import calendar_event_subscribe
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
import base64
class calendar_event_export(osv.osv_memory):
"""
Export Calendar Event.
"""
def _process_export_ics(self, cr, uid, context):
"""
Get Default value for file_path field.
"""
model = context.get('model', 'basic.calendar')
model_obj = self.pool.get(model)
calendar = model_obj.export_cal(cr, uid, context['active_ids'], context)
#TODO: check why returns wrong value
return base64.encodestring(calendar)
def _process_export_ics_name(self, cr, uid, context):
"""
Get Default value for Name field.
"""
model = context.get('model', 'basic.calendar')
model_obj = self.pool.get(model)
calendar = model_obj.export_cal(cr, uid, context['active_ids'], context)
return 'OpenERP %s.ics' % (model_obj._description)
_name = "calendar.event.export"
_description = "Event Export"
_columns = {
'file_path':fields.binary('Save ICS file', filters='*.ics', required=True),
'name':fields.char('File name', size=34, required=True, help='Save in .ics format')
}
_defaults={
'name':_process_export_ics_name,
'file_path':_process_export_ics
}
calendar_event_export()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_calendar_event_export" model="ir.ui.view">
<field name="name">calendar.event.export.form</field>
<field name="model">calendar.event.export</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Export ICS">
<group colspan="4" >
<field name="name"/>
<field name="file_path" colspan="4" width="300"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
</group>
</form>
</field>
</record>
<record id="action_calendar_event_export" model="ir.actions.act_window">
<field name="name">Export .ics File</field>
<field name="res_model">calendar.event.export</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_calendar_event_export"/>
<field name="target">new</field>
<field name="context">{'record_id':active_id}</field>
</record>
<!-- <record id="action_calendar_event_export_values" model="ir.values">-->
<!-- <field name="model_id" ref="caldav.model_basic_calendar" />-->
<!-- <field name="object" eval="1" />-->
<!-- <field name="name">Export .ics File</field>-->
<!-- <field name="key2">client_action_multi</field>-->
<!-- <field name="value" eval="'ir.actions.act_window,' + str(ref('action_calendar_event_export'))"/>-->
<!-- <field name="key">action</field> -->
<!-- <field name="model">basic.calendar</field>-->
<!-- </record>-->
<act_window id="action_calendar_event_export_values"
key2="client_action_multi" name="Export .ics File"
res_model="calendar.event.export" src_model="basic.calendar"
view_mode="form" target="new" view_type="form" />
</data>
</openerp>
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
import base64
class calendar_event_import(osv.osv_memory):
"""
Import Calendar Event.
"""
cnt = 0
def _process_imp_ics(self, cr, uid, ids, context=None):
"""
Process Import ics File.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of calendar event import’s IDs
@return: dictionary of calendar evet import window with Import successful msg.
"""
for data in self.read(cr, uid, ids):
model = data.get('model', 'basic.calendar')
model_obj = self.pool.get(model)
context.update({'model': model})
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'caldav', 'view_calendar_event_import_display')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
vals = model_obj.import_cal(cr, uid, data['file_path'], context['active_id'], context)
global cnt
if vals:
cnt = len(vals)
value = {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'calendar.event.import',
'views': [(id2,'form'),(False,'tree'),(False,'calendar'),(False,'graph')],
'type': 'ir.actions.act_window',
'target': 'new'
}
return value
_name = "calendar.event.import"
_description = "Event Import"
_columns = {
'file_path': fields.binary('Select ICS file', filters='*.ics', required=True),
'msg': fields.text('', readonly=True),
}
_defaults={
'msg':lambda *a:'Import Sucessful'
}
calendar_event_import()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_calendar_event_import" model="ir.ui.view">
<field name="name">calendar.event.import.form</field>
<field name="model">calendar.event.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import ICS">
<group colspan="4" >
<separator string="Select ICS file"/>
<field name="file_path" colspan="4" width="300" nolabel="1"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
<button icon="gtk-ok" name="_process_imp_ics" string="_Import" type="object"/>
</group>
</form>
</field>
</record>
<record id="view_calendar_event_import_display" model="ir.ui.view">
<field name="name">calendar.event.import.form.display</field>
<field name="model">calendar.event.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Message">
<group colspan="4" >
<field name="msg" colspan="4" width="300" nolabel="1"/>
</group>
<separator string="" colspan="4" />
<group colspan="4">
<button icon="gtk-ok" special="cancel" string="Ok"/>
</group>
</form>
</field>
</record>
<record id="action_calendar_event_import" model="ir.actions.act_window">
<field name="name">Import .ics File</field>
<field name="res_model">calendar.event.import</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_calendar_event_import"/>
<field name="target">new</field>
<field name="context">{'record_id':active_id}</field>
</record>
<record id="action_calendar_event_import_values" model="ir.values">
<field name="model_id" ref="caldav.model_basic_calendar" />
<field name="object" eval="1" />
<field name="name">Import .ics File</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_calendar_event_import'))"/>
<field name="key">action</field>
<field name="model">basic.calendar</field>
</record>
</data>
</openerp>
@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
import netsvc
import pooler
import time
import tools
import wizard
import base64
import urllib
class calendar_event_subscribe(osv.osv_memory):
"""
Subscribe Calendar Event.
"""
cnt = 0
def _process_imp_ics(self, cr, uid, ids, context=None):
"""
process ics file.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of calendar event subscribe’s IDs
@return: dictionary of calendar evet subscribe window with Import successful msg.
"""
global cnt
for data in self.read(cr, uid, ids):
try:
f = urllib.urlopen(data['url_path'])
caldata = f.fp.read()
f.close()
except Exception,e:
raise osv.except_osv(_('Error!'), _('Please provide Proper URL !'))
model = data.get('model', 'basic.calendar')
model_obj = self.pool.get(model)
context.update({'url': data['url_path'],
'model': data.get('model', 'basic.calendar')})
vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), \
context['active_id'], context)
if vals:
cnt = vals['count']
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'caldav', 'view_calendar_event_subscribe_display')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
value = {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'calendar.event.subscribe',
'views': [(id2,'form'),(False,'tree'),(False,'calendar'),(False,'graph')],
'type': 'ir.actions.act_window',
'target': 'new'
}
return value
_name = "calendar.event.subscribe"
_description = "Event subscribe"
_columns = {
'url_path': fields.char('Provide path for remote calendar', size=124, required=True),
'msg': fields.text('', readonly=True),
}
_defaults={
'msg':lambda *a:'Import Sucessful.'
}
calendar_event_subscribe()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_calendar_event_subscribe" model="ir.ui.view">
<field name="name">calendar.event.subscribe.form</field>
<field name="model">calendar.event.subscribe</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Subscribe to Remote Calendar">
<group colspan="4" >
<separator string="Provide path for Remote Calendar"/>
<field name="url_path" colspan="4" width="300" nolabel="1" widget="url"/>
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
<button icon="gtk-ok" name="_process_imp_ics" string="_Subscribe" type="object"/>
</group>
</form>
</field>
</record>
<record id="view_calendar_event_subscribe_display" model="ir.ui.view">
<field name="name">calendar.event.subscribe.form.display</field>
<field name="model">calendar.event.subscribe</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Message...">
<group colspan="4" >
<field name="msg" colspan="4" width="300" nolabel="1"/>
</group>
<separator string="" colspan="4" />
<group colspan="4">
<button icon="gtk-ok" special="cancel" string="Ok"/>
</group>
</form>
</field>
</record>
<record id="action_calendar_event_subscribe" model="ir.actions.act_window">
<field name="name">Subscribe</field>
<field name="res_model">calendar.event.subscribe</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_calendar_event_subscribe"/>
<field name="target">new</field>
<field name="context">{'record_id':active_id}</field>
</record>
<record id="action_calendar_event_subscribe_values" model="ir.values">
<field name="model_id" ref="caldav.model_basic_calendar" />
<field name="object" eval="1" />
<field name="name">Subscribe</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_calendar_event_subscribe'))"/>
<field name="key">action</field>
<field name="model">basic.calendar</field>
</record>
</data>
</openerp>
-65
View File
@@ -1,65 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import base64
import pooler
class cal_event_export_wizard(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="Export ICS">
<field name="name"/>
<field name="file_path" colspan="4" width="300"/>
</form>'''
form1_fields = {
'file_path': {
'string': 'Save ICS file',
'type': 'binary',
'required': True,
'filters': '*.ics'
},
'name': {
'string': 'File name',
'type': 'char',
'size': 34,
'required': True,
'help': 'Save in .ics format'},
}
def _process_export_ics(self, cr, uid, data, context):
model = data.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
calendar = model_obj.export_cal(cr, uid, data['ids'], context)
return {'file_path': base64.encodestring(calendar), \
'name': 'OpenERP %s.ics' % (model_obj._description)}
states = {
'init': {
'actions': [_process_export_ics],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, \
'state': [('end', '_Cancel', 'gtk-cancel')]}},
}
cal_event_export_wizard('calendar.event.export')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-88
View File
@@ -1,88 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
class cal_event_import_wizard(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="Import ICS">
<separator string="Select ICS file"/>
<field name="file_path" colspan="4" width="300" nolabel="1"/>
</form>'''
form1_fields = {
'file_path': {
'string': 'Select ICS file',
'type': 'binary',
'required': True,
'filters': '*.ics'
}
}
display = '''<?xml version="1.0"?>
<form string="Import Message">
<field name="msg" colspan="4" width="300" nolabel="1"/>
</form>'''
display_fields = {
'msg': {
'string': '',
'type': 'text',
'readonly': True,
}
}
def _process_imp_ics(self, cr, uid, data, context=None):
model = data.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
context.update({'model': model})
vals = model_obj.import_cal(cr, uid, data['form']['file_path'], data['id'], context)
global cnt
cnt = 0
if vals:
cnt = len(vals)
return {}
def _result_set(self, cr, uid, data, context=None):
msg = (cnt and "Imported %s components" % cnt) or 'Import Sucessful'
return {'msg': msg}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \
'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Import', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _process_imp_ics, 'state': 'display'}
},
'display': {
'actions': [_result_set],
'result': {'type': 'form', 'arch': display, 'fields': display_fields, \
'state': [('end', 'Ok', 'gtk-ok')]}
},
}
cal_event_import_wizard('calendar.event.import')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,97 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from tools.translate import _
import base64
import pooler
import urllib
import wizard
class cal_event_subscribe_wizard(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="Subscribe to Remote Calendar">
<separator string="Provide path for Remote Calendar"/>
<field name="url_path" colspan="4" width="300" nolabel="1" widget="url"/>
</form>'''
form1_fields = {
'url_path': {
'string': 'Provide path for remote calendar',
'type': 'char',
'required': True,
'size': 124
}
}
display = '''<?xml version="1.0"?>
<form string="Message...">
<field name="msg" colspan="4" width="300" nolabel="1"/>
</form>'''
display_fields = {
'msg': {
'string': '',
'type': 'text',
'readonly': True,
}
}
def _process_imp_ics(self, cr, uid, data, context=None):
global cnt
cnt = 0
try:
f = urllib.urlopen(data['form']['url_path'])
caldata = f.fp.read()
f.close()
except Exception,e:
raise wizard.except_wizard(_('Error!'), _('Please provide Proper URL !'))
model = data.get('model')
model_obj = pooler.get_pool(cr.dbname).get(model)
context.update({'url': data['form']['url_path'],
'model': data.get('model')})
vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), \
data['id'], context)
if vals:
cnt = vals['count']
return {}
def _result_set(self, cr, uid, data, context=None):
return {'msg': 'Import Sucessful.'}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \
'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Subscribe', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _process_imp_ics, 'state': 'display'}
},
'display': {
'actions': [_result_set],
'result': {'type': 'form', 'arch': display, 'fields': display_fields, \
'state': [('end', 'Ok', 'gtk-ok')]}
},
}
cal_event_subscribe_wizard('calendar.event.subscribe')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+11 -5
View File
@@ -61,19 +61,25 @@ between mails and Open ERP.""",
],
'update_xml': [
'wizard/crm_lead_to_partner_view.xml',
'wizard/crm_lead_to_opportunity_view.xml',
'wizard/crm_phonecall2phonecall.xml',
'wizard/phonecall2meeting.xml',
'wizard/phonecall2partner_view.xml',
'wizard/phonecall2opportunity.xml',
'wizard/crm_opportunity_to_meeting_view.xml',
'wizard/crm_opportunity_to_phonecall_view.xml',
'crm_wizard.xml',
'crm_view.xml',
'crm_view.xml',
'crm_action_rule_view.xml',
'crm_lead_wizard.xml',
'crm_lead_view.xml',
'crm_lead_menu.xml',
'crm_meeting_wizard.xml',
'crm_meeting_view.xml',
'crm_meeting_menu.xml',
'crm_phonecall_wizard.xml',
#'crm_phonecall_wizard.xml',
'crm_phonecall_view.xml',
'crm_phonecall_menu.xml',
'crm_opportunity_wizard.xml',
'crm_opportunity_view.xml',
'crm_opportunity_menu.xml',
'crm_fund_view.xml',
+6 -9
View File
@@ -19,14 +19,6 @@
#
##############################################################################
import time
import re
import os
import base64
import tools
import mx.DateTime
import datetime
from datetime import datetime
from datetime import timedelta
from osv import fields
@@ -34,7 +26,12 @@ from osv import orm
from osv import osv
from osv.orm import except_orm
from tools.translate import _
import base64
import mx.DateTime
import os
import re
import time
import tools
MAX_LEVEL = 15
+54 -13
View File
@@ -19,28 +19,69 @@
#
##############################################################################
from osv import fields,osv,orm
from osv import fields, osv, orm
from datetime import datetime, timedelta
import crm
import math
class crm_lead(osv.osv):
_name = "crm.lead"
_description = "Leads Cases"
_order = "priority desc, id desc"
_inherit = ['res.partner.address','crm.case']
_inherit = ['res.partner.address', 'crm.case']
def _compute_openday(self, cr, uid, ids, name, args, context={}):
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'crm.lead')])
log_obj = self.pool.get('crm.case.log')
hist_id = log_obj.search(cr, uid, [('model_id', '=', model_id[0]), \
('res_id', '=', r.id), \
('name', '=', 'Open')])
if hist_id:
# Considering last log for opening case
log = log_obj.browse(cr, uid, hist_id[-1])
date_lead_open = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_log_open = datetime.strptime(log.date, "%Y-%m-%d %H:%M:%S")
ans = date_lead_open - date_log_open
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
def _compute_closeday(self, cr, uid, ids, name, args, context={}):
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
if r.date_closed:
date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Lead Name", size=64),
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Lead Name", size=64),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity'),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'stage_id': fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity'),
'user_id': fields.many2one('res.users', 'Salesman'),
'referred': fields.char('Referred By', size=32),
'day_open': fields.function(_compute_openday, string='Days to Open', \
method=True, type="integer", store=True),
'day_close': fields.function(_compute_closeday, string='Days to Close', \
method=True, type="integer", store=True),
}
'user_id': fields.many2one('res.users', 'Salesman'),
'referred': fields.char('Referred By', size=32),
}
_defaults = {
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
}
crm_lead()
+8 -3
View File
@@ -46,7 +46,7 @@
<field name="priority"/>
<field name="date_deadline"/>
<button
name="%(wizard_crm_lead_opportunity_set)d"
name="%(action_crm_lead2opportunity)d"
string="Convert"
help="Convert into Opportunity"
icon="gtk-index"
@@ -90,7 +90,7 @@
<separator string="Links" colspan="4" col="3"/>
<field name="partner_id"/>
<button
name="%(wizard_crm_lead_partner_create)d"
name="%(action_crm_lead2partner)d"
icon="gtk-index" type="action"
string="Create"
attrs="{'invisible':[('partner_id','!=',False)]}"/>
@@ -155,6 +155,11 @@
<field name="write_date"/>
<field name="date_closed"/>
</group>
<group colspan="2" col="2">
<separator string="Statistics" colspan="2" col="2"/>
<field name="day_open"/>
<field name="day_close"/>
</group>
</page>
</notebook>
</form>
@@ -185,7 +190,7 @@
<field name="state"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Close" states="open,draft,pending" type="object" icon="gtk-close"/>
<button string="Convert to Opportunity" name="%(wizard_crm_lead_opportunity_set)d" states="draft,open,pending" icon="gtk-index" type="action"/>
<button string="Convert to Opportunity" name="%(action_crm_lead2opportunity)d" states="draft,open,pending" icon="gtk-index" type="action"/>
<button name="case_escalate" string="Escalate" states="open,draft,pending" type="object" icon="gtk-go-up"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
</tree>
-21
View File
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
id="wizard_crm_lead_partner_create"
keyword="client_action_multi"
model="crm.lead"
name="crm.lead.partner_create"
multi="True"
string="Create Partner"/>
<wizard
id="wizard_crm_lead_opportunity_set"
keyword="client_action_multi"
model="crm.lead"
name="crm.lead.opportunity_set"
multi="True"
string="Convert To Opportunity"/>
</data>
</openerp>
+1 -1
View File
@@ -38,7 +38,7 @@
<field name="rrule_type" string="Recurrency"
colspan="1" attrs="{'readonly':[('recurrent_uid','!=',False)]}"/>
<button string="Edit All" help="Edit all Ourrences of recurrent Meeting" attrs="{'invisible':[('rrule_type','in', ('none', False))]}"
name="%(wizard_edit_all_events)d" icon="gtk-edit"
name="%(base_calendar.action_calendar_event_edit_all)d" icon="gtk-edit"
type="action" context="{'model' : 'crm.meeting', 'date': date, 'date_deadline': date_deadline}" />
</group>
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard string="Edit all events" model="crm.meeting"
name="calendar.event.edit.all" id="wizard_edit_all_events"
menu="False" />
</data>
</openerp>
+44 -4
View File
@@ -19,6 +19,7 @@
#
##############################################################################
from datetime import datetime
from osv import fields,osv,orm
import crm
@@ -35,6 +36,39 @@ class crm_opportunity(osv.osv):
_description = "Opportunity Cases"
_order = "id desc"
_inherit = 'crm.case'
def _compute_openday(self, cr, uid, ids, name, args, context={}):
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'crm.opportunity')])
log_obj = self.pool.get('crm.case.log')
hist_id = log_obj.search(cr, uid, [('model_id', '=', model_id[0]), \
('res_id', '=', r.id), \
('name', '=', 'Open')])
if hist_id:
# Considering last log for opening case
log = log_obj.browse(cr, uid, hist_id[-1])
date_lead_open = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_log_open = datetime.strptime(log.date, "%Y-%m-%d %H:%M:%S")
ans = date_lead_open - date_log_open
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
def _compute_closeday(self, cr, uid, ids, name, args, context={}):
result = {}
for r in self.browse(cr, uid, ids , context):
result[r.id] = 0
if r.date_closed:
date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
ans = date_close - date_create
duration = float(ans.days) + (float(ans.seconds) / 86400)
result[r.id] = abs(int(duration))
return result
_columns = {
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
@@ -52,7 +86,13 @@ class crm_opportunity(osv.osv):
\nIf the case is in progress the state is set to \'Open\'.\
\nWhen the case is over, the state is set to \'Done\'.\
\nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
}
'day_open': fields.function(_compute_openday, string='Days to Open', \
method=True, type="integer", store=True),
'day_close': fields.function(_compute_closeday, string='Days to Close', \
method=True, type="integer", store=True),
}
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
if not stage_id:
return {'value':{}}
@@ -64,16 +104,16 @@ class crm_opportunity(osv.osv):
def stage_next(self, cr, uid, ids, context={}):
res = super(crm_opportunity, self).stage_next(cr, uid, ids, context=context)
for case in self.browse(cr, uid, ids, context):
if case.stage_id and case.stage_id.on_change:
if case.stage_id and case.stage_id.on_change:
self.write(cr, uid, [case.id], {'probability': case.stage_id.probability})
return res
def stage_previous(self, cr, uid, ids, context={}):
res = super(crm_opportunity, self).stage_previous(cr, uid, ids, context=context)
for case in self.browse(cr, uid, ids, context):
if case.stage_id and case.stage_id.on_change:
if case.stage_id and case.stage_id.on_change:
self.write(cr, uid, [case.id], {'probability': case.stage_id.probability})
return res
return res
_defaults = {
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.opportunity', context=c),
+3 -3
View File
@@ -8,9 +8,9 @@
name="Meetings"
res_model="crm.meeting"
src_model="crm.opportunity"
view_mode="calendar,tree,form"
context="{'default_duration': 4.0}"
domain="[('user_id','=',uid)]"
view_mode="tree,form,calendar,"
context="{'default_duration': 4.0, 'default_opportunity_id': active_id}"
domain="[('user_id','=',uid), ('opportunity_id', '=', active_id)]"
view_type="form"/>
<act_window
+6 -4
View File
@@ -63,17 +63,17 @@
</group>
<field name="user_id"/>
<button string="Schedule Meeting"
name="%(wizard_crm_opportunity_meeting_set)d" icon="gtk-redo" type="action" />
name="%(opportunity2meeting_act)d" icon="gtk-redo" type="action" />
<field name="planned_revenue"/>
<field name="probability"/>
<field name="date_deadline" string="Expected Closing"/>
<button string="Schedule Call"
name="%(wizard_crm_opportunity_reschedule_phone_call)d" icon="gtk-redo" type="action" />
name="%(opportunity2phonecall_act)d" icon="gtk-redo" type="action" />
</group>
<notebook colspan="4">
<page string="Opportunity">
<group col="2" colspan="2">
<separator colspan="2" string="Contacts"/>
<group col="3" colspan="2">
<separator colspan="3" string="Contacts"/>
<field name="partner_id" select="1" on_change="onchange_partner_id(partner_id, email_from)" colspan="2"/>
<field name="partner_address_id" string="Contact" on_change="onchange_partner_address_id(partner_address_id, email_from)" colspan="1"/>
<field name="email_from" string="Email"/>
@@ -112,6 +112,8 @@
<group col="2" colspan="2">
<separator string="Misc" colspan="2"/>
<field name="active"/>
<field name="day_open"/>
<field name="day_close"/>
</group>
<separator colspan="4" string="References"/>
<field name="ref"/>
+1 -23
View File
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
id="wizard_crm_opportunity_reschedule_phone_call"
keyword="client_action_multi"
model="crm.opportunity"
name="crm.opportunity.reschedule_phone_call"
multi="True"
string="Schedule Phone Call" />
<wizard
id="wizard_partner_create_opportunity"
keyword="client_action_multi"
@@ -16,20 +8,6 @@
name="crm.case.opportunity.partner_opportunity"
menu="False"
string="Create Opportunity"/>
<wizard
id="wizard_crm_opportunity_meeting_set"
keyword="client_action_multi"
model="crm.opportunity"
name="crm.opportunity.meeting_set"
menu="False"
string="Schedule Meeting"/>
<wizard
id="wizard_partner_create_opportunity1"
keyword="client_action_relate"
model="res.partner"
name="crm.case.opportunity.partner_opportunity"
string="Create Opportunity"/>
</data>
</openerp>
+11 -8
View File
@@ -49,12 +49,12 @@
<field name="partner_phone"/>
<field name="user_id"/>
<button string="Opportunity"
name="%(wizard_crm_phonecall_opportunity_set)d"
name="%(phonecall2opportunity_act)d"
states="draft,open,pending"
type="action" attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<button string="Meeting"
states="draft,open,pending"
name="%(wizard_crm_phonecall_meeting_set)d" type="action" />
name="%(phonecall2meeting_act)d" type="action" />
<field name="state"/>
<button name="case_open" string="Open" states="draft,pending" type="object" icon="gtk-go-forward"/>
<button name="case_close" string="Held" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
@@ -75,26 +75,29 @@
<field name="date" string="Planned Date"/>
<field name="user_id"/>
<button string="Schedule a Meeting"
name="%(wizard_crm_phonecall_meeting_set)d"
name="%(phonecall2meeting_act)d"
icon="gtk-redo"
type="action" />
<newline/>
<field name="partner_phone"/>
<field name="duration"/>
<field name="section_id" colspan="1" widget="selection" />
<button string="Convert to Opportunity"
name="%(wizard_crm_phonecall_opportunity_set)d"
name="%(phonecall2opportunity_act)d"
icon="gtk-index" type="action"
attrs="{'invisible':[('opportunity_id','!=',False)]}" />
<label colspan="6" string=""/>
<button string="Schedule Call Other"
icon="gtk-redo"
name="%(phonecall_to_phonecall_act)d"
type="action" />
</group>
<group col="3" colspan="2">
<separator colspan="3" string="Contacts" />
<field name="partner_id" />
<button string="Create a Partner"
icon="terp-crm"
name="%(wizard_crm_phonecall_partner_create)d"
name="%(action_crm_phonecall2partner)d"
type="action"
attrs="{'invisible':[('partner_id','!=',False)]}" />
<newline/>
+2 -1
View File
@@ -14,7 +14,8 @@ class crm_opportunity_report(osv.osv):
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'stage_id':fields.many2one('crm.case.stage', 'Stage', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]", readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner',readonly=True),
'company_id': fields.many2one('res.company', 'Company',readonly=True),
'company_id': fields.many2one('res.company', 'Company',readonly=True),
'user_id':fields.many2one('res.users', 'User', readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'crm_opportunity_report')
@@ -29,7 +29,6 @@ import os
import binascii
import time, socket
email_re = re.compile(r"""
([a-zA-Z][\w\.-]*[a-zA-Z0-9] # username part
@ # mandatory @ sign
@@ -186,8 +185,8 @@ class email_parser(object):
try:
id = self.rpc(self.model, 'create', data)
self.rpc(self.model, 'history', [id], 'Receive', True, msg['From'], message['body'])
#self.rpc(self.model, 'case_open', [id])
self.rpc(self.model, 'history', [id], 'send', False, msg['From'], message['body'])
self.rpc(self.model, 'case_open', [id])
except Exception, e:
if getattr(e, 'faultCode', '') and 'AccessError' in e.faultCode:
e = '\n\nThe Specified user does not have an access to the CRM case.'
@@ -302,7 +301,7 @@ class email_parser(object):
self.rpc(self.model, act, [id])
self.rpc(self.model, 'write', [id], data)
self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body'])
self.rpc(self.model, 'history', [id], 'send', False, msg['From'], message['body'])
return id
def msg_send(self, msg, emails, priority=None):
@@ -334,7 +333,7 @@ class email_parser(object):
'description':body,
}
self.rpc(self.model, 'write', [id], data)
self.rpc(self.model, 'history', [id], 'Send', True, msg['From'], message['body'])
self.rpc(self.model, 'history', [id], 'send', False, msg['From'], message['body'])
return id
def msg_test(self, msg, case_str):
+11 -2
View File
@@ -19,14 +19,23 @@
#
##############################################################################
import crm_opportunity_wizard
import crm_lead_wizard
import crm_phonecall_wizard
import wizard_crm_send_email
import wizard_crm_new_send_email
import wizard_history_event
import crm_lead_to_partner
import crm_lead_to_opportunity
import crm_opportunity_to_meeting
import crm_opportunity_to_phonecall
import crm_phonecall2phonecall
import phonecall2partner
import phonecall2meeting
import phonecall_to_opportunity
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,144 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from tools.translate import _
class crm_lead2opportunity(osv.osv_memory):
_name = 'crm.lead2opportunity'
_description = 'Lead To Opportunity'
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Lead To Opportunity form
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Lead to Partner's IDs
@param context: A standard dictionary for contextual values
"""
return {'type': 'ir.actions.act_window_close'}
def action_apply(self, cr, uid, ids, context=None):
"""
This converts lead to opportunity and opens Opportunity view
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Lead to Opportunity IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Opportunity form
"""
value = {}
record_ids = context and context.get('active_ids', []) or []
if record_ids:
lead_obj = self.pool.get('crm.lead')
opp_obj = self. pool.get('crm.opportunity')
data_obj = self.pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_oppor')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_oppor')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
for this in self.browse(cr, uid, ids, context=context):
for case in lead_obj.browse(cr, uid, record_ids, context=context):
new_opportunity_id = opp_obj.create(cr, uid, {
'name': this.name,
'planned_revenue': this.planned_revenue,
'probability': this.probability,
'partner_id': case.partner_id and case.partner_id.id or False ,
'section_id': case.section_id and case.section_id.id or False,
'description': case.description or False,
'date_deadline': case.date_deadline or False,
'partner_address_id': case.partner_address_id and \
case.partner_address_id.id or False ,
'priority': case.priority,
'phone': case.phone,
'email_from': case.email_from
})
new_opportunity = opp_obj.browse(cr, uid, new_opportunity_id)
vals = {
'partner_id': this.partner_id and this.partner_id.id or False,
}
if not case.opportunity_id:
vals.update({'opportunity_id' : new_opportunity.id})
lead_obj.write(cr, uid, [case.id], vals)
lead_obj.case_close(cr, uid, [case.id])
opp_obj.case_open(cr, uid, [new_opportunity_id])
value = {
'name': _('Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.opportunity',
'res_id': int(new_opportunity_id),
'view_id': False,
'views': [(id2, 'form'), (id3, 'tree'), (False, 'calendar'), (False, 'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
_columns = {
'name' : fields.char('Opportunity Summary', size=64, required=True, select=1),
'probability': fields.float('Success Probability'),
'planned_revenue': fields.float('Expected Revenue'),
'partner_id': fields.many2one('res.partner', 'Partner'),
}
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
lead_obj = self.pool.get('crm.lead')
res = super(crm_lead2opportunity, self).default_get(cr, uid, fields, context=context)
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])):
if lead.state in ['done', 'cancel']:
raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
Leads Could not convert into Opportunity"))
if lead.state != 'open':
raise osv.except_osv(_('Warning !'), _('Lead should be in \
\'Open\' state before converting to Opportunity.'))
res['name'] = lead.partner_name
res['partner_id'] = lead.partner_id and lead.partner_id.id or False
return res
crm_lead2opportunity()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,37 @@
<openerp>
<data>
<!-- Lead to Opportunity view -->
<record id="view_crm_lead2opportunity_create" model="ir.ui.view">
<field name="name">crm.lead2opportunity.create</field>
<field name="model">crm.lead2opportunity</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Convert To Opportunity">
<field name="name"/>
<field name="partner_id"/>
<newline/>
<field name="planned_revenue"/>
<field name="probability"/>
<group col="4" colspan="4">
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="action_apply" string="Create Opportunity" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<!-- Lead to Opportunity action -->
<record id="action_crm_lead2opportunity" model="ir.actions.act_window">
<field name="name">Create Opportunity</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">crm.lead2opportunity</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
+201
View File
@@ -0,0 +1,201 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
from tools.translate import _
class crm_lead2partner(osv.osv_memory):
""" Converts lead to partner """
_name = 'crm.lead2partner'
_description = 'Lead to Partner'
_columns = {
'action': fields.selection([('exist', 'Link to an existing partner'), \
('create', 'Create a new partner')], \
'Action', required=True),
'partner_id': fields.many2one('res.partner', 'Partner')
}
def _select_partner(self, cr, uid, context=None):
"""
This function Searches for Partner from selected lead.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : Partner id if any for selected lead.
"""
if not context:
context = {}
lead_obj = self.pool.get('crm.lead')
partner_obj = self.pool.get('res.partner')
contact_obj = self.pool.get('res.partner.address')
rec_ids = context and context.get('active_ids', [])
value={}
for lead in lead_obj.browse(cr, uid, rec_ids, context=context):
if lead.partner_id:
raise osv.except_osv(_('Warning !'),
_('A partner is already defined on this lead.'))
partner_ids = partner_obj.search(cr, uid, [('name', '=', lead.partner_name or lead.name)])
if not partner_ids and lead.email_from:
address_ids = contact_obj.search(cr, uid, [('email', '=', lead.email_from)])
if address_ids:
addresses = contact_obj.browse(cr, uid, address_ids)
partner_ids = addresses and [addresses[0].partner_id.id] or False
partner_id = partner_ids and partner_ids[0] or False
return partner_id
_defaults = {
'action': lambda *a:'exist',
'partner_id': _select_partner
}
def open_create_partner(self, cr, uid, ids, context=None):
"""
This function Opens form of create partner.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Lead to Partner's IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for next form.
"""
if not context:
context = {}
view_obj = self.pool.get('ir.ui.view')
view_id = view_obj.search(cr, uid, [('model', '=', 'crm.lead2partner'), \
('name', '=', 'crm.lead2partner.view')])
return {
'view_mode': 'form',
'view_type': 'form',
'view_id': view_id or False,
'res_model': 'crm.lead2partner',
'context': context,
'type': 'ir.actions.act_window',
'target': 'new',
}
def _create_partner(self, cr, uid, ids, context=None):
"""
This function Creates partner based on action.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Lead to Partner's IDs
@param context: A standard dictionary for contextual values
@return : Dictionary {}.
"""
if not context:
context = {}
lead_obj = self.pool.get('crm.lead')
partner_obj = self.pool.get('res.partner')
contact_obj = self.pool.get('res.partner.address')
partner_ids = []
partner_id = False
contact_id = False
rec_ids = context and context.get('active_ids', [])
for data in self.browse(cr, uid, ids):
for lead in lead_obj.browse(cr, uid, rec_ids):
if data.action == 'create':
partner_id = partner_obj.create(cr, uid, {
'name': lead.partner_name or lead.name,
'user_id': lead.user_id.id,
'comment': lead.description,
})
contact_id = contact_obj.create(cr, uid, {
'partner_id': partner_id,
'name': lead.name,
'phone': lead.phone,
'mobile': lead.mobile,
'email': lead.email_from,
'fax': lead.fax,
'title': lead.title,
'function': lead.function and lead.function.id or False,
'street': lead.street,
'street2': lead.street2,
'zip': lead.zip,
'city': lead.city,
'country_id': lead.country_id and lead.country_id.id or False,
'state_id': lead.state_id and lead.state_id.id or False,
})
else:
if data.partner_id:
partner_id = data.partner_id.id
contact_id = partner_obj.address_get(cr, uid, [partner_id])['default']
partner_ids.append(partner_id)
vals = {}
if partner_id:
vals.update({'partner_id': partner_id})
if contact_id:
vals.update({'partner_address_id': contact_id})
lead_obj.write(cr, uid, [lead.id], vals)
return partner_ids
def make_partner(self, cr, uid, ids, context=None):
"""
This function Makes partner based on action.
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Lead to Partner's IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Partner form.
"""
if not context:
context = {}
partner_ids = self._create_partner(cr, uid, ids, context)
mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
value = {
'domain': "[]",
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'res.partner',
'res_id': partner_ids and int(partner_ids[0]) or False,
'view_id': False,
'context': context,
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
crm_lead2partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,51 @@
<openerp>
<data>
<!-- Lead to partner confirmation form -->
<record id="view_crm_lead2partner_create" model="ir.ui.view">
<field name="name">crm.lead2partner.view.create</field>
<field name="model">crm.lead2partner</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create a Partner?">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<group col="4" colspan="4">
<button special="cancel" string="_Cancel" icon="gtk-cancel"/>
<button name="open_create_partner" string="Create _Partner" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<!-- Lead to Partner form view -->
<record id="view_crm_lead2partner" model="ir.ui.view">
<field name="name">crm.lead2partner.view</field>
<field name="model">crm.lead2partner</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create a Partner">
<field name="action"/>
<group attrs="{'invisible':[('action','!=','exist')]}">
<field name="partner_id" attrs="{'required': [('action', '=', 'exist')]}"/>
</group>
<group col="4" colspan="4">
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="make_partner" string="Continue" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<!-- Lead to Partner wizard -->
<act_window id="action_crm_lead2partner"
key2="client_action_multi" name="Create a Partner"
res_model="crm.lead2partner" src_model="crm.lead"
view_id="view_crm_lead2partner_create"
view_mode="form" target="new" view_type="form" />
</data>
</openerp>
-297
View File
@@ -1,297 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from mx.DateTime import now
import wizard
import netsvc
import ir
import pooler
from tools.translate import _
class partner_create(wizard.interface):
case_form = """<?xml version="1.0"?>
<form string="Create a Partner">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<!--field name="close"/-->
</form>"""
case_fields = {
'close': {'type':'boolean', 'string':'Close Lead'}
}
partner_form = """<?xml version="1.0"?>
<form string="Create a Partner">
<label string="Are you sure you want to create a partner based on this lead ?" colspan="4"/>
<label string="You may have to verify that this partner does not exist already." colspan="4"/>
<newline />
<field name="action"/>
<group attrs="{'invisible':[('action','!=','exist')]}">
<field name="partner_id"/>
</group>
</form>"""
partner_fields = {
'action': {'type':'selection',
'selection':[('exist','Link to an existing partner'),('create','Create a new partner')],
'string':'Action', 'required':True, 'default': lambda *a:'exist'},
'partner_id' : {'type':'many2one', 'relation':'res.partner', 'string':'Partner'},
}
def _selectPartner(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
case_obj = pool.get('crm.lead')
partner_obj = pool.get('res.partner')
contact_obj = pool.get('res.partner.address')
for case in case_obj.browse(cr, uid, data['ids']):
if case.partner_id:
raise wizard.except_wizard(_('Warning !'),
_('A partner is already defined on this lead.'))
partner_ids = partner_obj.search(cr, uid, [('name', '=', case.partner_name or case.name)])
if not partner_ids and case.email_from:
address_ids = contact_obj.search(cr, uid, [('email', '=', case.email_from)])
if address_ids:
addresses = contact_obj.browse(cr, uid, address_ids)
partner_ids = addresses and [addresses[0].partner_id.id] or False
partner_id = partner_ids and partner_ids[0] or False
vals = {'partner_id': partner_id}
if not partner_id:
vals['action'] = 'create'
return vals
def _create_partner(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
case_obj = pool.get('crm.lead')
partner_obj = pool.get('res.partner')
contact_obj = pool.get('res.partner.address')
partner_ids = []
partner_id = False
contact_id = False
for case in case_obj.browse(cr, uid, data['ids']):
if data['form']['action'] == 'create':
partner_id = partner_obj.create(cr, uid, {
'name': case.partner_name or case.name,
'user_id': case.user_id.id,
'comment': case.description,
})
contact_id = contact_obj.create(cr, uid, {
'partner_id': partner_id,
'name': case.name,
'phone': case.phone,
'mobile': case.mobile,
'email': case.email_from,
'fax': case.fax,
'title': case.title,
'function': case.function and case.function.id or False,
'street': case.street,
'street2': case.street2,
'zip': case.zip,
'city': case.city,
'country_id': case.country_id and case.country_id.id or False,
'state_id': case.state_id and case.state_id.id or False,
})
else:
if data['form']['partner_id']:
partner = partner_obj.browse(cr,uid,data['form']['partner_id'])
partner_id = partner.id
contact_id = partner.address and partner.address[0].id
partner_ids.append(partner_id)
vals = {}
if partner_id:
vals.update({'partner_id': partner_id})
if contact_id:
vals.update({'partner_address_id': contact_id})
case_obj.write(cr, uid, [case.id], vals)
return partner_ids
def _make_partner(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
partner_ids = self._create_partner(cr, uid, data, context)
mod_obj = pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
res = mod_obj.read(cr, uid, result, ['res_id'])
value = {
'domain': "[]",
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'res.partner',
'res_id': partner_ids and int(partner_ids[0]) or False,
'view_id': False,
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
states = {
'init': {
'actions': [_selectPartner],
'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
'state' : [('end', 'Cancel', 'gtk-cancel'),('create_partner', 'Create Partner', 'gtk-go-forward')]}
},
'create_partner': {
'actions': [],
'result': {'type': 'form', 'arch': partner_form, 'fields': partner_fields,
'state' : [('end', 'Cancel', 'gtk-cancel'),('create', 'Continue', 'gtk-go-forward')]}
},
'create': {
'actions': [],
'result': {'type': 'action', 'action': _make_partner, 'state': 'end'}
}
}
partner_create('crm.lead.partner_create')
class lead2opportunity(partner_create):
case_form = """<?xml version="1.0"?>
<form string="Convert To Opportunity">
<field name="name"/>
<field name="partner_id"/>
<newline/>
<field name="planned_revenue"/>
<field name="probability"/>
</form>"""
case_fields = {
'name': {'type':'char', 'size':64, 'string':'Opportunity Summary', 'required':True},
'planned_revenue': {'type':'float', 'digits':(16,2), 'string': 'Expected Revenue'},
'probability': {'type':'float', 'digits':(16,2), 'string': 'Success Probability'},
'partner_id' : {'type':'many2one', 'relation':'res.partner', 'string':'Partner'},
}
def _check_state(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
case_obj = pool.get('crm.lead')
for case in case_obj.browse(cr, uid, data['ids']):
if case.state != 'open':
raise wizard.except_wizard(_('Warning !'),
_('Lead should be in \'Open\' state before converting to Opportunity.'))
return {}
def _selectopportunity(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
case_obj = pool.get('crm.lead')
case = case_obj.browse(cr, uid, data['id'])
return {'name': case.name, 'partner_id':case.partner_id and case.partner_id.id or False}
def _selectChoice(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
case_obj = pool.get('crm.lead')
for case in case_obj.browse(cr, uid, data['ids']):
if not case.partner_id:
return 'create_partner'
return 'opportunity'
def _makeOrder(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
data_obj = pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter')
res = data_obj.read(cr, uid, result, ['res_id'])
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_oppor')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_oppor')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
lead_case_obj = pool.get('crm.lead')
opportunity_case_obj = pool.get('crm.opportunity')
for lead in lead_case_obj.browse(cr, uid, data['ids']):
new_opportunity_id = opportunity_case_obj.create(cr, uid, {
'name': data['form']['name'],
'planned_revenue': data['form']['planned_revenue'],
'probability': data['form']['probability'],
'partner_id': data['form']['partner_id'],
'section_id':lead.section_id.id,
'description':lead.description,
'date_deadline': lead.date_deadline,
'partner_address_id':lead.partner_address_id.id,
'priority': lead.priority,
'phone': lead.phone,
'email_from': lead.email_from
})
new_opportunity = opportunity_case_obj.browse(cr, uid, new_opportunity_id)
vals = {
'partner_id': data['form']['partner_id'],
}
if not lead.opportunity_id:
vals.update({'opportunity_id' : new_opportunity.id})
lead_case_obj.write(cr, uid, [lead.id], vals)
lead_case_obj.case_close(cr, uid, [lead.id])
opportunity_case_obj.case_open(cr, uid, [new_opportunity_id])
value = {
'name': _('Opportunity'),
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'crm.opportunity',
'res_id': int(new_opportunity_id),
'view_id': False,
'views': [(id2,'form'),(id3,'tree'),(False,'calendar'),(False,'graph')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
def _makePartner(self, cr, uid, data, context):
partner_ids = self._create_partner(cr, uid, data, context)
return {}
states = {
'init': {
'actions': [_check_state],
'result': {'type':'choice','next_state':_selectChoice}
},
'create_partner': {
'actions': [partner_create._selectPartner],
'result': {'type': 'form', 'arch': partner_create.partner_form, 'fields': partner_create.partner_fields,
'state' : [('end', 'Cancel', 'gtk-cancel'),('opportunity', 'Skip', 'gtk-goto-last'), ('create', 'Continue', 'gtk-go-forward')]}
},
'create': {
'actions': [],
'result': {'type': 'action', 'action': _makePartner, 'state':'opportunity' }
},
'opportunity': {
'actions': [_selectopportunity],
'result': {'type': 'form', 'arch': case_form, 'fields': case_fields,
'state' : [('end', 'Cancel', 'gtk-cancel'),('confirm', 'Create Opportunity', 'gtk-go-forward')]}
},
'confirm': {
'actions': [],
'result': {'type': 'action', 'action': _makeOrder, 'state': 'end'}
}
}
lead2opportunity('crm.lead.opportunity_set')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,98 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv
from tools.translate import _
class crm_opportunity2meeting(osv.osv_memory):
_name = 'crm.opportunity2meeting'
_description = 'Opportunity To Meeting'
def action_cancel(self, cr, uid, ids, context=None):
"""
Closes Opportunity to Meeting form
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Opportunity to Meeting IDs
@param context: A standard dictionary for contextual values
"""
return {'type': 'ir.actions.act_window_close'}
def action_makeMeeting(self, cr, uid, ids, context=None):
"""
This opens Meeting's calendar view to schedule meeting on current Opportunity
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Opportunity to Meeting IDs
@param context: A standard dictionary for contextual values
@return : Dictionary value for created Meeting view
"""
value = {}
record_ids = context and context.get('active_ids', []) or []
if record_ids:
opp_obj = self.pool.get('crm.opportunity')
data_obj = self.pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
res = data_obj.read(cr, uid, result, ['res_id'])
id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
if id1:
id1 = data_obj.browse(cr, uid, id1, context=context).res_id
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
if id3:
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
for this in self.browse(cr, uid, ids, context=context):
for opp in opp_obj.browse(cr, uid, record_ids, context=context):
context = {
'default_opportunity_id': opp.id,
'default_partner_id': opp.partner_id and opp.partner_id.id or False,
'default_section_id': opp.section_id and opp.section_id.id or False,
'default_email_from': opp.email_from,
'default_state': 'open',
'default_name': opp.name
}
value = {
'name': _('Meetings'),
'domain' : "[('user_id','=',%s)]" % (uid),
'context': context,
'view_type': 'form',
'view_mode': 'calendar,form,tree',
'res_model': 'crm.meeting',
'view_id': False,
'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')],
'type': 'ir.actions.act_window',
'search_view_id': res['res_id']
}
return value
crm_opportunity2meeting()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Some files were not shown because too many files have changed in this diff Show More