~shineit/openerp-china/pdf-font-for-any-language

« back to all changes in this revision

Viewing changes to oecn_base_fonts/oecn_base_fonts_config.py

  • Committer: jeff
  • Date: 2011-12-22 07:46:10 UTC
  • Revision ID: jeff@jeff-desktop-20111222074610-leyys0p4i6s81csg
pdf fonts replace, next step:_get_system_fonts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# __author__ = jeff@openerp.cn
 
3
##############################################################################
 
4
#
 
5
#    This program is free software: you can redistribute it and/or modify
 
6
#    it under the terms of the GNU Affero General Public License as
 
7
#    published by the Free Software Foundation, either version 3 of the
 
8
#    License, or (at your option) any later version.
 
9
#
 
10
#    This program is distributed in the hope that it will be useful,
 
11
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#    GNU Affero General Public License for more details.
 
14
#
 
15
#    You should have received a copy of the GNU Affero General Public License
 
16
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
#
 
18
##############################################################################
 
19
 
 
20
from osv import fields, osv
 
21
 
 
22
 
 
23
 
 
24
class oecn_base_fonts_map(osv.osv_memory):
 
25
    _name = 'oecn_base_fonts.map'
 
26
    def _system_fonts_get(self, cr, uid, ids, context = None):
 
27
        ''' get fonts list on server '''
 
28
        res = [('font1','font1'),('font2','font2')]
 
29
        return res
 
30
        
 
31
    _columns = {
 
32
        'map_id':fields.many2one('oecn_base_fonts.config','Font Map', required=True),
 
33
        'pdf_font':fields.char('Font in pdf report', size=64, required=True),
 
34
        'new_font':fields.selection(_system_fonts_get, 'Font to display', required=True),
 
35
    }
 
36
    
 
37
oecn_base_fonts_map()
 
38
 
 
39
class oecn_base_fonts_config(osv.osv_memory):
 
40
    _name = 'oecn_base_fonts.config'
 
41
    _inherit = 'res.config'
 
42
 
 
43
    _columns = {
 
44
        'wrap':fields.char('Word Wrap', size=64, required=True),
 
45
        'map_ids':fields.one2many('oecn_base_fonts.map','map_id','Fonts you need to replace in pdf'),
 
46
    }
 
47
    _defaults = {
 
48
        'wrap':'CJK',
 
49
    }
 
50
    def execute(self, cr, uid, ids, context=None):
 
51
        for o in self.browse(cr, uid, ids, context=context):
 
52
            config_obj = self.pool.get('ir.config_parameter')
 
53
            maps = []
 
54
            for map in o.map_ids:
 
55
                maps = maps + [(map.pdf_font, map.new_font)]
 
56
            config_obj.set_param(cr, uid, 'fonts_map', {'wrap':o.wrap,'maps':maps})
 
57
            # print str(config_obj.get_param(cr, uid, 'fonts_map'))
 
58
    
 
59
oecn_base_fonts_config()
 
60
 
 
61
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: