1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2011 Associazione OpenERP Italia
5
# (<http://www.openerp-italia.org>).
7
# Thanks to Cecchi s.r.l http://www.cecchi.com/
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.
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.
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/>.
22
##############################################################################
24
from datetime import datetime
26
from osv import fields, osv
27
from tools.translate import _
29
class Invoice(osv.osv):
30
_inherit = 'account.invoice'
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()]
41
def action_process_riba(self, cr, uid, ids, context=None):
43
inv = self.browse(cr, uid, ids[0], context=context)
44
if inv.payment_term.riba is True:
46
'name':_("Pay Invoice"),
50
'res_model': 'account.voucher',
51
'type': 'ir.actions.act_window',
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,
62
'default_type': inv.type in ('out_invoice') and 'receipt' or 'payment'
68
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: