~archetipo/openobject-italia/caritas_pcomod

« back to all changes in this revision

Viewing changes to l10n_it_ri_ba/account_invoice.py

  • Committer: Lorenzo Battistini
  • Date: 2012-06-18 05:50:31 UTC
  • Revision ID: lorenzo.battistini@agilebg.com-20120618055031-hinvyger2pt02amy
[DEL] l10n_it_ri_ba

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#    
4
 
#    Copyright (C) 2011 Associazione OpenERP Italia
5
 
#    (<http://www.openerp-italia.org>).
6
 
#    All Rights Reserved 
7
 
#    Thanks to Cecchi s.r.l http://www.cecchi.com/
8
 
#
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 published by
11
 
#    the Free Software Foundation, either version 3 of the License, or
12
 
#    (at your option) any later version.
13
 
#
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 General Public License for more details.
18
 
#
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/>.
21
 
#
22
 
##############################################################################
23
 
 
24
 
from datetime import datetime
25
 
 
26
 
from osv import fields, osv
27
 
from tools.translate import _
28
 
 
29
 
class Invoice(osv.osv):
30
 
    _inherit = 'account.invoice'
31
 
 
32
 
    def search_move_id_riba(self, cr, uid, ids, context):
33
 
       """Invoices on Payments_Term Riba True"""
34
 
       cr.execute(""" SELECT ai.move_id
35
 
          FROM account_invoice ai
36
 
          INNER JOIN account_payment_term pt ON (ai.payment_term = pt.id)
37
 
          WHERE pt.riba = 'True'""")
38
 
       return [x[0] for x in cr.fetchall()]
39
 
 
40
 
 
41
 
    def action_process_riba(self, cr, uid, ids, context=None):
42
 
        if not ids: return []
43
 
        inv = self.browse(cr, uid, ids[0], context=context)
44
 
        if inv.payment_term.riba is True:
45
 
          return {
46
 
            'name':_("Pay Invoice"),
47
 
            'view_mode': 'form',
48
 
            'view_id': False,
49
 
            'view_type': 'form',
50
 
            'res_model': 'account.voucher',
51
 
            'type': 'ir.actions.act_window',
52
 
            'nodestroy': True,
53
 
            'target': 'current',
54
 
            'domain': '[]',
55
 
            'context': {
56
 
                'default_partner_id': inv.partner_id.id,
57
 
                'default_amount': inv.residual,
58
 
                'default_name':inv.internal_number,
59
 
                'close_after_process': True,
60
 
                'invoice_type':inv.type,
61
 
                'invoice_id':inv.id,
62
 
                'default_type': inv.type in ('out_invoice') and 'receipt' or 'payment'
63
 
                }
64
 
        }
65
 
 
66
 
Invoice()
67
 
 
68
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: