diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 09f7ad35d8c..80f6b97e3c9 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1472,7 +1472,7 @@ diff --git a/addons/account/report/rappel.py b/addons/account/report/rappel.py index 6adad5e5857..11cf9432286 100644 --- a/addons/account/report/rappel.py +++ b/addons/account/report/rappel.py @@ -51,13 +51,14 @@ class report_rappel(report_sxw.rml_parse): return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False def _lines_get(self, partner): - part = pooler.get_pool(self.cr.dbname).get('res.partner') - acc = partner.property_account_receivable[0] moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - movelines = moveline_obj.search(self.cr, self.uid, [('partner_id','=',partner.id), ('account_id','=',acc), ('state','=','valid'), ('date_maturity', '=', False)]) - movelines += moveline_obj.search(self.cr, self.uid, [('partner_id','=',partner.id), ('account_id','=',acc), ('state','=','valid'), ('date_maturity', '<=', time.strftime('%Y-%m-%d'))]) + movelines = moveline_obj.search(self.cr, self.uid, + [('partner_id', '=', partner.id), + ('account_id.type', 'in', ['receivable', 'payable']), + ('state', '<>', 'draft'), ('reconcile_id', '=', False)]) movelines = moveline_obj.read(self.cr, self.uid, movelines) return movelines -report_sxw.report_sxw('report.account.rappel', 'res.partner', 'addons/account/report/rappel.rml',parser=report_rappel) +report_sxw.report_sxw('report.account.rappel', 'res.partner', + 'addons/account/report/rappel.rml', parser=report_rappel) diff --git a/addons/account_followup/followup_report.py b/addons/account_followup/followup_report.py index 1ad17befde1..a8d28ae3d55 100644 --- a/addons/account_followup/followup_report.py +++ b/addons/account_followup/followup_report.py @@ -43,11 +43,12 @@ class account_followup_stat(osv.osv): _auto = False _columns = { 'name': fields.many2one('res.partner', 'Partner', readonly=True), - 'account_type': fields.selection(_code_get, 'Account Type', required=True), + 'account_type': fields.selection(_code_get, 'Account Type', readonly=True), 'date_move':fields.date('First move', readonly=True), 'date_move_last':fields.date('Last move', readonly=True), 'date_followup':fields.date('Latest followup', readonly=True), - 'followup_id': fields.many2one('account_followup.followup.line', 'Follow Ups', required=True, ondelete="cascade"), + 'followup_id': fields.many2one('account_followup.followup.line', + 'Follow Ups', readonly=True, ondelete="cascade"), 'balance':fields.float('Balance', readonly=True), 'debit':fields.float('Debit', readonly=True), 'credit':fields.float('Credit', readonly=True), diff --git a/addons/account_followup/followup_view.xml b/addons/account_followup/followup_view.xml index 09aaa7a4687..e7d5165aeb5 100644 --- a/addons/account_followup/followup_view.xml +++ b/addons/account_followup/followup_view.xml @@ -84,18 +84,41 @@ + + account.move.line.form.followup + account.move.line + + + + + + + + + + + account.move.line.tree.followup + account.move.line + + + + + + + + + - @@ -105,9 +128,9 @@ id="menu_account_move_open_unreconcile"/> diff --git a/addons/account_followup/report/rappel.rml b/addons/account_followup/report/rappel.rml index 9ae9bfec3d7..f2050fdd57b 100644 --- a/addons/account_followup/report/rappel.rml +++ b/addons/account_followup/report/rappel.rml @@ -37,24 +37,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -64,7 +64,7 @@ - [[ repeatIn(ids_to_objects(data['form']['partner_id']),'o') ]] [[ setLang(o.lang) ]] + [[ repeatIn(ids_to_objects(data['form']['partner_ids'][0][2]),'o') ]] [[ setLang(o.lang) ]] @@ -73,147 +73,147 @@ - [[ o.name ]] - [[ adr_get(o, 'invoice')['name'] ]] - [[ adr_get(o, 'invoice')['street'] ]] - [[ adr_get(o, 'invoice')['zip'] ]] [[ adr_get(o, 'invoice')['city'] ]] - [[ adr_get(o, 'invoice')['country_id'][1] ]] - + [[ o.name ]] + [[ adr_get(o, 'invoice')['name'] ]] + [[ adr_get(o, 'invoice')['street'] ]] + [[ adr_get(o, 'invoice')['zip'] ]] [[ adr_get(o, 'invoice')['city'] ]] + [[ adr_get(o, 'invoice')['country_id'][1] ]] + - VAT: [[ o.vat or removeParentNode('para') ]] + VAT: [[ o.vat or removeParentNode('para') ]] - + - + - Document: Customer account statement - + Document: Customer account statement + Date: [[ time.strftime('%d/%m/%Y') ]] - Customer Ref: [[ o.id ]] - + Customer Ref: [[ o.id ]] + - Dear Sir/Madam, - + Dear Sir/Madam, + - Exception made if there was a mistake of ours, it seems that the following bills staid unpaid. Please, take appropriate measures in order to carry out this payment in the next 8 days. - + Exception made if there was a mistake of ours, it seems that the following bills staid unpaid. Please, take appropriate measures in order to carry out this payment in the next 8 days. + - Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at (+32).10.68.94.39. - + Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at (+32).10.68.94.39. + - Best regards. - + Best regards. + - Date + Date - Description + Description - Ref + Ref - Maturity date + Maturity date - Due + Due - Paid + Paid - Maturity + Maturity - Li. + Li. - + [[repeatIn(getLines(o), 'line') ]] [[ line['date'] ]] - [[ line['name'] ]] + [[ line['name'] ]] - [[ line['ref'] ]] + [[ line['ref'] ]] - [[ line['date_maturity'] ]] + [[ line['date_maturity'] ]] - [[ line['debit'] and '%.2f' % line['debit'] or '' ]] + [[ line['debit'] and '%.2f' % line['debit'] or '' ]] - [[ line['credit'] and '%.2f' % line['credit'] or '' ]] + [[ line['credit'] and '%.2f' % line['credit'] or '' ]] - [[ (line['date_maturity'] < time.strftime('%Y-%m-%d')) and (line['debit'] - line['credit']) or '' ]] + [[ (line['date_maturity'] < time.strftime('%Y-%m-%d')) and (line['debit'] - line['credit']) or '' ]] - [[ line['blocked'] and 'X' or '' ]] + [[ line['blocked'] and 'X' or '' ]] - Sub-Total: + Sub-Total: - [[ '%.2f' % (reduce(lambda x,y: x+y['debit'], getLines(o), 0)) ]] + [[ '%.2f' % (reduce(lambda x,y: x+y['debit'], getLines(o), 0)) ]] - + [[ '%.2f' % (reduce(lambda x,y: x+y['credit'], getLines(o), 0)) ]] - [[ reduce(lambda x,y: x+(y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), getLines(o)), 0) ]] + [[ reduce(lambda x,y: x+(y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), getLines(o)), 0) ]] - + - Balance: + Balance: - [[ '%.2f' % (reduce(lambda x,y: x+(y['debit'] - y['credit']), getLines(o), 0)) ]] + [[ '%.2f' % (reduce(lambda x,y: x+(y['debit'] - y['credit']), getLines(o), 0)) ]] - + - + - + @@ -222,11 +222,11 @@ - + Total amount due: [[ '%.2f' % (reduce(lambda x,y: x+(y['debit']-y['credit']), getLines(o), 0)) ]] [[ company.currency_id.name]]. - + diff --git a/addons/account_followup/report/report_followup_print.py b/addons/account_followup/report/report_followup_print.py index 3f46646895a..a5f199047ff 100644 --- a/addons/account_followup/report/report_followup_print.py +++ b/addons/account_followup/report/report_followup_print.py @@ -44,8 +44,9 @@ class report_rappel(report_sxw.rml_parse): }) def _ids_to_objects(self, partners_ids): - toto = pooler.get_pool(self.cr.dbname).get('res.partner').browse(self.cr, self.uid, partners_ids) - return toto + pool = pooler.get_pool(self.cr.dbname) + partners = pool.get('res.partner').browse(self.cr, self.uid, partners_ids) + return partners def _adr_get(self, partner, type): res_partner = pooler.get_pool(self.cr.dbname).get('res.partner') @@ -55,7 +56,13 @@ class report_rappel(report_sxw.rml_parse): def _lines_get(self, partner): moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') - movelines = moveline_obj.search(self.cr, self.uid, [('partner_id','=',partner.id), ('account_id','=','type:receivable'), ('reconcile_id','=',False),('state','<>','draft')]) + movelines = moveline_obj.search(self.cr, self.uid, + [('partner_id', '=', partner.id), + ('account_id.type', '=', 'receivable'), + ('reconcile_id', '=', False), ('state', '<>', 'draft')]) movelines = moveline_obj.read(self.cr, self.uid, movelines) return movelines -report_sxw.report_sxw('report.account_followup.followup.print', 'res.partner', 'addons/account_followup/report/rappel.rml',parser=report_rappel) + +report_sxw.report_sxw('report.account_followup.followup.print', + 'res.partner', 'addons/account_followup/report/rappel.rml', + parser=report_rappel) diff --git a/addons/account_followup/wizard/wizard_followup_print.py b/addons/account_followup/wizard/wizard_followup_print.py index 78d7bd5d91b..db35b8cbbc8 100644 --- a/addons/account_followup/wizard/wizard_followup_print.py +++ b/addons/account_followup/wizard/wizard_followup_print.py @@ -28,26 +28,28 @@ import wizard import datetime import pooler +import time _followup_wizard_all_form = """
- - - - - + + + + + +
""" @@ -84,41 +86,36 @@ Thanks, class followup_all_print(wizard.interface): + def _update_partners(self, cr, uid, data, context): + to_update = data['form']['to_update'] + for id in to_update.keys(): + cr.execute( + "UPDATE account_move_line "\ + "SET followup_line_id=%d, followup_date=%s "\ + "WHERE id=%d", + (to_update[id], + time.strftime('%Y-%m-%d'), int(id),)) + return {} + def _get_partners(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) cr.execute( - "SELECT distinct l.partner_id "\ - "FROM account_move_line AS l LEFT JOIN account_account AS a "\ + "SELECT l.partner_id, l.followup_line_id, l.date, l.id "\ + "FROM account_move_line AS l "\ + "LEFT JOIN account_account AS a "\ "ON (l.account_id=a.id) "\ "WHERE (l.reconcile_id IS NULL) "\ "AND (a.type='receivable') "\ "AND (l.state<>'draft') "\ "AND (l.reconcile_id is NULL) "\ - "AND (l.partner_id is NOT NULL) "\ - "AND a.active ") - ids = map(lambda x: x[0], cr.fetchall()) - return {'partner_ids': ids} - - def _update_partners(self, cr, uid, data, context): - partner_ids = data['form']['partner_ids'][0][2] - if partner_ids: - cr.execute( - "SELECT l.partner_id, l.followup_line_id, l.date, l.id "\ - "FROM account_move_line AS l LEFT JOIN account_account AS a "\ - "ON (l.account_id=a.id) "\ - "WHERE (l.reconcile_id IS NULL) "\ - "AND (a.type='receivable') "\ - "AND (l.state<>'draft') "\ - "AND (l.reconcile_id is NULL) "\ - "AND partner_id in ("+','.join(map(str,partner_ids))+") "\ - "AND a.active "\ - "ORDER BY l.date") - move_lines = cr.fetchall() - else: - move_lines = [] + "AND partner_id is NOT NULL "\ + "AND a.active "\ + "ORDER BY l.date") + move_lines = cr.fetchall() old = None fups = {} - fup_ids = pooler.get_pool(cr.dbname).get('account_followup.followup').search(cr, uid, []) + fup_ids = pool.get('account_followup.followup').search(cr, uid, []) if not fup_ids: raise wizard.except_wizard('No Follow up Defined', 'You must define at least one follow up for your company !') @@ -140,6 +137,7 @@ class followup_all_print(wizard.interface): fups[old] = (datetime.date(datetime.MAXYEAR, 12, 31), old) partner_list = [] + to_update = {} for partner_id, followup_line_id, date, id in move_lines: if (partner_id in partner_list) or (not partner_id): continue @@ -147,13 +145,9 @@ class followup_all_print(wizard.interface): continue if date <= fups[followup_line_id][0].strftime('%Y-%m-%d'): partner_list.append(partner_id) - cr.execute( - "UPDATE account_move_line "\ - "SET followup_line_id=%d, followup_date=%s "\ - "WHERE id=%d", - (fups[followup_line_id][1], - current_date.strftime('%Y-%m-%d'), id,)) - return {'partner_id': partner_list} + to_update[str(id)] = fups[followup_line_id][1] + return {'partner_ids': partner_list, 'to_update': to_update} + states = { 'init' : { 'actions': [_get_partners], @@ -165,7 +159,9 @@ class followup_all_print(wizard.interface): }, 'print': { 'actions': [_update_partners], - 'result': {'type':'print', 'report':'account_followup.followup.print', 'state':'end'}, + 'result': {'type': 'print', + 'report':'account_followup.followup.print', + 'state':'end'}, }, }