1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 from osv import fields, osv
25 class res_company(osv.osv):
26 _inherit = "res.company"
28 'overdue_msg' : fields.text('Overdue Payments Message', translate=True),
32 'overdue_msg': lambda *a: 'Would your payment have been carried \
33 out after this mail was sent, please consider the present one as \
34 void. Do not hesitate to contact our accounting department'
38 class company_setup(osv.osv_memory):
40 Insert Information for a company.
42 * A Company with its partner
43 * Insert a suitable message for Overdue Payment Report.
45 _name='wizard.company.setup'
48 'company_id':fields.many2one('res.company','Company',required=True),
49 'partner_id':fields.many2one('res.partner','Partner'),
50 'overdue_msg': fields.text('Overdue Payment Message'),
52 def get_message(self,cr,uid,context={}):
53 company =self.pool.get('res.users').browse(cr,uid,[uid],context)[0].company_id
54 msg = company.overdue_msg
55 phone = company.partner_id.address and (company.partner_id.address[0].phone and ' at ' + str(company.partner_id.address[0].phone) + '.' or '.') or '.'
60 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.id,
61 'partner_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.partner_id.id,
62 'overdue_msg': get_message,
65 def onchange_company_id(self, cr, uid, ids, company, context=None):
69 comp_obj = self.pool.get('res.company').browse(cr,uid,company)
70 res['partner_id'] = comp_obj.partner_id.id
71 phone = comp_obj.partner_id.address and (comp_obj.partner_id.address[0].phone and ' at ' + str(comp_obj.partner_id.address[0].phone) + '.' or '.') or '.'
72 res['overdue_msg'] = comp_obj.overdue_msg + str(phone)
74 return {'value': res }
76 def action_create(self, cr, uid, ids, context=None):
77 content_wiz = self.pool.get('wizard.company.setup').read(cr,uid,ids,['company_id','overdue_msg'])
79 wiz_data = content_wiz[0]
80 self.pool.get('res.company').write(cr, uid, [wiz_data['company_id']], {'overdue_msg':wiz_data['overdue_msg']})
85 'res_model': 'ir.actions.configuration.wizard',
86 'type': 'ir.actions.act_window',
90 def action_cancel(self,cr,uid,ids,conect=None):
94 'res_model': 'ir.actions.configuration.wizard',
95 'type': 'ir.actions.act_window',