~icsergio/openobject-italia/account_invoice_sequential_dates

« back to all changes in this revision

Viewing changes to l10n_it_ricevute_bancarie/configurazione.py

  • Committer: Lorenzo Battistini
  • Date: 2012-07-30 14:19:28 UTC
  • Revision ID: lorenzo.battistini@agilebg.com-20120730141928-ybf0puxbr9chuxy4
[REM] l10n_it_ricevute_bancarie*

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#    
4
 
#    Copyright (C) 2012 Andrea Cometa.
5
 
#    Email: info@andreacometa.it
6
 
#    Web site: http://www.andreacometa.it
7
 
#    Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
8
 
#    Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
9
 
#    Copyright (C) 2012 Associazione OpenERP Italia
10
 
#    (<http://www.openerp-italia.org>).
11
 
#    All Rights Reserved
12
 
#
13
 
#    This program is free software: you can redistribute it and/or modify
14
 
#    it under the terms of the GNU Affero General Public License as published
15
 
#    by the Free Software Foundation, either version 3 of the License, or
16
 
#    (at your option) any later version.
17
 
#
18
 
#    This program is distributed in the hope that it will be useful,
19
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
#    GNU Affero General Public License for more details.
22
 
#
23
 
#    You should have received a copy of the GNU Affero General Public License
24
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
#
26
 
##############################################################################
27
 
 
28
 
from osv import fields, osv
29
 
 
30
 
class riba_configurazione(osv.osv):
31
 
 
32
 
    _name = "riba.configurazione"
33
 
    _description = "Parametri di configurazione per le Ricevute Bancarie"
34
 
 
35
 
    _columns = {
36
 
        'name' : fields.char("Descrizione", size=64, required=True),
37
 
        'tipo' : fields.selection((('sbf', 'Salvo buon fine'),('incasso', 'Al dopo incasso')), 
38
 
            "Modalità Emissione", required=True),
39
 
        'bank_id' : fields.many2one('res.partner.bank', "Banca",
40
 
            required=True, help="Bank account used for Ri.Ba. issuing"),
41
 
            
42
 
        'acceptance_journal_id' : fields.many2one('account.journal', "Acceptance journal", 
43
 
            domain=[('type', '=', 'bank')], required=True,
44
 
            help="Journal used when Ri.Ba. is accepted by the bank"),
45
 
        'acceptance_account_id' : fields.many2one('account.account', "Acceptance account", 
46
 
            domain=[('type', '=', 'receivable')], required=True, help='Account used when Ri.Ba. is accepted by the bank'),
47
 
            
48
 
        'company_id': fields.many2one('res.company', 'Company',required=True),
49
 
        
50
 
        'accreditation_journal_id' : fields.many2one('account.journal', "Accreditation journal", 
51
 
            domain=[('type', '=', 'bank')],
52
 
            help="Journal used when Ri.Ba. amount is accredited by the bank"),
53
 
        'accreditation_account_id' : fields.many2one('account.account', "Ri.Ba. bank account", help='Account used when Ri.Ba. is accepted by the bank'),
54
 
        'bank_account_id' : fields.many2one('account.account', "Bank account", 
55
 
            domain=[('type', '=', 'liquidity')]),
56
 
        'bank_expense_account_id' : fields.many2one('account.account', "Bank Expenses account"),
57
 
        
58
 
        'unsolved_journal_id' : fields.many2one('account.journal', "Unsolved journal", 
59
 
            domain=[('type', '=', 'bank')],
60
 
            help="Journal used when Ri.Ba. is unsolved"),
61
 
        'overdue_effects_account_id' : fields.many2one('account.account', "Overdue Effects account", 
62
 
            domain=[('type', '=', 'receivable')]),
63
 
        'protest_charge_account_id' : fields.many2one('account.account', "Protest charge account"),
64
 
    }
65
 
 
66
 
    _defaults = {
67
 
        'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'riba.configurazione', context=c),
68
 
    }
69
 
    
70
 
    def get_default_value_by_distinta(self, cr, uid, field_name, context=None):
71
 
        if context is None:
72
 
            context = {}
73
 
        if not context.get('active_id', False):
74
 
            return False
75
 
        distinta_pool = self.pool.get('riba.distinta')
76
 
        distinta = distinta_pool.browse(cr, uid, context['active_id'], context=context)
77
 
        return distinta.config[field_name] and distinta.config[field_name].id or False
78
 
    
79
 
    def get_default_value_by_distinta_line(self, cr, uid, field_name, context=None):
80
 
        if context is None:
81
 
            context = {}
82
 
        if not context.get('active_id', False):
83
 
            return False
84
 
        distinta_line = self.pool.get('riba.distinta.line').browse(cr, uid, context['active_id'], context=context)
85
 
        return distinta_line.distinta_id.config[field_name] and distinta_line.distinta_id.config[field_name].id or False
86
 
 
87
 
riba_configurazione()
88