1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
26 from osv import fields, osv
27 from tools.translate import _
28 from lxml import etree
30 # Specify Your Terminology will move to 'partner' module
31 class specify_partner_terminology(osv.osv_memory):
32 _name = 'base.setup.terminology'
33 _inherit = 'res.config'
35 'partner': fields.selection([
36 ('Customer','Customer'),
39 ('Patient','Patient'),
40 ('Partner','Partner'),
44 ], 'How do you call a Customer', required=True ),
47 'partner' :'Customer',
50 def make_translations(self, cr, uid, ids, name, type, src, value, res_id=0, context=None):
51 trans_obj = self.pool.get('ir.translation')
52 user_obj = self.pool.get('res.users')
53 context_lang = user_obj.browse(cr, uid, uid, context=context).context_lang
54 existing_trans_ids = trans_obj.search(cr, uid, [('name','=',name), ('lang','=',context_lang), ('type','=',type), ('src','=',src), ('res_id','=',res_id)])
55 if existing_trans_ids:
56 trans_obj.write(cr, uid, existing_trans_ids, {'value': value}, context=context)
58 create_id = trans_obj.create(cr, uid, {'name': name,'lang': context_lang, 'type': type, 'src': src, 'value': value , 'res_id': res_id}, context=context)
61 def execute(self, cr, uid, ids, context=None):
62 def _case_insensitive_replace(ref_string, src, value):
64 pattern = re.compile(src, re.IGNORECASE)
65 return pattern.sub(_(value), _(ref_string))
66 trans_obj = self.pool.get('ir.translation')
67 fields_obj = self.pool.get('ir.model.fields')
68 menu_obj = self.pool.get('ir.ui.menu')
69 act_window_obj = self.pool.get('ir.actions.act_window')
70 for o in self.browse(cr, uid, ids, context=context):
71 #translate label of field
72 field_ids = fields_obj.search(cr, uid, [('field_description','ilike','Customer')])
73 for f_id in fields_obj.browse(cr ,uid, field_ids, context=context):
74 field_ref = f_id.model_id.model + ',' + f_id.name
75 self.make_translations(cr, uid, ids, field_ref, 'field', f_id.field_description, _case_insensitive_replace(f_id.field_description,'Customer',o.partner), context=context)
76 #translate help tooltip of field
77 for obj in self.pool.models.values():
78 for field_name, field_rec in obj._columns.items():
79 if field_rec.help.lower().count('customer'):
80 field_ref = obj._name + ',' + field_name
81 self.make_translations(cr, uid, ids, field_ref, 'help', field_rec.help, _case_insensitive_replace(field_rec.help,'Customer',o.partner), context=context)
83 menu_ids = menu_obj.search(cr,uid, [('name','ilike','Customer')])
84 for m_id in menu_obj.browse(cr, uid, menu_ids, context=context):
86 menu_ref = 'ir.ui.menu' + ',' + 'name'
87 self.make_translations(cr, uid, ids, menu_ref, 'model', menu_name, _case_insensitive_replace(menu_name,'Customer',o.partner), res_id=m_id.id, context=context)
88 #translate act window name
89 act_window_ids = act_window_obj.search(cr, uid, [('name','ilike','Customer')])
90 for act_id in act_window_obj.browse(cr ,uid, act_window_ids, context=context):
91 act_ref = 'ir.actions.act_window' + ',' + 'name'
92 self.make_translations(cr, uid, ids, act_ref, 'model', act_id.name, _case_insensitive_replace(act_id.name,'Customer',o.partner), res_id=act_id.id, context=context)
93 #translate act window tooltips
94 act_window_ids = act_window_obj.search(cr, uid, [('help','ilike','Customer')])
95 for act_id in act_window_obj.browse(cr ,uid, act_window_ids, context=context):
96 act_ref = 'ir.actions.act_window' + ',' + 'help'
97 self.make_translations(cr, uid, ids, act_ref, 'model', act_id.help, _case_insensitive_replace(act_id.help,'Customer',o.partner), res_id=act_id.id, context=context)
100 # Preferences wizard for Sales & CRM.
101 # It is defined here because it is inherited independently in modules sale, crm,
102 # plugin_outlook and plugin_thunderbird.
103 class sale_config_settings(osv.osv_memory):
104 _name = 'sale.config.settings'
105 _inherit = 'res.config.settings'
107 'module_crm': fields.boolean('CRM'),
108 'module_plugin_thunderbird': fields.boolean('Thunderbird Plugin',
109 help="""The plugin allows you archive email and its attachments to the selected
110 OpenERP objects. You can select a partner, a task, a project, an analytical
111 account, or any other object and attach the selected mail as a .eml file in
112 the attachment of a selected record. You can create documents for CRM Lead,
113 HR Applicant and Project Issue from the selected emails.
114 This installs the module plugin_thunderbird."""),
115 'module_plugin_outlook': fields.boolean('Outlook Plugin',
116 help="""The Outlook plugin allows you to select an object that you would like to add
117 to your email and its attachments from MS Outlook. You can select a partner, a task,
118 a project, an analytical account, or any other object and archive a selected
119 email into an OpenERP mail message with attachments.
120 This installs the module plugin_outlook."""),
123 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: