1
# -*- coding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
8
############################################################################
9
# Coded by: Rodo (rodo@vauxoo.com)
10
############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as
14
# published by the Free Software Foundation, either version 3 of the
15
# License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
##############################################################################
27
from openerp.osv import osv
28
from openerp.tools.translate import _
30
class invoice(osv.osv):
31
_inherit = 'account.invoice'
33
def invoice_pay_customer(self, cr, uid, ids, context=None):
35
mod_obj = self.pool.get('ir.model.data')
36
act_obj = self.pool.get('ir.actions.act_window')
37
inv = self.browse(cr, uid, ids[0], context=context)
39
result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'action_voucher_list')
40
id = result and result[1] or False
41
if inv.type == 'out_invoice' or inv.type=='out_refund':
42
view_type='view_vendor_receipt_form'
44
view_type='view_vendor_payment_form'
45
res = mod_obj.get_object_reference(cr, uid, 'account_voucher', view_type)
46
result = act_obj.read(cr, uid, [id], context=context)[0]
47
result['views'] = [(res and res[1] or False, 'form')]
49
'default_partner_id': self.pool.get('res.partner')._find_accounting_partner(inv.partner_id).id,
50
'default_amount': inv.type in ('out_refund', 'in_refund') and -inv.residual or inv.residual,
51
'default_reference': inv.name,
52
'invoice_type': inv.type,
54
'default_type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment',
55
'type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment'
57
result['res_id'] = inv_ids and inv_ids[0] or False