~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to account_move_nonzero/account_move_line.py

  • Committer: Jose Antonio
  • Author(s): Vauxoo
  • Date: 2012-03-27 19:17:09 UTC
  • mto: This revision was merged to the branch mainline in revision 186.
  • Revision ID: jose@vauxoo.com-20120327191709-j5out2jdy19a5yxv

[ADD] Added module to add date and time in the invoice for compute products costs

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 openerp.osv import osv, fields
26
 
 
27
 
 
28
 
class account_move_line(osv.Model):
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
 
    _constraints = [
43
 
        (_update_check_nonzero,
44
 
         'You can not create an entry with zero balance !\
45
 
         Please set amount !', []),
46
 
    ]