~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to partner_invoice_description/account_invoice.py

  • Committer: Openerp User
  • Author(s): Vauxoo
  • Date: 2012-07-26 20:13:13 UTC
  • Revision ID: openerp@ingelub-erp-20120726201313-cgffyvd3zmqhn2w4

[FIX] bug a la hora de confirmar una orden de venta cuando el producto es de tipo servicio 
tomaba dicho porducto como si este fuera almacenable y tuviera stock cosa que no es asi 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
 
###########################################################################
3
 
#    Module Writen to OpenERP, Open Source Management Solution
4
 
#
5
 
#    Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
6
 
#    All Rights Reserved.
7
 
#    info Vauxoo (info@vauxoo.com)
8
 
############################################################################
9
 
#    Coded by: Luis Torres (luis_t@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 ofres.partner form
19
 
 
20
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
#    GNU Affero General Public License for more details.
22
 
#
23
 
#    You should have received a copy of the GNU Affero General Public License
24
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
#
26
 
##############################################################################
27
 
from openerp.osv import osv, fields
28
 
 
29
 
 
30
 
class account_invoice(osv.Model):
31
 
    _inherit = 'account.invoice'
32
 
 
33
 
    def onchange_partner_id(self, cr, uid, ids, type, partner_id,
34
 
                            date_invoice=False, payment_term=False,
35
 
                            partner_bank_id=False, company_id=False):
36
 
        res = super(
37
 
            account_invoice, self).onchange_partner_id(cr, uid, ids, type,
38
 
                    partner_id, date_invoice=date_invoice,
39
 
                    payment_term=payment_term, partner_bank_id=partner_bank_id,
40
 
                    company_id=company_id)
41
 
        if partner_id:
42
 
            partner_invoice_description = self.pool.get(
43
 
                'res.partner').browse(cr, uid, partner_id).description_invoice
44
 
            res['value'].update({'comment': partner_invoice_description})
45
 
        return res
46
 
 
47
 
 
48
 
class stock_invoice_onshipping(osv.TransientModel):
49
 
    _inherit = 'stock.invoice.onshipping'
50
 
 
51
 
    def create_invoice(self, cr, uid, ids, context=None):
52
 
        if not context:
53
 
            context = {}
54
 
        res = super(stock_invoice_onshipping, self).create_invoice(
55
 
            cr, uid, ids, context=context)
56
 
        invoice_ids = context['active_ids']
57
 
        for invoice_id in invoice_ids:
58
 
            invoice_description = self.pool.get('account.invoice').browse(
59
 
                cr, uid, res[invoice_id]).partner_id.description_invoice
60
 
            if invoice_description:
61
 
                self.pool.get('account.invoice').write(cr, uid, res[
62
 
                                invoice_id], {'comment': invoice_description})
63
 
        return res
64
 
 
65
 
 
66
 
class sale_make_invoice(osv.TransientModel):
67
 
    _inherit = 'sale.make.invoice'
68
 
 
69
 
    def make_invoices(self, cr, uid, ids, context=None):
70
 
        if not context:
71
 
            context = {}
72
 
        res = super(sale_make_invoice, self).make_invoices(
73
 
            cr, uid, ids, context=context)
74
 
        id_invoice = eval(res['domain'])
75
 
        ids_invoices = id_invoice[0][2]
76
 
        for invoice_id in ids_invoices:
77
 
            invoice_description = self.pool.get('account.invoice').browse(
78
 
                cr, uid, invoice_id).partner_id.description_invoice
79
 
            if invoice_description:
80
 
                self.pool.get('account.invoice').write(
81
 
                    cr, uid, invoice_id, {'comment': invoice_description})
82
 
        return res
83
 
 
84
 
 
85
 
class sale_order(osv.Model):
86
 
    _inherit = 'sale.order'
87
 
 
88
 
    def action_invoice_create(self, cr, uid, ids, grouped=False,
89
 
                                states=['confirmed', 'done', 'exception'],
90
 
                                date_inv=False, context=None):
91
 
        if not context:
92
 
            context = {}
93
 
        res = super(sale_order, self).action_invoice_create(cr, uid, ids,
94
 
                    grouped=False, states=['confirmed', 'done', 'exception'],
95
 
                    date_inv=date_inv, context=context)
96
 
        invoice_description = self.pool.get('account.invoice').browse(
97
 
            cr, uid, res).partner_id.description_invoice
98
 
        if invoice_description:
99
 
            self.pool.get('account.invoice').write(
100
 
                cr, uid, res, {'comment': invoice_description})
101
 
        return res