1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: Luis Torres (luis_t@vauxoo.com)
10
############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as
14
# published by the Free Software Foundation, either version 3 of the
15
# License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
##############################################################################
26
from osv import fields, osv
27
from tools.translate import _
29
class account_account(osv.osv):
30
_inherit='account.account'
33
'analytic_required': fields.boolean('Analytic Required'),
39
class account_move(osv.osv):
40
_inherit='account.move'
42
def button_validate(self, cursor, user, ids, context=None):
43
account_move_obj=self.pool.get('account.move.line')
44
account_obj=self.pool.get('account.account')
45
moves=account_move_obj.search(cursor, user, [('move_id', 'in', ids)])
48
move=account_move_obj.browse(cursor, user, move_id)
49
name_move=move.name or ''
50
analytic_st=move.account_id and move.account_id.analytic_required or False
51
if analytic_st is True:
52
account_move_id=move.account_id and move.account_id.id or False
53
analytic_acc_move=move.analytic_account_id and move.analytic_account_id.id or False
54
if analytic_acc_move is False:
55
raise osv.except_osv(_('Error'), _('Need add analytic account in move whit name '+ name_move + '.'))
56
res=super(account_move, self).button_validate(cursor, user, ids, context=context)