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_auth_oauth': fields.boolean('Use external authentication providers, sign in with google, facebook, ...'),
39 'module_base_import': fields.boolean("Allow users to import data from CSV files"),
40 'module_google_drive': fields.boolean('Attach Google documents to any record',
41 help="""This installs the module google_docs."""),
42 'module_google_calendar': fields.boolean('Allow the users to synchronize their calendar with Google Calendar',
43 help="""This installs the module google_calendar."""),
44 'font': fields.many2one('res.font', string="Report Font", domain=[('mode', 'in', ('Normal', 'Regular', 'all', 'Book'))],
45 help="Set the font into the report header, it will be used as default font in the RML reports of the user company"),
50 'font': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.font.id,
53 def open_company(self, cr, uid, ids, context=None):
54 user = self.pool.get('res.users').browse(cr, uid, uid, context)
56 'type': 'ir.actions.act_window',
57 'name': 'Your Company',
60 'res_model': 'res.company',
61 'res_id': user.company_id.id,
65 def _change_header(self, header,font):
66 """ Replace default fontname use in header and setfont tag """
68 default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
69 return re.sub('(<setFont.?name.?=.?)(".*?")(.)', '\g<1>"%s"\g<3>'% font,default_para)
71 def set_base_defaults(self, cr, uid, ids, context=None):
72 ir_model_data = self.pool.get('ir.model.data')
73 wizard = self.browse(cr, uid, ids, context)[0]
75 user = self.pool.get('res.users').browse(cr, uid, uid, context)
76 font_name = wizard.font.name
77 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)})
80 def act_discover_fonts(self, cr, uid, ids, context=None):
81 return self.pool.get("res.font").font_scan(cr, uid, context=context)
83 # Preferences wizard for Sales & CRM.
84 # It is defined here because it is inherited independently in modules sale, crm,
85 # plugin_outlook and plugin_thunderbird.
86 class sale_config_settings(osv.osv_memory):
87 _name = 'sale.config.settings'
88 _inherit = 'res.config.settings'
90 'module_web_linkedin': fields.boolean('Get contacts automatically from linkedIn',
91 help="""When you create a new contact (person or company), you will be able to load all the data from LinkedIn (photos, address, etc)."""),
92 'module_crm': fields.boolean('CRM'),
93 'module_sale' : fields.boolean('SALE'),
94 'module_plugin_thunderbird': fields.boolean('Enable Thunderbird plug-in',
95 help='The plugin allows you archive email and its attachments to the selected '
96 'OpenERP objects. You can select a partner, or a lead and '
97 'attach the selected mail as a .eml file in '
98 'the attachment of a selected record. You can create documents for CRM Lead, '
99 'Partner from the selected emails.\n'
100 '-This installs the module plugin_thunderbird.'),
101 'module_plugin_outlook': fields.boolean('Enable Outlook plug-in',
102 help='The Outlook plugin allows you to select an object that you would like to add '
103 'to your email and its attachments from MS Outlook. You can select a partner, '
104 'or a lead object and archive a selected email into an OpenERP mail message with attachments.\n'
105 '-This installs the module plugin_outlook.'),
106 'module_mass_mailing': fields.boolean(
107 'Manage mass mailing campaigns',
108 help='Get access to statistics with your mass mailing, manage campaigns.'),
111 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: