1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
5
# @author Bessi Nicolas, Vicent Renaville
7
# WARNING: This program as such is intended to be used by professional
8
# programmers who take the whole responsability of assessing all potential
9
# consequences resulting from its eventual inadequacies and bugs
10
# End users who are looking for a ready-to-use solution with commercial
11
# garantees and support are strongly adviced to contract a Free Software
14
# This program is Free Software; you can redistribute it and/or
15
# modify it under the terms of the GNU General Public License
16
# as published by the Free Software Foundation; either version 2
17
# of the License, or (at your option) any later version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
##############################################################################
29
from openerp.osv.orm import Model, fields
31
class InvoiceConditionText(Model):
32
"""add info condition in the invoice"""
33
_name = "account.condition_text"
34
_description = "Invoices conditions"
37
'name' : fields.char('Condition summary', required=True, size=128),
38
'type' : fields.selection([('header','Top condition'),
39
('footer','Bottom condition')],
40
'type', required=True),
42
'text': fields.text('Condition', translate=True, required=True)}
44
class AccountInvoice(Model):
45
""" Add account.condition_text to invoice"""
47
_inherit = "account.invoice"
49
def _set_condition(self, cr, uid, inv_id, commentid, key):
50
"""Set the text of the notes in invoices"""
54
lang = self.browse(cr, uid, inv_id)[0].partner_id.lang
57
cond = self.pool.get('account.condition_text').browse(cr, uid, commentid, {'lang': lang})
58
return {'value': {key: cond.text}}
60
def set_header(self, cr, uid, inv_id, commentid):
61
return self._set_condition(cr, uid, inv_id, commentid, 'note1')
63
def set_footer(self, cr, uid, inv_id, commentid):
64
return self._set_condition(cr, uid, inv_id, commentid, 'note2')
66
_columns = {'text_condition1': fields.many2one('account.condition_text', 'Header condition'),
67
'text_condition2': fields.many2one('account.condition_text', 'Footer condition'),
68
'note1' : fields.text('Header'),
69
'note2' : fields.text('Footer'),}