1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: Luis Torres (luis_t@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 ofres.partner form
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU Affero General Public License for more details.
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/>.
26
##############################################################################
27
from openerp.osv import osv, fields
30
class account_invoice(osv.Model):
31
_inherit = 'account.invoice'
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):
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)
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})
48
class stock_invoice_onshipping(osv.TransientModel):
49
_inherit = 'stock.invoice.onshipping'
51
def create_invoice(self, cr, uid, ids, context=None):
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})
66
class sale_make_invoice(osv.TransientModel):
67
_inherit = 'sale.make.invoice'
69
def make_invoices(self, cr, uid, ids, context=None):
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})
85
class sale_order(osv.Model):
86
_inherit = 'sale.order'
88
def action_invoice_create(self, cr, uid, ids, grouped=False,
89
states=['confirmed', 'done', 'exception'],
90
date_inv=False, context=None):
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})