2
# -*- coding: utf-8 -*-
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2012 TeMPO Consulting, MSF. All Rights Reserved
7
# Developer: Olivier DOSSMANN
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU Affero General Public License for more details.
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
25
from osv import fields
27
class res_company(osv.osv):
29
_inherit = 'res.company'
32
'import_invoice_default_account': fields.many2one('account.account', string="Re-billing Inter-section account",
33
help="Default account for an import invoice on a Debit note"),
34
'intermission_default_counterpart': fields.many2one('account.account', string="Intermission counterpart",
35
help="Default account used for partner in Intermission Voucher IN/OUT"),
36
'additional_allocation': fields.boolean('Additional allocation condition?', help="If you check this attribute, analytic allocation will be required for income accounts with an account code starting with \"7\"; if unchecked, the analytic allocation will be required for all income accounts."),
37
'revaluation_default_account': fields.many2one('account.account', string="Revaluation account",
38
help="Default account used for revaluation"),
41
def check_revaluation_default_account_has_sup_destination(self, cr, uid, company, context=None):
42
if company and company.revaluation_default_account:
43
reval_account = company.revaluation_default_account
44
if reval_account.default_destination_id \
45
and reval_account.default_destination_id.code == 'SUP':
47
for dest in reval_account.destination_ids:
48
if dest.code == 'SUP':
53
def _check_revaluation_default_account(self, cr, uid, ids, context=None):
54
if isinstance(ids, (int, long)):
56
for obj in self.browse(cr, uid, ids, context=context):
57
if not self.check_revaluation_default_account_has_sup_destination(cr, uid, obj, context=context):
58
raise osv.except_osv('Settings Error!','The default revaluation account must have a default destination SUP')
62
(_check_revaluation_default_account, 'The default revaluation account must have a default destination SUP', ['revaluation_default_account'])
66
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: