Merge lp:~openerp-dev/openobject-addons/trunk-followupimprov3-jco into lp:openobject-addons

Proposed by Josse Colpaert (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-followupimprov3-jco
Merge into: lp:openobject-addons
Diff against target: 128 lines (+69/-7)
3 files modified
account_followup/account_followup.py (+62/-1)
account_followup/wizard/account_followup_print.py (+6/-5)
account_followup/wizard/account_followup_print_view.xml (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-followupimprov3-jco
Reviewer Review Type Date Requested Status
qdp (OpenERP) Pending
Review via email: mp+140423@code.launchpad.net

Description of the change

Clear manual actions should return the right length of ids. (used in the message of the wizard afterwards to tell how many actions were cleared)

To post a comment you must log in.

Unmerged revisions

8212. By Josse Colpaert (OpenERP)

[MERGE] Merge from trunk

8211. By Josse Colpaert (OpenERP)

[IMP] Correct escapes (rco)

8210. By Josse Colpaert (OpenERP)

[MERGE] Merge from trunk

8209. By Josse Colpaert (OpenERP)

[IMP] Merge from trunk

8208. By Josse Colpaert (OpenERP)

[IMP] Wizard clear action message now with correct ids

8207. By Josse Colpaert (OpenERP)

[IMP] remove one empty line

8206. By Josse Colpaert (OpenERP)

[IMP] Changing tabs -> spaces

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_followup/account_followup.py'
2--- account_followup/account_followup.py 2012-12-17 14:43:06 +0000
3+++ account_followup/account_followup.py 2012-12-18 13:00:47 +0000
4@@ -113,6 +113,67 @@
5 }
6
7
8+
9+
10+class email_template(osv.osv):
11+ _inherit = 'email.template'
12+
13+ def _get_followup_table_html(self, cr, uid, res_id, context=None):
14+ '''
15+ Build the html tables to be included in emails send to partners, when reminding them their
16+ overdue invoices.
17+
18+ :param res_id: ID of the partner for whom we are building the tables
19+ :rtype: string
20+ '''
21+ from report import account_followup_print
22+ partner = self.pool.get('res.partner').browse(cr, uid, res_id, context=context)
23+ followup_table = ''
24+ if partner.unreconciled_aml_ids:
25+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
26+ current_date = fields.date.context_today(cr, uid, context)
27+ rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser")
28+ final_res = rml_parse._lines_get_with_partner(partner, company.id)
29+
30+ for currency_dict in final_res:
31+ currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id']
32+ followup_table += '''
33+ <table border="2" width=100%%>
34+ <tr>
35+ <td>Invoice date</td>
36+ <td>Reference</td>
37+ <td>Due date</td>
38+ <td>Amount (%s)</td>
39+ <td>Lit.</td>
40+ </tr>
41+ ''' % (currency.symbol)
42+ total = 0
43+ for aml in currency_dict['line']:
44+ block = aml['blocked'] and 'X' or ' '
45+ total += aml['balance']
46+ strbegin = "<TD>"
47+ strend = "</TD>"
48+ date = aml['date_maturity'] or aml['date']
49+ if date <= current_date and aml['balance'] > 0:
50+ strbegin = "<TD><B>"
51+ strend = "</B></TD>"
52+ followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
53+ total = rml_parse.formatLang(total, dp='Account', currency_obj=currency)
54+ followup_table += '''<tr> </tr>
55+ </table>
56+ <center>Amount due: %s </center>''' % (total)
57+ return followup_table
58+
59+
60+ def render_template(self, cr, uid, template, model, res_id, context=None):
61+ if model == 'res.partner' and context.get('followup'):
62+ context['followup_table'] = self._get_followup_table_html(cr, uid, res_id, context=context)
63+ # Adds current_date to the context. That way it can be used to put
64+ # the account move lines in bold that are overdue in the email
65+ context['current_date'] = fields.date.context_today(cr, uid, context)
66+ return super(email_template, self).render_template(cr, uid, template, model, res_id, context=context)
67+
68+
69 class res_partner(osv.osv):
70
71 def fields_view_get(self, cr, uid, view_id=None, view_type=None, context=None, toolbar=False, submenu=False):
72@@ -308,7 +369,7 @@
73 for aml in partner.unreconciled_aml_ids:
74 if (aml.company_id == company):
75 date_maturity = aml.date_maturity or aml.date
76- if not worst_due_date or date_maturity < worst_due_date:
77+ if not worst_due_date or worst_due_date > date_maturity:
78 worst_due_date = date_maturity
79 amount_due += aml.result
80 if (date_maturity <= current_date):
81
82=== modified file 'account_followup/wizard/account_followup_print.py'
83--- account_followup/wizard/account_followup_print.py 2012-12-10 11:16:54 +0000
84+++ account_followup/wizard/account_followup_print.py 2012-12-18 13:00:47 +0000
85@@ -195,16 +195,17 @@
86 # Partnerlist is list to exclude
87 # Will clear the actions of partners that have no due payments anymore
88 partner_list_ids = [partner.partner_id.id for partner in self.pool.get('account_followup.stat.by.partner').browse(cr, uid, partner_list, context=context)]
89- ids = self.pool.get('res.partner').search(cr, uid, ['&', ('id', 'not in', partner_list_ids), '|',
90- ('payment_responsible_id', '!=', False),
91+
92+ ids = self.pool.get('res.partner').search(cr, uid, [ '&', ('id', 'not in', partner_list_ids), '|',
93+ ('payment_responsible_id', '!=', False), '|', '&',
94+ ('payment_next_action', '!=', False), ('payment_next_action', '!=', ''),
95 ('payment_next_action_date', '!=', False)], context=context)
96-
97 partners_to_clear = []
98 for part in self.pool.get('res.partner').browse(cr, uid, ids, context=context):
99 if not part.unreconciled_aml_ids:
100 partners_to_clear.append(part.id)
101 self.pool.get('res.partner').action_done(cr, uid, partners_to_clear, context=context)
102- return len(ids)
103+ return len(partners_to_clear)
104
105 def do_process(self, cr, uid, ids, context=None):
106 if context is None:
107@@ -296,7 +297,7 @@
108
109 partner_list = []
110 to_update = {}
111-
112+
113 #Fill dictionary of accountmovelines to_update with the partners that need to be updated
114 for partner_id, followup_line_id, date_maturity,date, id in move_lines:
115 if not partner_id:
116
117=== modified file 'account_followup/wizard/account_followup_print_view.xml'
118--- account_followup/wizard/account_followup_print_view.xml 2012-12-06 16:40:06 +0000
119+++ account_followup/wizard/account_followup_print_view.xml 2012-12-18 13:00:47 +0000
120@@ -11,7 +11,7 @@
121 <field name="followup_id" groups="base.group_multi_company"/>
122 <field name="date" groups="base.group_no_one"/>
123 </group>
124- <p class ="oe_grey">
125+ <p class ="oe_grey">
126 This action will send follow-up emails, print the letters and
127 set the manual actions per customer, according to the follow-up levels defined.
128 </p>

Subscribers

People subscribed via source and target branches

to all changes: