[MERGE] merge with trunk addons
bzr revid: mra@mra-laptop-20100702065516-2iighmxuun79f3sc
This commit is contained in:
@@ -58,8 +58,7 @@
|
||||
<field name="usage">menu</field>
|
||||
<field name="view_id" ref="board_auction_manager_form"/>
|
||||
</record>
|
||||
<menuitem icon="terp-graph" id="base.dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>
|
||||
<menuitem name="Auction" id="menu_board_auction" parent="base.dashboard" />
|
||||
<menuitem icon="terp-graph" name="Dashboard" id="menu_board_auction" parent="auction_report_menu" sequence="0"/>
|
||||
<menuitem
|
||||
name="Auction Member"
|
||||
action="open_board_auction"
|
||||
|
||||
+8
-7
@@ -212,10 +212,13 @@ class crm_case(object):
|
||||
address = self.pool.get('res.partner.address').browse(cr, uid, add)
|
||||
return {'value': {'email_from': address.email, 'phone': address.phone}}
|
||||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, emails=None, message=None, context=None):
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context={}):
|
||||
mailgate_pool = self.pool.get('mailgate.thread')
|
||||
return mailgate_pool._history(cr, uid, cases, keyword, history=history,\
|
||||
emails=emails, message=message, context=context)
|
||||
subject=subject, email=email, \
|
||||
details=details, email_from=email_from,\
|
||||
message_id=message_id, attach=attach, \
|
||||
context=context)
|
||||
|
||||
def case_open(self, cr, uid, ids, *args):
|
||||
"""Opens Case
|
||||
@@ -357,7 +360,7 @@ class crm_case(object):
|
||||
src = case.email_from
|
||||
dest = case.section_id.reply_to
|
||||
body = ""
|
||||
body = case.description
|
||||
body = case.email_last or case.description
|
||||
if not destination:
|
||||
src, dest = dest, src
|
||||
if body and case.user_id.signature:
|
||||
@@ -377,15 +380,13 @@ class crm_case(object):
|
||||
flag = tools.email_send(
|
||||
src,
|
||||
[dest],
|
||||
subject,
|
||||
subject,
|
||||
body,
|
||||
reply_to=case.section_id.reply_to,
|
||||
openobject_id=str(case.id),
|
||||
attach=attach_to_send
|
||||
)
|
||||
emails = {'email_from': src, 'email_to': dest}
|
||||
message = {'subject': subject, 'description': body, 'attach': attach_to_send}
|
||||
self._history(cr, uid, [case], _('Send'), history=True, emails=emails, message=message)
|
||||
self._history(cr, uid, [case], _('Send'), history=True, subject=subject, email=dest, details=body, email_from=src)
|
||||
return True
|
||||
|
||||
def _check(self, cr, uid, ids=False, context={}):
|
||||
|
||||
@@ -205,7 +205,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
||||
msgs = msgs[:1]
|
||||
attachments.extend(itertools.chain(*[m.attachment_ids for m in msgs]))
|
||||
attach = [(a.datas_fname or a.name, base64.decodestring(a.datas)) for a in attachments if a.datas]
|
||||
|
||||
|
||||
result = tools.email_send(
|
||||
email_from,
|
||||
emails,
|
||||
@@ -217,9 +217,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
||||
)
|
||||
|
||||
if result:
|
||||
emails = {'email_from': email_from, 'email_to': this.email_to}
|
||||
message = {'subject': this.subject, 'description': body , 'attach': attach}
|
||||
case_pool._history(cr, uid, [case], _('Forward'), history=True, emails=emails, message=message)
|
||||
case_pool._history(cr, uid, [case], _('Forward'), history=True, email=this.email_to, subject=this.subject, details=body, email_from=email_from, attach=attach)
|
||||
else:
|
||||
raise osv.except_osv(_('Error!'), _('Unable to send mail. Please check SMTP is configured properly.'))
|
||||
|
||||
|
||||
@@ -130,11 +130,13 @@ class crm_send_new_email(osv.osv_memory):
|
||||
if not flag:
|
||||
raise osv.except_osv(_('Error!'), _('Unable to send mail. Please check SMTP is configured properly.'))
|
||||
if flag:
|
||||
email_dict = {'email_from': email_from, 'email_to': obj.email_to, 'email_cc': email_cc}
|
||||
message = {'subject': obj.subject, 'description': body, 'message_id': message_id, 'ref_id': ref_id , 'attach': attach}
|
||||
case_pool._history(cr, uid, [case], _('Send'), history=True, emails=email_dict, message=message)
|
||||
case_pool._history(cr, uid, [case], _('Send'), history=True, \
|
||||
email=obj.email_to, details=body, \
|
||||
subject=obj.subject, email_from=email_from, \
|
||||
message_id=message_id, references=ref_id or message_id, attach=attach)
|
||||
if obj.state == 'unchanged':
|
||||
pass
|
||||
elif obj.state == 'done':
|
||||
case_pool.case_close(cr, uid, [case.id])
|
||||
elif obj.state == 'draft':
|
||||
case_pool.case_reset(cr, uid, [case.id])
|
||||
|
||||
@@ -50,11 +50,13 @@
|
||||
<field name="view_id" ref="board_document_manager_form"/>
|
||||
</record>
|
||||
|
||||
<menuitem icon="terp-graph" id="base.dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>
|
||||
<menuitem id="menu_reporting" name="Reporting" sequence="2" parent="knowledge.menu_document"/>
|
||||
<menuitem
|
||||
name="Document"
|
||||
name="Dashboard"
|
||||
id="menu_board_document"
|
||||
parent="base.dashboard"
|
||||
parent="menu_reporting"
|
||||
sequence="0"
|
||||
icon="terp-graph"
|
||||
groups="document.group_document_manager"/>
|
||||
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
<group expand="0" string="Group By..." groups="base.group_extended">
|
||||
<filter string="Type" domain="[]" context="{'group_by':'type'}"/>
|
||||
<filter string="Owner" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Storage" domain="[]" context="{'group_by':'storage_id'}"/>
|
||||
<filter string="Storage" domain="[]" context="{'group_by':'storage_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
@@ -299,7 +299,7 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="priority" eval="1"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="blue:type in ('url',)">
|
||||
<tree colors="blue:type in ('url',)">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="datas_fname"/>
|
||||
@@ -318,7 +318,7 @@
|
||||
<field name="name">Document</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<menuitem name="Documents" id="menu_document_doc" parent="knowledge.menu_document" sequence="5"/>
|
||||
<menuitem name="Documents" id="menu_document_doc" parent="knowledge.menu_document" sequence="0"/>
|
||||
<menuitem
|
||||
name="Documents"
|
||||
action="action_document_file_form"
|
||||
@@ -392,7 +392,7 @@
|
||||
src_model="document.directory"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
string="New members"
|
||||
name="%(membership.action_report_partner_member_year_tree)d"
|
||||
view_mode="graph,tree" colspan="4"/>-->
|
||||
|
||||
|
||||
<record model ="ir.ui.view" id="view_report_event_reg_graph">
|
||||
<field name="name">Registration Event report</field>
|
||||
<field name="model">report.event.registration</field>
|
||||
@@ -26,15 +26,15 @@
|
||||
<field name="register_max" operator="+"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="act_event_reg">
|
||||
<field name="name">Events On Registrations</field>
|
||||
<field name="res_model">report.event.registration</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="view_id" ref="view_report_event_reg_graph"/>
|
||||
</record>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="act_event_view">
|
||||
<field name="name">Next Events</field>
|
||||
@@ -42,12 +42,12 @@
|
||||
<field name="res_model">event.event</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
</record>
|
||||
|
||||
<record model="board.note.type" id="note_association_type">
|
||||
<field name="name">associations</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="board_associations_manager_form">
|
||||
<field name="name">board.associations.manager.form</field>
|
||||
<field name="model">board.board</field>
|
||||
@@ -68,10 +68,10 @@
|
||||
<child2>
|
||||
<action string="Register Events"
|
||||
name="%(act_event_reg)d"
|
||||
colspan="4"/>
|
||||
|
||||
colspan="4"/>
|
||||
|
||||
</child2>
|
||||
|
||||
|
||||
</hpaned>
|
||||
</form>
|
||||
</field>
|
||||
@@ -84,8 +84,7 @@
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="board_associations_manager_form"/>
|
||||
</record>
|
||||
<menuitem icon="terp-graph" id="base.dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>
|
||||
<menuitem id="board_associations" name="Associations" parent="base.dashboard" />
|
||||
<menuitem id="board_associations" icon="terp-graph" name="Dashboard" parent="menu_report_event" sequence="0"/>
|
||||
<menuitem
|
||||
name="Associations" parent="board_associations"
|
||||
action="open_board_associations_manager"
|
||||
|
||||
@@ -68,7 +68,8 @@ class mailgate_thread(osv.osv):
|
||||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
raise Exception, _('Method is not implemented')
|
||||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, emails=None, message=None, context=None):
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \
|
||||
email_from=False, message_id=False, references=None, attach=None, context=None):
|
||||
"""
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@@ -76,18 +77,17 @@ class mailgate_thread(osv.osv):
|
||||
@param cases: a browse record list
|
||||
@param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used
|
||||
@param history: Value True/False, If True it makes entry in case History otherwise in Case Log
|
||||
@param emails: Email details, e.g. emails = {'email_from': 'FROM', 'email_to': 'TO', 'email_cc': 'CC', 'email_bcc': 'BCC'}
|
||||
@param message: Details of email to send, e.g. message = {'subject': 'SUBJECT', 'description': 'DESCRIPTION', 'message_id':'MESSAGE_ID', 'ref_id': 'REFERENCES' , 'attach': 'ATTACH'}
|
||||
@param email: Email address if any
|
||||
@param details: Details of case history if any
|
||||
@param atach: Attachment sent in email
|
||||
@param context: A standard dictionary for contextual values"""
|
||||
if context is None:
|
||||
context = {}
|
||||
if message is None:
|
||||
message = {}
|
||||
if emails is None:
|
||||
emails = {}
|
||||
if message.get('attach') is None:
|
||||
message.update({'attach': []})
|
||||
if attach is None:
|
||||
attach = []
|
||||
|
||||
# The mailgate sends the ids of the cases and not the object list
|
||||
|
||||
if all(isinstance(case_id, (int, long)) for case_id in cases):
|
||||
cases = self.browse(cr, uid, cases, context=context)
|
||||
|
||||
@@ -101,40 +101,34 @@ class mailgate_thread(osv.osv):
|
||||
'model' : case._name,
|
||||
'res_id': case.id,
|
||||
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'message_id': message.get('message_id', False),
|
||||
'message_id': message_id,
|
||||
}
|
||||
attachments = []
|
||||
if history:
|
||||
for att in message.get('attach'):
|
||||
for att in attach:
|
||||
attachments.append(att_obj.create(cr, uid, {'name': att[0], 'datas': base64.encodestring(att[1])}))
|
||||
|
||||
data = {
|
||||
'name': message.get('subject', 'History'),
|
||||
'name': subject or 'History',
|
||||
'history': True,
|
||||
'user_id': uid,
|
||||
'model' : case._name,
|
||||
'res_id': case.id,
|
||||
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'description': message.get('description') or (hasattr(case, 'description') and case.description or False),
|
||||
'email_to': emails.get('email_to') or \
|
||||
'description': details or (hasattr(case, 'description') and case.description or False),
|
||||
'email_to': email or \
|
||||
(hasattr(case, 'user_id') and case.user_id and case.user_id.address_id and \
|
||||
case.user_id.address_id.email) or tools.config.get('email_from', False),
|
||||
'email_from': emails.get('email_from') or \
|
||||
'email_from': email_from or \
|
||||
(hasattr(case, 'user_id') and case.user_id and case.user_id.address_id and \
|
||||
case.user_id.address_id.email) or tools.config.get('email_from', False),
|
||||
'email_cc': emails.get('email_cc', None),
|
||||
'email_bcc': emails.get('email_bcc', None),
|
||||
'partner_id': hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False,
|
||||
'ref_id': message.get('ref_id'),
|
||||
'message_id': message.get('message_id'),
|
||||
'references': references,
|
||||
'message_id': message_id,
|
||||
'attachment_ids': [(6, 0, attachments)]
|
||||
}
|
||||
obj.create(cr, uid, data, context=context)
|
||||
return True
|
||||
|
||||
history = _history
|
||||
__history = _history
|
||||
|
||||
mailgate_thread()
|
||||
|
||||
class mailgate_message(osv.osv):
|
||||
@@ -421,9 +415,15 @@ class mailgate_tool(osv.osv_memory):
|
||||
# Store messages
|
||||
context.update({'model' : model})
|
||||
if hasattr(model_pool, '_history'):
|
||||
emails = {'email_from': msg.get('from'), 'email_to': msg.get('to'), 'email_cc': msg.get('cc')}
|
||||
message = {'subject': msg.get('subject'), 'description': msg.get('body'), 'message_id': msg.get('message-id'), 'ref_id': msg.get('references', False) , 'attach': attachments.items()}
|
||||
model_pool._history(cr, uid, res_ids, _('Receive'), history=True, emails=emails, message=message, context = context)
|
||||
model_pool._history(cr, uid, res_ids, _('Receive'), history=True,
|
||||
subject = msg.get('subject'),
|
||||
email = msg.get('to'),
|
||||
details = msg.get('body'),
|
||||
email_from = msg.get('from'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False),
|
||||
attach = attachments.items(),
|
||||
context = context)
|
||||
else:
|
||||
self.history(cr, uid, model, res_ids, msg, attachment_ids, context=context)
|
||||
self.email_forward(cr, uid, model, res_ids, msg_txt)
|
||||
|
||||
@@ -125,11 +125,12 @@
|
||||
<field name="usage">menu</field>
|
||||
<field name="view_id" ref="board_project_form"/>
|
||||
</record>
|
||||
<menuitem icon="terp-graph" id="base.dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>
|
||||
<menuitem
|
||||
id="next_id_86"
|
||||
name="Project"
|
||||
parent="base.dashboard"/>
|
||||
name="Dashboard"
|
||||
icon="terp-graph"
|
||||
sequence="0"
|
||||
parent="base.menu_project_report"/>
|
||||
<menuitem
|
||||
action="open_board_project"
|
||||
icon="terp-graph"
|
||||
|
||||
@@ -1,219 +1,219 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 Axelor SPRL. (http://www.axelor.com) All Rights Reserved.
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
import ir
|
||||
from osv import osv,fields
|
||||
import base64
|
||||
import netsvc
|
||||
from tools.translate import _
|
||||
|
||||
class tinythunderbird_partner(osv.osv):
|
||||
|
||||
def _links_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('res.request.link')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context)
|
||||
|
||||
return [(r['object'], r['name']) for r in res]
|
||||
|
||||
_name = "tinythunderbird.partner"
|
||||
_description="Thunderbid mails"
|
||||
_rec_name="sender"
|
||||
_columns = {
|
||||
'sender':fields.char("Sender",size=128,required=True,select=True),
|
||||
'receiver':fields.text("Receiver"),
|
||||
"copy_to":fields.text("Copy To"),
|
||||
"date":fields.date("Date",select=True),
|
||||
"title":fields.char("Subject",size=128,select=True),
|
||||
"description":fields.text("Description"),
|
||||
"reference":fields.reference("Reference", selection=_links_get, size=128),
|
||||
"res_user_id":fields.many2one("res.users","User"),
|
||||
"attachments":fields.text("Attached Files",readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'res_user_id':lambda obj,cr,uid,context: uid,
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d')
|
||||
}
|
||||
|
||||
def thunderbird_mailcreate(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
import email
|
||||
header_name = email.Header.decode_header(dictcreate['name'])
|
||||
dictcreate['name'] = header_name and header_name[0] and header_name[0][0]
|
||||
add_obj=self.pool.get('res.partner.address')
|
||||
case_pool=self.pool.get(dictcreate.get('object','crm.case'))
|
||||
partner_ids=add_obj.search(cr,user,[('email','=',dictcreate['email_from'])])
|
||||
partner=add_obj.read(cr,user,partner_ids,['partner_id'])
|
||||
if partner and partner[0] and partner[0]['partner_id']:
|
||||
dictcreate.update({'partner_id':partner[0]['partner_id'][0]})
|
||||
create_id = case_pool.create(cr, user, dictcreate)
|
||||
cases=case_pool.browse(cr,user,[create_id])
|
||||
case_pool._history(cr, user, cases, _('Archive'), history=True)
|
||||
return create_id
|
||||
|
||||
def thunderbird_createcontact(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
create_id = self.pool.get('res.partner.address').create(cr, user, dictcreate)
|
||||
return create_id
|
||||
|
||||
def thunderbird_createpartner(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
address_obj = self.pool.get('res.partner')
|
||||
search_id = address_obj.search(cr, user,[('name','=',dictcreate['name'])])
|
||||
if search_id:
|
||||
return 0
|
||||
create_id = address_obj.create(cr, user, dictcreate)
|
||||
return create_id
|
||||
|
||||
def thunderbird_searchobject(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
search_id = self.pool.get('ir.model').search(cr, user,[('model','=',dictcreate['model'])])
|
||||
return (search_id and search_id[0]) or 0
|
||||
|
||||
def thunderbird_searchcontact(self,cr,user,vals):
|
||||
address_obj = self.pool.get('res.partner.address')
|
||||
search_id1 = address_obj.search(cr,user,[('name','ilike',vals)])
|
||||
search_id2 = address_obj.search(cr,user,[('email','=',vals)])
|
||||
if search_id1:
|
||||
return address_obj.name_get(cr, user, search_id1)
|
||||
elif search_id2:
|
||||
return address_obj.name_get(cr, user, search_id2)
|
||||
return []
|
||||
|
||||
def thunderbird_tempsearch(self,cr,user,vals):
|
||||
if vals[0]:
|
||||
value = vals[0][0]
|
||||
if vals[1]:
|
||||
obj = vals[1];
|
||||
name_get=[]
|
||||
er_val=[]
|
||||
for object in obj:
|
||||
dyn_object = self.pool.get(object)
|
||||
if object == 'res.partner.address':
|
||||
search_id1 = dyn_object.search(cr,user,[('name','ilike',value)])
|
||||
search_id2 = dyn_object.search(cr,user,[('email','=',value)])
|
||||
if search_id1:
|
||||
name_get.append(object)
|
||||
name_get.append(dyn_object.name_get(cr, user, search_id1))
|
||||
elif search_id2:
|
||||
name_get.append(object)
|
||||
name_get.append(dyn_object.name_get(cr, user, search_id2))
|
||||
else:
|
||||
try:
|
||||
search_id1 = dyn_object.search(cr,user,[('name','ilike',value)])
|
||||
if search_id1:
|
||||
name_get.append(object)
|
||||
name_get.append(dyn_object.name_get(cr, user, search_id1))
|
||||
except:
|
||||
er_val.append(object)
|
||||
continue
|
||||
if len(er_val) > 0:
|
||||
name_get.append('error')
|
||||
name_get.append(er_val)
|
||||
return name_get
|
||||
|
||||
def thunderbird_attachment(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
datas = [dictcreate['datas']]
|
||||
name = [dictcreate['name']]
|
||||
f_name = [dictcreate['datas_fname']]
|
||||
if(dictcreate['datas'].__contains__(',')):
|
||||
name = dictcreate['name'].split(',')
|
||||
datas = dictcreate['datas'].split(',')
|
||||
f_name = dictcreate['datas_fname'].split(',')
|
||||
for i in range(0,datas.__len__()):
|
||||
dictcreate['name'] = name[i]
|
||||
dictcreate['datas'] = datas[i]
|
||||
dictcreate['datas_fname'] = f_name[i]
|
||||
create_id = self.pool.get('ir.attachment').create(cr,user,dictcreate)
|
||||
return 0
|
||||
|
||||
def thunderbird_login(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
service = netsvc.LocalService('common')
|
||||
res = service.login(dictcreate['db'],dictcreate['login'],dictcreate['passwd'])
|
||||
return res or 0
|
||||
|
||||
def read(self, cr, user, ids, fields=None, context={}, load='_classic_read'):
|
||||
ret_read = super(tinythunderbird_partner, self).read(cr, user, ids,fields,context,load)
|
||||
attach_obj = self.pool.get('ir.attachment')
|
||||
for read_data in ret_read:
|
||||
attachments = attach_obj.search(cr,user,[('res_model','=',self._name),('res_id','=',read_data['id'])])
|
||||
attechments_data = sattach_obj.read(cr,user,attachments,['name'])
|
||||
file_names = [a['name'] for a in attechments_data]
|
||||
text_atteched = '\n'.join(file_names)
|
||||
read_data['attachments'] = text_atteched
|
||||
return ret_read
|
||||
|
||||
def unlink(self, cr, uid, ids, context={}):
|
||||
attach_obj = self.pool.get('ir.attachment')
|
||||
attachments = attach_obj.search(cr,uid,[('res_model','=',self._name),('res_id','in',ids)])
|
||||
attach_obj.unlink(cr,uid,attachments)
|
||||
return super(tinythunderbird_partner, self).unlink(cr, uid, ids,context)
|
||||
|
||||
def thunderbird_objectsearch(self,cr,user,vals):
|
||||
obj_list= [('crm.claim', 'Claim'), ('crm.lead','Lead'), ('crm.meeting','Metting'), ('crm.opportunity','Opportunity'), ('crm.phonecall','Phonecall'), ('crm.fundraising','Fund raising'), ('crm.helpdesk','Helpdesk')]
|
||||
object=[]
|
||||
model_obj = self.pool.get('ir.model')
|
||||
for obj in obj_list:
|
||||
if model_obj.search(cr, user, [('model', '=', obj[0])]):
|
||||
object.append(obj)
|
||||
return object
|
||||
|
||||
def thunderbird_list_search_object(self,cr,user,vals):
|
||||
model_obj = self.pool.get('ir.model')
|
||||
object=''
|
||||
for obj in vals[0][1].split(','):
|
||||
if model_obj.search(cr, user, [('model', '=', obj)]):
|
||||
object += obj + ","
|
||||
else:
|
||||
object += "null,"
|
||||
return object
|
||||
|
||||
tinythunderbird_partner()
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004 Axelor SPRL. (http://www.axelor.com) All Rights Reserved.
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
import ir
|
||||
from osv import osv,fields
|
||||
import base64
|
||||
import netsvc
|
||||
from tools.translate import _
|
||||
|
||||
class tinythunderbird_partner(osv.osv):
|
||||
|
||||
def _links_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('res.request.link')
|
||||
ids = obj.search(cr, uid, [])
|
||||
res = obj.read(cr, uid, ids, ['object', 'name'], context)
|
||||
|
||||
return [(r['object'], r['name']) for r in res]
|
||||
|
||||
_name = "tinythunderbird.partner"
|
||||
_description="Thunderbid mails"
|
||||
_rec_name="sender"
|
||||
_columns = {
|
||||
'sender':fields.char("Sender",size=128,required=True,select=True),
|
||||
'receiver':fields.text("Receiver"),
|
||||
"copy_to":fields.text("Copy To"),
|
||||
"date":fields.date("Date",select=True),
|
||||
"title":fields.char("Subject",size=128,select=True),
|
||||
"description":fields.text("Description"),
|
||||
"reference":fields.reference("Reference", selection=_links_get, size=128),
|
||||
"res_user_id":fields.many2one("res.users","User"),
|
||||
"attachments":fields.text("Attached Files",readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'res_user_id':lambda obj,cr,uid,context: uid,
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d')
|
||||
}
|
||||
|
||||
def thunderbird_mailcreate(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
import email
|
||||
header_name = email.Header.decode_header(dictcreate['name'])
|
||||
dictcreate['name'] = header_name and header_name[0] and header_name[0][0]
|
||||
add_obj=self.pool.get('res.partner.address')
|
||||
case_pool=self.pool.get(dictcreate.get('object','crm.case'))
|
||||
partner_ids=add_obj.search(cr,user,[('email','=',dictcreate['email_from'])])
|
||||
partner=add_obj.read(cr,user,partner_ids,['partner_id'])
|
||||
if partner and partner[0] and partner[0]['partner_id']:
|
||||
dictcreate.update({'partner_id':partner[0]['partner_id'][0]})
|
||||
create_id = case_pool.create(cr, user, dictcreate)
|
||||
cases=case_pool.browse(cr,user,[create_id])
|
||||
case_pool._history(cr, user, cases, _('Archive'), history=True, email=False)
|
||||
return create_id
|
||||
|
||||
def thunderbird_createcontact(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
create_id = self.pool.get('res.partner.address').create(cr, user, dictcreate)
|
||||
return create_id
|
||||
|
||||
def thunderbird_createpartner(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
address_obj = self.pool.get('res.partner')
|
||||
search_id = address_obj.search(cr, user,[('name','=',dictcreate['name'])])
|
||||
if search_id:
|
||||
return 0
|
||||
create_id = address_obj.create(cr, user, dictcreate)
|
||||
return create_id
|
||||
|
||||
def thunderbird_searchobject(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
search_id = self.pool.get('ir.model').search(cr, user,[('model','=',dictcreate['model'])])
|
||||
return (search_id and search_id[0]) or 0
|
||||
|
||||
def thunderbird_searchcontact(self,cr,user,vals):
|
||||
address_obj = self.pool.get('res.partner.address')
|
||||
search_id1 = address_obj.search(cr,user,[('name','ilike',vals)])
|
||||
search_id2 = address_obj.search(cr,user,[('email','=',vals)])
|
||||
if search_id1:
|
||||
return address_obj.name_get(cr, user, search_id1)
|
||||
elif search_id2:
|
||||
return address_obj.name_get(cr, user, search_id2)
|
||||
return []
|
||||
|
||||
def thunderbird_tempsearch(self,cr,user,vals):
|
||||
if vals[0]:
|
||||
value = vals[0][0]
|
||||
if vals[1]:
|
||||
obj = vals[1];
|
||||
name_get=[]
|
||||
er_val=[]
|
||||
for object in obj:
|
||||
dyn_object = self.pool.get(object)
|
||||
if object == 'res.partner.address':
|
||||
search_id1 = dyn_object.search(cr,user,[('name','ilike',value)])
|
||||
search_id2 = dyn_object.search(cr,user,[('email','=',value)])
|
||||
if search_id1:
|
||||
name_get.append(object)
|
||||
name_get.append(dyn_object.name_get(cr, user, search_id1))
|
||||
elif search_id2:
|
||||
name_get.append(object)
|
||||
name_get.append(dyn_object.name_get(cr, user, search_id2))
|
||||
else:
|
||||
try:
|
||||
search_id1 = dyn_object.search(cr,user,[('name','ilike',value)])
|
||||
if search_id1:
|
||||
name_get.append(object)
|
||||
name_get.append(dyn_object.name_get(cr, user, search_id1))
|
||||
except:
|
||||
er_val.append(object)
|
||||
continue
|
||||
if len(er_val) > 0:
|
||||
name_get.append('error')
|
||||
name_get.append(er_val)
|
||||
return name_get
|
||||
|
||||
def thunderbird_attachment(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
datas = [dictcreate['datas']]
|
||||
name = [dictcreate['name']]
|
||||
f_name = [dictcreate['datas_fname']]
|
||||
if(dictcreate['datas'].__contains__(',')):
|
||||
name = dictcreate['name'].split(',')
|
||||
datas = dictcreate['datas'].split(',')
|
||||
f_name = dictcreate['datas_fname'].split(',')
|
||||
for i in range(0,datas.__len__()):
|
||||
dictcreate['name'] = name[i]
|
||||
dictcreate['datas'] = datas[i]
|
||||
dictcreate['datas_fname'] = f_name[i]
|
||||
create_id = self.pool.get('ir.attachment').create(cr,user,dictcreate)
|
||||
return 0
|
||||
|
||||
def thunderbird_login(self,cr,user,vals):
|
||||
dictcreate = dict(vals)
|
||||
service = netsvc.LocalService('common')
|
||||
res = service.login(dictcreate['db'],dictcreate['login'],dictcreate['passwd'])
|
||||
return res or 0
|
||||
|
||||
def read(self, cr, user, ids, fields=None, context={}, load='_classic_read'):
|
||||
ret_read = super(tinythunderbird_partner, self).read(cr, user, ids,fields,context,load)
|
||||
attach_obj = self.pool.get('ir.attachment')
|
||||
for read_data in ret_read:
|
||||
attachments = attach_obj.search(cr,user,[('res_model','=',self._name),('res_id','=',read_data['id'])])
|
||||
attechments_data = sattach_obj.read(cr,user,attachments,['name'])
|
||||
file_names = [a['name'] for a in attechments_data]
|
||||
text_atteched = '\n'.join(file_names)
|
||||
read_data['attachments'] = text_atteched
|
||||
return ret_read
|
||||
|
||||
def unlink(self, cr, uid, ids, context={}):
|
||||
attach_obj = self.pool.get('ir.attachment')
|
||||
attachments = attach_obj.search(cr,uid,[('res_model','=',self._name),('res_id','in',ids)])
|
||||
attach_obj.unlink(cr,uid,attachments)
|
||||
return super(tinythunderbird_partner, self).unlink(cr, uid, ids,context)
|
||||
|
||||
def thunderbird_objectsearch(self,cr,user,vals):
|
||||
obj_list= [('crm.claim', 'Claim'), ('crm.lead','Lead'), ('crm.meeting','Metting'), ('crm.opportunity','Opportunity'), ('crm.phonecall','Phonecall'), ('crm.fundraising','Fund raising'), ('crm.helpdesk','Helpdesk')]
|
||||
object=[]
|
||||
model_obj = self.pool.get('ir.model')
|
||||
for obj in obj_list:
|
||||
if model_obj.search(cr, user, [('model', '=', obj[0])]):
|
||||
object.append(obj)
|
||||
return object
|
||||
|
||||
def thunderbird_list_search_object(self,cr,user,vals):
|
||||
model_obj = self.pool.get('ir.model')
|
||||
object=''
|
||||
for obj in vals[0][1].split(','):
|
||||
if model_obj.search(cr, user, [('model', '=', obj)]):
|
||||
object += obj + ","
|
||||
else:
|
||||
object += "null,"
|
||||
return object
|
||||
|
||||
tinythunderbird_partner()
|
||||
|
||||
Reference in New Issue
Block a user