~elbati/account-invoicing/adding_stock_invoice_picking_7

« back to all changes in this revision

Viewing changes to account_invoice_total/account_invoice_total.py

  • Committer: Stefan Rijnhart
  • Author(s): stephane.bidoul at acsone
  • Date: 2012-12-03 11:53:48 UTC
  • mfrom: (11.1.2 account-invoicing)
  • Revision ID: stefan@therp.nl-20121203115348-gklf0l9n0hckbszc
[NEW] account_invoice_total: bring back account verification total on supplier invoices for OpenERP 6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    account_invoice_total module for OpenERP
 
5
#    Copyright (C) 2012 Ren Dao Solutions (<http://rendaosolutions.com>).
 
6
#    Copyright (C) 2012 Acsone (<http://acsone.eu>).
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU Affero General Public License as
 
10
#    published by the Free Software Foundation, either version 3 of the
 
11
#    License, or (at your option) any later version.
 
12
#
 
13
#    This program is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    GNU Affero General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU Affero General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
from osv import fields, osv
 
24
from tools.translate import _
 
25
 
 
26
class account_invoice_total(osv.osv):
 
27
    _inherit = 'account.invoice'
 
28
  
 
29
    def action_move_create(self, cr, uid, ids, context=None):
 
30
        res = super(account_invoice_total, self).action_move_create(cr, uid, ids, context=context)
 
31
        for inv in self.browse(cr, uid, ids, context=context):
 
32
            if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0):
 
33
                raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.'))
 
34
        return res
 
35
 
 
36
account_invoice_total()
 
37
 
 
38
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: