[IMP] translations: parse views iteratively instead of recursively
[odoo/odoo.git] / addons / base_setup / res_config.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Business Applications
5 #    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
6 #
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.
11 #
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.
16 #
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/>.
19 #
20 ##############################################################################
21
22 from openerp.osv import fields, osv
23 import re
24 from openerp.report.render.rml2pdf import customfonts
25
26 class base_config_settings(osv.osv_memory):
27     _name = 'base.config.settings'
28     _inherit = 'res.config.settings'
29         
30     _columns = {
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"),
46
47     }
48     
49     _defaults= {
50         'font': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.font.id,
51     }
52     
53     def open_company(self, cr, uid, ids, context=None):
54         user = self.pool.get('res.users').browse(cr, uid, uid, context)
55         return {
56             'type': 'ir.actions.act_window',
57             'name': 'Your Company',
58             'view_type': 'form',
59             'view_mode': 'form',
60             'res_model': 'res.company',
61             'res_id': user.company_id.id,
62             'target': 'current',
63         }
64
65     def _change_header(self, header,font):
66         """ Replace default fontname use in header and setfont tag """
67         
68         default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
69         return re.sub('(<setFont.?name.?=.?)(".*?")(.)', '\g<1>"%s"\g<3>'% font,default_para)
70     
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]
74         if wizard.font:
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)})
78         return {}
79
80     def act_discover_fonts(self, cr, uid, ids, context=None):
81         return self.pool.get("res.font").font_scan(cr, uid, context=context)
82
83 # Preferences wizard for Sales & CRM.
84 # It is defined here because it is inherited independently in modules sale, crm.
85 class sale_config_settings(osv.osv_memory):
86     _name = 'sale.config.settings'
87     _inherit = 'res.config.settings'
88     _columns = {
89         'module_web_linkedin': fields.boolean('Get contacts automatically from linkedIn',
90             help="""When you create a new contact (person or company), you will be able to load all the data from LinkedIn (photos, address, etc)."""),
91         'module_crm': fields.boolean('CRM'),
92         'module_sale' : fields.boolean('SALE'),
93         'module_mass_mailing': fields.boolean(
94             'Manage mass mailing campaigns',
95             help='Get access to statistics with your mass mailing, manage campaigns.'),
96     }
97
98 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: