[IMP] account: removed duplicated entry for journal items to reconcile
[odoo/odoo.git] / addons / l10n_br / l10n_br.py
1 # -*- encoding: utf-8 -*-
2 #################################################################################
3 #                                                                               #
4 # Copyright (C) 2009  Renato Lima - Akretion                                    #
5 #                                                                               #
6 #This program is free software: you can redistribute it and/or modify           #
7 #it under the terms of the GNU Affero General Public License as published by    #
8 #the Free Software Foundation, either version 3 of the License, or              #
9 #(at your option) any later version.                                            #
10 #                                                                               #
11 #This program is distributed in the hope that it will be useful,                #
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of                 #
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                  #
14 #GNU General Public License for more details.                                   #
15 #                                                                               #
16 #You should have received a copy of the GNU General Public License              #
17 #along with this program.  If not, see <http://www.gnu.org/licenses/>.          #
18 #################################################################################
19
20 from osv import fields, osv
21
22 class l10n_br_account_cst_template(osv.osv):
23     _name = 'l10n_br_account.cst.template'
24     _description = 'Tax Situation Code Template' 
25     _columns = {
26                 'code': fields.char('Code', size=8,required=True),
27                 'name': fields.char('Description', size=64),
28                 'tax_code_template_id': fields.many2one('account.tax.code.template', 'Tax Code Template',required=True),
29                 }
30     
31     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
32         if not args:
33             args = []
34         if context is None:
35             context = {}
36         ids = self.search(cr, user, ['|',('name',operator,name),('code',operator,name)] + args, limit=limit, context=context)
37         return self.name_get(cr, user, ids, context)
38     
39     def name_get(self, cr, uid, ids, context=None):
40         if not ids:
41             return []
42         reads = self.read(cr, uid, ids, ['name', 'code'], context=context)
43         res = []
44         for record in reads:
45             name = record['name']
46             if record['code']:
47                 name = record['code'] + ' - '+name
48             res.append((record['id'], name))
49         return res
50     
51 l10n_br_account_cst_template()
52
53 class l10n_br_account_cst(osv.osv):
54     _name = 'l10n_br_account.cst'
55     _description = 'Tax Situation Code'
56     _columns = {
57                 'code': fields.char('Code', size=8,required=True),
58                 'name': fields.char('Description', size=64),
59                 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code',required=True),
60                 }
61     
62     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
63         if not args:
64             args = []
65         if context is None:
66             context = {}
67         ids = self.search(cr, user, ['|',('name',operator,name),('code',operator,name)] + args, limit=limit, context=context)
68         return self.name_get(cr, user, ids, context)
69     
70     def name_get(self, cr, uid, ids, context=None):
71         if not ids:
72             return []
73         reads = self.read(cr, uid, ids, ['name', 'code'], context=context)
74         res = []
75         for record in reads:
76             name = record['name']
77             if record['code']:
78                 name = record['code'] + ' - '+name
79             res.append((record['id'], name))
80         return res
81     
82 l10n_br_account_cst()
83
84 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: