From 646bae0c50c965a5fc9124ebec693cb4bde7d827 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Sat, 3 Jul 2010 15:00:47 +0530 Subject: [PATCH] [IMP] Account_followup: Cleaning and improvement in module (Print report has still problem) bzr revid: mra@mra-laptop-20100703093047-2mdpngvqmvtnzlb0 --- addons/account_followup/__init__.py | 11 ++- addons/account_followup/__openerp__.py | 15 ++--- .../{followup.py => account_followup.py} | 27 +++++--- ...wup_data.xml => account_followup_data.xml} | 0 ...wup_demo.xml => account_followup_demo.xml} | 0 ...p_report.py => account_followup_report.py} | 0 ...t_view.xml => account_followup_report.xml} | 0 ...wup_view.xml => account_followup_view.xml} | 67 +++++++++++-------- .../report/report_followup_print.py | 14 ++-- .../wizard/account_followup_print.py | 40 +++++++---- .../wizard/account_followup_print_view.xml | 11 --- 11 files changed, 102 insertions(+), 83 deletions(-) rename addons/account_followup/{followup.py => account_followup.py} (89%) rename addons/account_followup/{followup_data.xml => account_followup_data.xml} (100%) rename addons/account_followup/{followup_demo.xml => account_followup_demo.xml} (100%) rename addons/account_followup/{followup_report.py => account_followup_report.py} (100%) rename addons/account_followup/{followup_report_view.xml => account_followup_report.xml} (100%) rename addons/account_followup/{followup_view.xml => account_followup_view.xml} (85%) diff --git a/addons/account_followup/__init__.py b/addons/account_followup/__init__.py index 3065bef0130..b0067573a2f 100644 --- a/addons/account_followup/__init__.py +++ b/addons/account_followup/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,14 +15,13 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## -import followup -import followup_report +import account_followup +import account_followup_report import wizard import report -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_followup/__openerp__.py b/addons/account_followup/__openerp__.py index 81a5cb79cee..5aefa0abc96 100644 --- a/addons/account_followup/__openerp__.py +++ b/addons/account_followup/__openerp__.py @@ -19,7 +19,6 @@ # ############################################################################## - { 'name': 'Accounting follow-ups management', 'version': '1.0', @@ -36,11 +35,10 @@ It will generate a PDF with all the letters according the the different levels of recall defined. You can define different policies - for different companies. - + for different companies. You can send also mail to the customer. Note that if you want to change the followup level for a given partner/account entry, you can do it in the menu: - Financial Management/Reporting/Follow-Ups/All receivable entries + Accounting/Reporting/Follow-Ups/All receivable entries """, 'author': 'Tiny', @@ -50,13 +48,14 @@ 'update_xml': [ 'security/ir.model.access.csv', 'wizard/account_followup_print_view.xml', - 'followup_report_view.xml', - 'followup_view.xml', - 'followup_data.xml' + 'account_followup_report.xml', + 'account_followup_view.xml', + 'account_followup_data.xml' ], - 'demo_xml': ['followup_demo.xml'], + 'demo_xml': ['account_followup_demo.xml'], 'installable': True, 'active': False, 'certificate': '0072481076453', } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_followup/followup.py b/addons/account_followup/account_followup.py similarity index 89% rename from addons/account_followup/followup.py rename to addons/account_followup/account_followup.py index c8bf9537f13..02986acb184 100644 --- a/addons/account_followup/followup.py +++ b/addons/account_followup/account_followup.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -23,13 +23,17 @@ from osv import fields, osv class followup(osv.osv): _name = 'account_followup.followup' - _description = 'Follow-Up' + _description = 'Account Follow Up' _columns = { 'name': fields.char('Name', size=64, required=True), 'description': fields.text('Description'), 'followup_line': fields.one2many('account_followup.followup.line', 'followup_id', 'Follow-Up'), 'company_id': fields.many2one('res.company', 'Company'), } + _defaults = { + 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'account_followup.followup', context=c), + } + followup() class followup_line(osv.osv): @@ -42,26 +46,27 @@ class followup_line(osv.osv): 'start': fields.selection([('days','Net Days'),('end_of_month','End of Month')], 'Type of Term', size=64, required=True), 'followup_id': fields.many2one('account_followup.followup', 'Follow Ups', required=True, ondelete="cascade"), 'description': fields.text('Printed Message', translate=True), - } + } + followup_line() class account_move_line(osv.osv): - _name = 'account.move.line' _inherit = 'account.move.line' _columns = { 'followup_line_id': fields.many2one('account_followup.followup.line', 'Follow-up Level'), 'followup_date': fields.date('Latest Follow-up'), - } + } + account_move_line() class res_company(osv.osv): _inherit = "res.company" _columns = { 'follow_up_msg' : fields.text('Follow-up Message', translate=True), - } + } _defaults = { - 'overdue_msg': lambda *a: ''' + 'overdue_msg': ''' Date : %(date)s Dear %(partner_name)s, @@ -75,8 +80,8 @@ Thanks, %(user_signature)s %(company_name)s ''' - } + } + res_company() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_followup/followup_data.xml b/addons/account_followup/account_followup_data.xml similarity index 100% rename from addons/account_followup/followup_data.xml rename to addons/account_followup/account_followup_data.xml diff --git a/addons/account_followup/followup_demo.xml b/addons/account_followup/account_followup_demo.xml similarity index 100% rename from addons/account_followup/followup_demo.xml rename to addons/account_followup/account_followup_demo.xml diff --git a/addons/account_followup/followup_report.py b/addons/account_followup/account_followup_report.py similarity index 100% rename from addons/account_followup/followup_report.py rename to addons/account_followup/account_followup_report.py diff --git a/addons/account_followup/followup_report_view.xml b/addons/account_followup/account_followup_report.xml similarity index 100% rename from addons/account_followup/followup_report_view.xml rename to addons/account_followup/account_followup_report.xml diff --git a/addons/account_followup/followup_view.xml b/addons/account_followup/account_followup_view.xml similarity index 85% rename from addons/account_followup/followup_view.xml rename to addons/account_followup/account_followup_view.xml index ae31f7253a2..50c1cb5df34 100644 --- a/addons/account_followup/followup_view.xml +++ b/addons/account_followup/account_followup_view.xml @@ -1,7 +1,7 @@ - + account_followup.followup.line.tree account_followup.followup.line @@ -15,40 +15,39 @@ - + account_followup.followup.line.form account_followup.followup.line form
- - - - + + + + - + - -
- + account_followup.followup.form account_followup.followup form
- - + + - - + + @@ -66,17 +65,30 @@
+ + account.followup.select + account_followup.followup + search + + + + + + + + + Follow-Ups ir.actions.act_window account_followup.followup + form - + - - + account.move.line.partner.tree account.move.line @@ -99,7 +111,7 @@ - + account.move.line.form.followup account.move.line @@ -111,7 +123,7 @@ - + account.move.line.tree.followup account.move.line @@ -123,17 +135,17 @@ - + - + - + - + - + - + res.company.followup.form.inherit @@ -146,5 +158,6 @@ +
diff --git a/addons/account_followup/report/report_followup_print.py b/addons/account_followup/report/report_followup_print.py index 4f1df09c302..08c572a5ba9 100644 --- a/addons/account_followup/report/report_followup_print.py +++ b/addons/account_followup/report/report_followup_print.py @@ -30,12 +30,12 @@ class report_rappel(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(report_rappel, self).__init__(cr, uid, name, context=context) self.localcontext.update( { - 'time' : time, + 'time': time, 'ids_to_objects': self._ids_to_objects, - 'adr_get' : self._adr_get, - 'getLines' : self._lines_get, - 'get_text' : self._get_text - }) + 'adr_get': self._adr_get, + 'getLines': self._lines_get, + 'get_text': self._get_text + }) def _ids_to_objects(self, partners_ids): pool = pooler.get_pool(self.cr.dbname) @@ -91,10 +91,8 @@ class report_rappel(report_sxw.rml_parse): return text - report_sxw.report_sxw('report.account_followup.followup.print', 'res.partner', 'addons/account_followup/report/rappel.rml', parser=report_rappel) -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index d7327638669..868249365ee 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -34,25 +34,32 @@ class account_followup_print(osv.osv_memory): } def _get_followup(self, cr, uid, context=None): + if context is None: + context = {} + if context.get('active_model', 'ir.ui.menu') == 'account_followup.followup': + return context.get('active_id', False) company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id - tmp = self.pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)]) - return tmp and tmp[0] or False + followp_id = self.pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)], context=context) + return followp_id and followp_id[0] or False def do_continue(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') + + if context is None: + context = {} data = self.read(cr, uid, ids, [])[0] model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] context.update({'followup_id': data['followup_id'], 'date':data['date']}) return { - 'name': _('Select partners'), - 'view_type': 'form', - 'context': context, - 'view_mode': 'tree,form', - 'res_model': 'account.followup.print.all', - 'views': [(resource_id,'form')], - 'type': 'ir.actions.act_window', - 'target': 'new', + 'name': _('Select Partners'), + 'view_type': 'form', + 'context': context, + 'view_mode': 'tree,form', + 'res_model': 'account.followup.print.all', + 'views': [(resource_id,'form')], + 'type': 'ir.actions.act_window', + 'target': 'new', } _defaults = { @@ -74,10 +81,12 @@ class account_followup_print_all(osv.osv_memory): 'summary': fields.text('Summary', required=True, readonly=True) } def _get_summary(self, cr, uid, context=None): + if context is None: + context = {} return context.get('summary', '') def _get_partners(self, cr, uid, context=None): - return self._get_partners_followp(cr, uid, [], context)['partner_ids'] + return self._get_partners_followp(cr, uid, [], context=context)['partner_ids'] def _get_msg(self, cr, uid, context=None): return self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg @@ -168,6 +177,9 @@ class account_followup_print_all(osv.osv_memory): move_obj = self.pool.get('account.move.line') user_obj = self.pool.get('res.users') line_obj = self.pool.get('account_followup.stat') + + if context is None: + context = {} data = self.read(cr, uid, ids, [])[0] model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] @@ -252,8 +264,9 @@ class account_followup_print_all(osv.osv_memory): context.update({'summary': summary}) else: context.update({'summary': '\n\n\nE-Mail has not been sent to any partner. If you want to send it, please tick send email confirmation on wizard.'}) + return { - 'name': _('Summary'), + 'name': _('Follwoup Summary'), 'view_type': 'form', 'context': context, 'view_mode': 'tree,form', @@ -265,6 +278,8 @@ class account_followup_print_all(osv.osv_memory): } def do_print(self, cr, uid, ids, context=None): + if context is None: + context = {} data = self.read(cr, uid, ids, [])[0] res = self._get_partners_followp(cr, uid, ids, context)['to_update'] to_update = res @@ -284,6 +299,7 @@ class account_followup_print_all(osv.osv_memory): 'model': 'account_followup.followup', 'form': data } + return { 'type': 'ir.actions.report.xml', 'report_name': 'account_followup.followup.print', diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml index 9e0c34c8bf5..a97e54347cb 100644 --- a/addons/account_followup/wizard/account_followup_print_view.xml +++ b/addons/account_followup/wizard/account_followup_print_view.xml @@ -2,17 +2,6 @@ - - - account.followup.print.form account.followup.print