1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# $Id: letter.py 1304 2005-09-08 14:35:42Z nicoe $
8
# WARNING: This program as such is intended to be used by professional
9
# programmers who take the whole responsability of assessing all potential
10
# consequences resulting from its eventual inadequacies and bugs
11
# End users who are looking for a ready-to-use solution with commercial
12
# garantees and support are strongly adviced to contract a Free Software
15
# This program is Free Software; you can redistribute it and/or
16
# modify it under the terms of the GNU General Public License
17
# as published by the Free Software Foundation; either version 2
18
# of the License, or (at your option) any later version.
20
# This program is distributed in the hope that it will be useful,
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
# GNU General Public License for more details.
25
# You should have received a copy of the GNU General Public License
26
# along with this program; if not, write to the Free Software
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
##############################################################################
31
from osv import fields,osv, orm
37
class letter_paragraph_type(osv.osv):
38
_name = "letter.paragraph.type"
40
'name': fields.char('Paragraph Type', size=60, required=True),
41
'sequence': fields.integer('Sequence', required=True),
43
letter_paragraph_type()
45
class letter_paragraph(osv.osv):
46
_name = "letter.paragraph"
48
'name': fields.char('Paragraph Name', size=60, required=True),
49
'sequence': fields.integer('Sequence'),
50
'type_id': fields.many2one('letter.paragraph.type', 'Paragraph Type'),
51
'content': fields.text('Content'),
55
class letter_letter_type(osv.osv):
56
_name = "letter.letter.type"
58
'name': fields.char('Name', size=60, required=True),
59
'template': fields.selection([('default','Default Template')], 'Template', required=True),
60
'paragraph_ids': fields.many2many('letter.paragraph', 'letter_letter_paragraph_rel', 'letter_id','paragraph_id', 'Defaults Paragraphs')
64
class letter_letter(osv.osv):
65
_name = "letter.letter"
67
'name': fields.char('Name', size=60, required=True),
68
'partner_id': fields.many2one('res.partner', 'Partner', required=True),
69
'type_id': fields.many2one('letter.letter.type', 'Letter Type', required=True),
70
'state': fields.selection([('draft', 'Draft'),('confirmed','Confirmed')], 'State', required=True),
71
'paragraph_ids': fields.one2many('letter.letter.paragraph','letter_id', 'Letter')
74
'state': lambda *a: 'draft',
77
def onchange_type_id(self, cr, uid, ids, type_id):
79
letter = pooler.get_pool(cr.dbname).get('letter.letter.type').browse(cr, uid, type_id)[0]
80
return {'value':{'paragraph_ids': [x.id for x in letter.paragraph_ids]}}
82
return {'value':{'paragraph_ids': []}}
86
class letter_letter_paragraph(osv.osv):
87
_name = "letter.letter.paragraph"
89
'sequence': fields.integer('Sequence'),
90
'name': fields.char('Paragraph Name', size=60, required=True),
91
'letter_id': fields.many2one('letter.letter', 'Letter'),
92
'type_id': fields.many2one('letter.paragraph.type', 'Paragraph Type'),
93
'content': fields.text('Content'),
95
letter_letter_paragraph()