1
# -*- coding: utf-8 -*-
2
##############################################################################
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>).
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.
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.
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/>.
26
##############################################################################
28
from osv import fields, osv
30
class riba_configurazione(osv.osv):
32
_name = "riba.configurazione"
33
_description = "Parametri di configurazione per le Ricevute Bancarie"
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"),
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'),
48
'company_id': fields.many2one('res.company', 'Company',required=True),
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"),
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"),
67
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'riba.configurazione', context=c),
70
def get_default_value_by_distinta(self, cr, uid, field_name, context=None):
73
if not context.get('active_id', 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
79
def get_default_value_by_distinta_line(self, cr, uid, field_name, context=None):
82
if not context.get('active_id', 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