1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Business Applications
5 # Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
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 ##############################################################################
22 from openerp.osv import fields, osv
24 from openerp.report.render.rml2pdf import customfonts
26 class base_config_settings(osv.osv_memory):
27 _name = 'base.config.settings'
28 _inherit = 'res.config.settings'
31 'module_multi_company': fields.boolean('Manage multiple companies',
32 help='Work in multi-company environments, with appropriate security access between companies.\n'
33 '-This installs the module multi_company.'),
34 'module_share': fields.boolean('Allow documents sharing',
35 help="""Share or embbed any screen of openerp."""),
36 'module_portal': fields.boolean('Activate the customer portal',
37 help="""Give your customers access to their documents."""),
38 'module_portal_anonymous': fields.boolean('Activate the public portal',
39 help="""Enable the public part of openerp, openerp becomes a public website."""),
40 'module_auth_oauth': fields.boolean('Use external authentication providers, sign in with google, facebook, ...'),
41 'module_base_import': fields.boolean("Allow users to import data from CSV files"),
42 'module_google_drive': fields.boolean('Attach Google documents to any record',
43 help="""This installs the module google_docs."""),
44 'font': fields.many2one('res.font', string="Report Font", help="Set the font into the report header, it will be used as default font in the RML reports of the user company"),
48 'font': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.font.id,
51 def open_company(self, cr, uid, ids, context=None):
52 user = self.pool.get('res.users').browse(cr, uid, uid, context)
54 'type': 'ir.actions.act_window',
55 'name': 'Your Company',
58 'res_model': 'res.company',
59 'res_id': user.company_id.id,
63 def _change_header(self, header,font):
64 """ Replace default fontname use in header and setfont tag """
66 default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
67 return re.sub('(<setFont.?name.?=.?)(".*?")(.)', '\g<1>"%s"\g<3>'% font,default_para)
69 def set_base_defaults(self, cr, uid, ids, context=None):
70 ir_model_data = self.pool.get('ir.model.data')
71 wizard = self.browse(cr, uid, ids)[0]
73 user = self.pool.get('res.users').browse(cr, uid, uid, context)
74 font_name = wizard.font.name
75 user.company_id.write({'font': wizard.font.id,'rml_header': self._change_header(user.company_id.rml_header,font_name), 'rml_header2': self._change_header(user.company_id.rml_header2, font_name), 'rml_header3': self._change_header(user.company_id.rml_header3, font_name)})
78 def act_discover_fonts(self, cr, uid, ids, context=None):
79 return self.pool.get("res.font").discover_fonts(cr, uid, ids, context)
81 # Preferences wizard for Sales & CRM.
82 # It is defined here because it is inherited independently in modules sale, crm,
83 # plugin_outlook and plugin_thunderbird.
84 class sale_config_settings(osv.osv_memory):
85 _name = 'sale.config.settings'
86 _inherit = 'res.config.settings'
88 'module_web_linkedin': fields.boolean('Get contacts automatically from linkedIn',
89 help="""When you create a new contact (person or company), you will be able to load all the data from LinkedIn (photos, address, etc)."""),
90 'module_crm': fields.boolean('CRM'),
91 'module_sale' : fields.boolean('SALE'),
92 'module_plugin_thunderbird': fields.boolean('Enable Thunderbird plug-in',
93 help='The plugin allows you archive email and its attachments to the selected '
94 'OpenERP objects. You can select a partner, or a lead and '
95 'attach the selected mail as a .eml file in '
96 'the attachment of a selected record. You can create documents for CRM Lead, '
97 'Partner from the selected emails.\n'
98 '-This installs the module plugin_thunderbird.'),
99 'module_plugin_outlook': fields.boolean('Enable Outlook plug-in',
100 help='The Outlook plugin allows you to select an object that you would like to add '
101 'to your email and its attachments from MS Outlook. You can select a partner, '
102 'or a lead object and archive a selected email into an OpenERP mail message with attachments.\n'
103 '-This installs the module plugin_outlook.'),
104 'module_mass_mailing': fields.boolean(
105 'Manage mass mailing campaigns',
106 help='Get access to statistics with your mass mailing, manage campaigns.'),
109 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: