~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to account_voucher_tax/invoice.py

  • Committer: Gabriela (Vauxoo)
  • Date: 2012-01-02 16:24:49 UTC
  • Revision ID: gabrielaquilarque97@gmail.com-20120102162449-lhxnrtif2ud36du2

[ADD] Added new module invoice_so.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
###########################################################################
3
 
#    Module Writen to OpenERP, Open Source Management Solution
4
 
#
5
 
#    Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
6
 
#    All Rights Reserved.
7
 
#    info@vauxoo.com
8
 
############################################################################
9
 
#    Coded by: Rodo (rodo@vauxoo.com)
10
 
############################################################################
11
 
#
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.
16
 
#
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.
21
 
#
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/>.
24
 
#
25
 
##############################################################################
26
 
 
27
 
from openerp.osv import osv
28
 
from openerp.tools.translate import _
29
 
 
30
 
class invoice(osv.osv):
31
 
    _inherit = 'account.invoice'
32
 
 
33
 
    def invoice_pay_customer(self, cr, uid, ids, context=None):
34
 
        if not ids: return []
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)
38
 
        inv_ids=[]
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'
43
 
        else:
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')]
48
 
        result['context']= {
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,
53
 
                'invoice_id': inv.id,
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'
56
 
            }
57
 
        result['res_id'] = inv_ids and inv_ids[0] or False
58
 
        return result