2012-03-28 06:34:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
2012-04-19 13:29:11 +00:00
|
|
|
# OpenERP, Open Source Business Applications
|
|
|
|
# Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
|
2012-03-28 06:34:59 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
2013-08-19 12:10:17 +00:00
|
|
|
import re
|
2013-09-12 11:57:34 +00:00
|
|
|
from openerp.report.render.rml2pdf import customfonts
|
2013-09-11 10:29:59 +00:00
|
|
|
|
2012-04-20 09:28:34 +00:00
|
|
|
class base_config_settings(osv.osv_memory):
|
2012-04-19 13:29:11 +00:00
|
|
|
_name = 'base.config.settings'
|
2012-03-28 06:34:59 +00:00
|
|
|
_inherit = 'res.config.settings'
|
2013-09-12 11:57:34 +00:00
|
|
|
|
2012-03-28 06:34:59 +00:00
|
|
|
_columns = {
|
2012-09-12 07:14:13 +00:00
|
|
|
'module_multi_company': fields.boolean('Manage multiple companies',
|
2013-07-25 06:14:42 +00:00
|
|
|
help='Work in multi-company environments, with appropriate security access between companies.\n'
|
2013-09-17 13:08:14 +00:00
|
|
|
'-This installs the module multi_company.'),
|
2012-09-12 07:14:13 +00:00
|
|
|
'module_share': fields.boolean('Allow documents sharing',
|
2014-12-12 21:29:04 +00:00
|
|
|
help="""Share or embbed any screen of Odoo."""),
|
2012-12-16 13:01:14 +00:00
|
|
|
'module_portal': fields.boolean('Activate the customer portal',
|
2012-12-17 08:30:17 +00:00
|
|
|
help="""Give your customers access to their documents."""),
|
2012-09-12 07:14:13 +00:00
|
|
|
'module_auth_oauth': fields.boolean('Use external authentication providers, sign in with google, facebook, ...'),
|
2012-09-11 07:08:58 +00:00
|
|
|
'module_base_import': fields.boolean("Allow users to import data from CSV files"),
|
2013-06-26 15:07:19 +00:00
|
|
|
'module_google_drive': fields.boolean('Attach Google documents to any record',
|
2013-06-26 09:57:36 +00:00
|
|
|
help="""This installs the module google_docs."""),
|
2013-12-16 16:21:47 +00:00
|
|
|
'module_google_calendar': fields.boolean('Allow the users to synchronize their calendar with Google Calendar',
|
|
|
|
help="""This installs the module google_calendar."""),
|
2014-02-17 13:48:19 +00:00
|
|
|
'font': fields.many2one('res.font', string="Report Font", domain=[('mode', 'in', ('Normal', 'Regular', 'all', 'Book'))],
|
|
|
|
help="Set the font into the report header, it will be used as default font in the RML reports of the user company"),
|
|
|
|
|
2012-03-28 06:34:59 +00:00
|
|
|
}
|
2013-09-11 06:32:10 +00:00
|
|
|
|
2013-09-12 11:57:34 +00:00
|
|
|
_defaults= {
|
2013-10-14 09:40:25 +00:00
|
|
|
'font': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.font.id,
|
2013-09-12 11:57:34 +00:00
|
|
|
}
|
|
|
|
|
2012-05-31 07:37:26 +00:00
|
|
|
def open_company(self, cr, uid, ids, context=None):
|
2012-06-22 09:56:57 +00:00
|
|
|
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
2012-05-31 07:37:26 +00:00
|
|
|
return {
|
2012-06-22 09:56:57 +00:00
|
|
|
'type': 'ir.actions.act_window',
|
2012-05-31 07:37:26 +00:00
|
|
|
'name': 'Your Company',
|
|
|
|
'view_type': 'form',
|
2012-06-22 10:20:36 +00:00
|
|
|
'view_mode': 'form',
|
2012-05-31 07:37:26 +00:00
|
|
|
'res_model': 'res.company',
|
2012-06-22 09:56:57 +00:00
|
|
|
'res_id': user.company_id.id,
|
2012-06-29 13:41:51 +00:00
|
|
|
'target': 'current',
|
|
|
|
}
|
2012-06-22 09:49:40 +00:00
|
|
|
|
2013-08-19 12:10:17 +00:00
|
|
|
def _change_header(self, header,font):
|
|
|
|
""" Replace default fontname use in header and setfont tag """
|
|
|
|
|
|
|
|
default_para = re.sub('fontName.?=.?".*"', 'fontName="%s"'% font,header)
|
|
|
|
return re.sub('(<setFont.?name.?=.?)(".*?")(.)', '\g<1>"%s"\g<3>'% font,default_para)
|
2013-09-11 06:32:10 +00:00
|
|
|
|
2013-08-19 12:10:17 +00:00
|
|
|
def set_base_defaults(self, cr, uid, ids, context=None):
|
|
|
|
ir_model_data = self.pool.get('ir.model.data')
|
2013-12-09 13:21:32 +00:00
|
|
|
wizard = self.browse(cr, uid, ids, context)[0]
|
2013-08-19 12:10:17 +00:00
|
|
|
if wizard.font:
|
|
|
|
user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
2013-12-09 13:34:31 +00:00
|
|
|
font_name = wizard.font.name
|
2013-10-14 10:33:08 +00:00
|
|
|
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)})
|
2013-08-19 12:10:17 +00:00
|
|
|
return {}
|
2013-10-03 14:13:50 +00:00
|
|
|
|
2013-10-14 14:53:39 +00:00
|
|
|
def act_discover_fonts(self, cr, uid, ids, context=None):
|
2013-12-09 13:21:32 +00:00
|
|
|
return self.pool.get("res.font").font_scan(cr, uid, context=context)
|
2013-10-14 14:53:39 +00:00
|
|
|
|
2012-06-22 09:49:40 +00:00
|
|
|
# Preferences wizard for Sales & CRM.
|
2014-06-27 12:06:07 +00:00
|
|
|
# It is defined here because it is inherited independently in modules sale, crm.
|
2012-06-22 09:49:40 +00:00
|
|
|
class sale_config_settings(osv.osv_memory):
|
|
|
|
_name = 'sale.config.settings'
|
|
|
|
_inherit = 'res.config.settings'
|
|
|
|
_columns = {
|
2012-09-12 07:14:13 +00:00
|
|
|
'module_web_linkedin': fields.boolean('Get contacts automatically from linkedIn',
|
2012-08-09 12:22:11 +00:00
|
|
|
help="""When you create a new contact (person or company), you will be able to load all the data from LinkedIn (photos, address, etc)."""),
|
2012-06-22 09:49:40 +00:00
|
|
|
'module_crm': fields.boolean('CRM'),
|
2012-11-26 11:19:38 +00:00
|
|
|
'module_sale' : fields.boolean('SALE'),
|
2013-09-13 13:21:50 +00:00
|
|
|
'module_mass_mailing': fields.boolean(
|
|
|
|
'Manage mass mailing campaigns',
|
|
|
|
help='Get access to statistics with your mass mailing, manage campaigns.'),
|
2012-06-22 09:49:40 +00:00
|
|
|
}
|
2013-09-11 06:32:10 +00:00
|
|
|
|
2013-10-02 10:20:36 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|