~vauxoo/addons-vauxoo/7.0-project_issue_conf-dev_luis

« back to all changes in this revision

Viewing changes to account_move_nonzero/account_move_line.py

  • Committer: Javier Duran
  • Author(s): javier at vauxoo
  • Date: 2012-05-04 17:35:59 UTC
  • Revision ID: javier@squezee-vir-20120504173559-i0sqz1vw1mjoc9uy
[ADD] Se incorpora modulo para la validación de apuntes con saldo diferente de cero

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- encoding: utf-8 -*-
 
3
###########################################################################
 
4
#    Module Writen to OpenERP, Open Source Management Solution
 
5
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
6
#    All Rights Reserved
 
7
###############Credits######################################################
 
8
#    Coded by: javier@vauxoo.com
 
9
#    Audited by: Vauxoo C.A.
 
10
#############################################################################
 
11
#    This program is free software: you can redistribute it and/or modify
 
12
#    it under the terms of the GNU Affero General Public License as published by
 
13
#    the Free Software Foundation, either version 3 of the License, or
 
14
#    (at your option) any later version.
 
15
#
 
16
#    This program is distributed in the hope that it will be useful,
 
17
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
#    GNU Affero General Public License for more details.
 
20
#
 
21
#    You should have received a copy of the GNU Affero General Public License
 
22
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
23
################################################################################
 
24
 
 
25
from osv import fields, osv
 
26
 
 
27
 
 
28
class account_move_line(osv.osv):
 
29
    _inherit = 'account.move.line'
 
30
    
 
31
    '''
 
32
    Check that the entry balance is greater than zero
 
33
    '''
 
34
    def _update_check_nonzero(self, cr, uid, ids, context=None):
 
35
        writeoff = 0.0
 
36
        for line in self.browse(cr, uid, ids, context=context):
 
37
            writeoff = abs(line.debit - line.credit)
 
38
            if writeoff == 0.0:
 
39
                return False
 
40
        return True
 
41
 
 
42
 
 
43
    _constraints = [
 
44
        (_update_check_nonzero, 'You can not create an entry with zero balance ! Please set amount !', []),
 
45
    ]
 
46
 
 
47
 
 
48
 
 
49
account_move_line()
 
50