+ ''' % (currency_symbol)
+ total = 0
+ for aml in currency_dict['line']:
+ block = aml['blocked'] and 'X' or ' '
+ total += aml['balance']
+ strbegin = "
"
+ strend = "
"
+ date = aml['date_maturity'] or aml['date']
+ if date <= current_date and aml['balance'] > 0:
+ strbegin = "
''' % (total)
+ return followup_table
+
# Adds current_date to the context. That way it can be used to put
# the account move lines in bold that are overdue in the email
def render_template(self, cr, uid, template, model, res_id, context=None):
context['current_date'] = fields.date.context_today(cr, uid, context)
+ if model == 'res.partner': # and 'followup' in context.keys() and context['followup']:
+ context['followup_table'] = self._get_followup_table_html(cr, uid, res_id, context=context)
return super(email_template, self).render_template(cr, uid, template, model, res_id, context=context)
-
class res_partner(osv.osv):
def fields_view_get(self, cr, uid, view_id=None, view_type=None, context=None, toolbar=False, submenu=False):
@@ -138,7 +180,11 @@ class res_partner(osv.osv):
root.insert(0, first_node[0])
res['arch'] = etree.tostring(doc, encoding="utf-8")
return res
-
+
+# def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):
+# if order and order[0] == '':
+# pass
+
def _get_latest(self, cr, uid, ids, names, arg, context=None, company_id=None):
res={}
if company_id == None:
@@ -172,6 +218,7 @@ class res_partner(osv.osv):
for partner in self.browse(cr, uid, partner_ids, context=context):
#Check action: check if the action was not empty, if not add
action_text= ""
+ context['followup'] = True
if partner.payment_next_action:
action_text = (partner.payment_next_action or '') + "\n" + (partner.latest_followup_level_id_without_lit.manual_action_note or '')
else:
@@ -256,6 +303,95 @@ class res_partner(osv.osv):
}
+ def _get_amounts_and_date(self, cr, uid, ids, name, arg, context=None, company_id=None):
+ res = {}
+ if company_id == None:
+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
+ else:
+ company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
+ current_date = fields.date.context_today(cr, uid, context)
+ for partner in self.browse(cr, uid, ids, context=context):
+ res[partner.id] = [0.0, 0.0, False]
+ calc_date = False
+ amount_due = 0.0
+ amount_overdue = 0.0
+ for aml in partner.unreconciled_aml_ids:
+ if (aml.company_id == company):
+ date_maturity = (not aml.date_maturity) and aml.date or aml.date_maturity
+ if (not calc_date or calc_date > date_maturity):
+ calc_date = date_maturity
+ amount_due += aml.result
+ if (date_maturity <= current_date):
+ amount_overdue += aml.result
+ res[partner.id] = {'payment_amount_due': amount_due,
+ 'payment_amount_overdue': amount_overdue,
+ 'payment_earliest_due_date': calc_date}
+ return res
+
+
+ def _search_unreconciled(self, cr, uid, obj, name, args, field, context=None):
+ pass
+
+ def _payment_overdue_search(self, cr, uid, obj, name, args, context=None):
+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ if not args:
+ return []
+ having_values = tuple(map(itemgetter(2), args))
+ where = ' AND '.join(
+ map(lambda x: '(SUM(bal2) %(operator)s %%s)' % {
+ 'operator':x[1]},args))
+ query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
+ cr.execute(('SELECT pid AS partner_id, SUM(bal2) FROM ' \
+ '(SELECT CASE WHEN bal IS NOT NULL THEN bal ' \
+ 'ELSE 0.0 END AS bal2, p.id as pid ' \
+ ' FROM ' \
+ '(SELECT (debit-credit) AS bal, partner_id ' \
+ 'FROM account_move_line l ' \
+ 'WHERE account_id IN ' \
+ '(SELECT id FROM account_account '\
+ 'WHERE type=\'receivable\' AND active) ' \
+ 'AND date_maturity <= NOW() ' \
+ 'AND l.company_id = %s '
+ 'AND reconcile_id IS NULL ' \
+ 'AND '+query+') AS l ' \
+ 'RIGHT JOIN res_partner p ' \
+ 'ON p.id = partner_id ) AS pl ' \
+ 'GROUP BY pid HAVING ' + where),
+ (str(company),) + having_values)
+ res = cr.fetchall()
+ if not res:
+ return [('id','=','0')]
+ return [('id','in',map(itemgetter(0), res))]
+
+ def _payment_due_search(self, cr, uid, obj, name, args, context=None):
+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ if not args:
+ return []
+ having_values = tuple(map(itemgetter(2), args))
+ where = ' AND '.join(
+ map(lambda x: '(SUM(bal2) %(operator)s %%s)' % {
+ 'operator':x[1]},args))
+ query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
+ cr.execute(('SELECT pid AS partner_id, SUM(bal2) FROM ' \
+ '(SELECT CASE WHEN bal IS NOT NULL THEN bal ' \
+ 'ELSE 0.0 END AS bal2, p.id as pid FROM ' \
+ '(SELECT (debit-credit) AS bal, partner_id ' \
+ 'FROM account_move_line l ' \
+ 'WHERE account_id IN ' \
+ '(SELECT id FROM account_account '\
+ 'WHERE type=\'receivable\' AND active) ' \
+ 'AND reconcile_id IS NULL ' \
+ 'AND company_id = %s'
+ 'AND '+query+') AS l ' \
+ 'RIGHT JOIN res_partner p ' \
+ 'ON p.id = partner_id ) AS pl ' \
+ 'GROUP BY pid HAVING ' + where), (str(company),) + having_values)
+ res = cr.fetchall()
+ if not res:
+ return [('id','=','0')]
+ return [('id','in',map(itemgetter(0), res))]
+
+
_inherit = "res.partner"
_columns = {
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Follow-up Responsible',
@@ -281,7 +417,19 @@ class res_partner(osv.osv):
help="The maximum follow-up level without taking into account the account move lines with litigation",
store=False,
multi="latest"),
- 'payment_amount_due':fields.related('credit', type='float', string="Total amount due", readonly=True),
+ 'payment_amount_due':fields.function(_get_amounts_and_date, method = True,
+ type='float', string="Amount due",
+ store = False, multi="amountsdate",
+ fnct_search=_payment_due_search),
+ 'payment_amount_overdue':fields.function(_get_amounts_and_date, method = True,
+ type='float', string="Amount overdue",
+ store = False, multi="amountsdate",
+ fnct_search = _payment_overdue_search),
+ 'payment_earliest_due_date':fields.function(_get_amounts_and_date, method=True,
+ type='date',
+ string = "Most overdue date",
+ multi="amountsdate",
+ ),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml
index df703773303..129232f475e 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -16,7 +16,9 @@
-
+
+
+
@@ -28,7 +30,7 @@
-
+
@@ -43,29 +45,7 @@
-
- Search
- res.partner
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Manual Follow-Ups
@@ -73,7 +53,7 @@
res.partnerformtree,form
- {}
+ [('credit', '>', 0.0)]{'Followupfirst':True, 'search_default_todo': True}
@@ -105,11 +85,11 @@
help="Click to mark the action as done." class="oe_link"
attrs="{'invisible':[('payment_next_action_date','=', False)]}"
groups="base.group_partner_manager"/>
-
+
-
+
Below is the history of the transactions of this
customer. You can set an invoice in litigation in
@@ -119,12 +99,14 @@
+
+
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index ce2df1d03d6..c4a2e2188f4 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -6,68 +6,40 @@
Follow-up of overdue invoices level 0
- ${user.email or ''}
- ${user.company_id.name} Payment Follow-up
- ${object.email}
- ${object.lang}
+ ${user.email or '' | h}
+ ${user.company_id.name | h} Payment Reminder
+ ${object.email | h}
+ ${object.lang | h}
-
Dear ${object.name},
+
Dear ${object.name | h},
Exception made if there was a mistake of ours, it seems that the following amount stays 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 ignore this message. Do not hesitate to
-contact our accounting department at (+32).10.68.94.39.
+contact our accounting department.
- ''' % (currency_symbol)
- total = 0
- for aml in currency_dict['line']:
- block = aml['blocked'] and 'X' or ' '
- total += aml['balance']
- strbegin = "
"
- strend = "
"
- date = aml['date_maturity'] or aml['date']
- if date <= ctx['current_date'] and aml['balance'] > 0:
- strbegin = "
We are disappointed to see that despite sending a reminder, that your account is now seriously overdue.
It is essential that immediate payment is made, otherwise we will have to consider placing a stop on your account
which means that we will no longer be able to supply your company with (goods/services).
Please, take appropriate measures in order to carry out this payment in the next 8 days.
If there is a problem with paying invoice that we are not aware of, do not hesitate to contact our accounting
-department at (+32).10.68.94.39. so that we can resolve the matter quickly.
+department. so that we can resolve the matter quickly.
Details of due payments is printed below.
- ''' % (currency_symbol)
- total = 0
- for aml in currency_dict['line']:
- block = aml['blocked'] and 'X' or ' '
- total += aml['balance']
- strbegin = "
"
- strend = "
"
- date = aml['date_maturity'] or aml['date']
- if date <= ctx['current_date'] and aml['balance'] > 0:
- strbegin = "
Despite several reminders, your account is still not settled.
Unless full payment is made in next 8 days, legal action for the recovery of the debt will be taken without
further notice.
I trust that this action will prove unnecessary and details of due payments is printed below.
-In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
+In case of any queries concerning this matter, do not hesitate to contact our accounting department.
- ''' % (currency_symbol)
- total = 0
- for aml in currency_dict['line']:
- block = aml['blocked'] and 'X' or ' '
- total += aml['balance']
- strbegin = "
"
- strend = "
"
- date = aml['date_maturity'] or aml['date']
- if date <= ctx['current_date'] and aml['balance'] > 0:
- strbegin = "
Exception made if there was a mistake of ours, it seems that the following amount stays 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 ignore this message. Do not hesitate to
-contact our accounting department at (+32).10.68.94.39.
+contact our accounting department.
- ''' % (currency_symbol)
- total = 0
- for aml in currency_dict['line']:
- block = aml['blocked'] and 'X' or ' '
- total += aml['balance']
- strbegin = "
"
- strend = "
"
- date = aml['date_maturity'] or aml['date']
- if date <= ctx['current_date'] and aml['balance'] > 0:
- strbegin = "
''' % (total)
-
+ followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
%>
-${followup_table}
-
-
+${followup_table | h}
+
]]>
-
-
-
-
@@ -319,7 +192,7 @@ Dear %(partner_name)s,
Exception made if there was a mistake of ours, it seems that the following amount stays 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 ignore this message. Do not hesitate to contact our accounting department at (+32).10.68.94.39.
+Would your payment have been carried out after this mail was sent, please ignore this message. Do not hesitate to contact our accounting department.
Best Regards,
@@ -342,15 +215,13 @@ We are disappointed to see that despite sending a reminder, that your account is
It is essential that immediate payment is made, otherwise we will have to consider placing a stop on your account which means that we will no longer be able to supply your company with (goods/services).
Please, take appropriate measures in order to carry out this payment in the next 8 days.
-If there is a problem with paying invoice that we are not aware of, do not hesitate to contact our accounting department at (+32).10.68.94.39. so that we can resolve the matter quickly.
+If there is a problem with paying invoice that we are not aware of, do not hesitate to contact our accounting department, so that we can resolve the matter quickly.
Details of due payments is printed below.
Best Regards,
-
-
Call the customer on the phone3
@@ -369,7 +240,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
-In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
+In case of any queries concerning this matter, do not hesitate to contact our accounting department.
Best Regards,
diff --git a/addons/account_followup/account_followup_demo.xml b/addons/account_followup/account_followup_demo.xml
index 4f22c18857d..053d611fc08 100644
--- a/addons/account_followup/account_followup_demo.xml
+++ b/addons/account_followup/account_followup_demo.xml
@@ -17,7 +17,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
-In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
+In case of any queries concerning this matter, do not hesitate to contact our accounting department at [TEL NUMBER].
Best Regards,
@@ -39,7 +39,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
-In case of any queries concerning this matter, do not hesitate to contact our accounting department at (+32).10.68.94.39.
+In case of any queries concerning this matter, do not hesitate to contact our accounting department at [TEL NUMBER].
Best Regards,
diff --git a/addons/account_followup/account_followup_view.xml b/addons/account_followup/account_followup_view.xml
index 1df87feac76..c1b79d20369 100644
--- a/addons/account_followup/account_followup_view.xml
+++ b/addons/account_followup/account_followup_view.xml
@@ -69,7 +69,6 @@
account_followup.followup.formaccount_followup.followup
-
+ ''' % (currency_symbol)
+ total = 0
+ ctx = context
+ for aml in currency_dict['line']:
+ block = aml['blocked'] and 'X' or ' '
+ total += aml['balance']
+ strbegin = "
"
+ strend = "
"
+ date = aml['date_maturity'] or aml['date']
+ if date <= ctx['current_date'] and aml['balance'] > 0:
+ strbegin = "
''' % (total)
+ return followup_table
+
+
def _get_text(self, stat_line, followup_id, context=None):
if context is None:
context = {}
@@ -108,7 +143,6 @@ class report_rappel(report_sxw.rml_parse):
'company_name': stat_line.company_id.name,
'user_signature': pooler.get_pool(self.cr.dbname).get('res.users').browse(self.cr, self.uid, self.uid, context).signature or '',
}
-
return text
report_sxw.report_sxw('report.account_followup.followup.print',
From cfd009394dfa2e8692f89e1321f8d6c51b75750a Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 6 Dec 2012 12:03:15 +0100
Subject: [PATCH 02/12] [IMP] Search functions on amounts and dates in partner
bzr revid: jco@openerp.com-20121206110315-ddgp3qxwn3ezl06g
---
addons/account/account_move_line.py | 2 +-
addons/account/partner.py | 25 ++++++-----
addons/account_followup/account_followup.py | 43 ++++++++++++++-----
.../account_followup_customers.xml | 18 ++++----
.../account_followup_data.xml | 8 ++--
.../wizard/account_followup_print.py | 14 ++----
6 files changed, 64 insertions(+), 46 deletions(-)
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index 698b1bcf00c..6d27630aee0 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -456,7 +456,7 @@ class account_move_line(osv.osv):
store = {
'account.move': (_get_move_lines, ['period_id'], 20)
}),
- 'blocked': fields.boolean('Litigation', help="You can check this box to mark this journal item as a litigation with the associated partner"),
+ 'blocked': fields.boolean('No Follow-up', help="You can check this box to mark this journal item as a litigation with the associated partner"),
'partner_id': fields.many2one('res.partner', 'Partner', select=1, ondelete='restrict'),
'date_maturity': fields.date('Due date', select=True ,help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."),
'date': fields.related('move_id','date', string='Effective date', type='date', required=True, select=True,
diff --git a/addons/account/partner.py b/addons/account/partner.py
index 3355363308b..819aef68892 100644
--- a/addons/account/partner.py
+++ b/addons/account/partner.py
@@ -134,18 +134,23 @@ class res_partner(osv.osv):
return []
having_values = tuple(map(itemgetter(2), args))
where = ' AND '.join(
- map(lambda x: '(SUM(debit-credit) %(operator)s %%s)' % {
+ map(lambda x: '(SUM(bal2) %(operator)s %%s)' % {
'operator':x[1]},args))
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
- cr.execute(('SELECT partner_id FROM account_move_line l '\
- 'WHERE account_id IN '\
- '(SELECT id FROM account_account '\
- 'WHERE type=%s AND active) '\
- 'AND reconcile_id IS NULL '\
- 'AND '+query+' '\
- 'AND partner_id IS NOT NULL '\
- 'GROUP BY partner_id HAVING '+where),
- (type,) + having_values)
+ cr.execute(('SELECT pid AS partner_id, SUM(bal2) FROM ' \
+ '(SELECT CASE WHEN bal IS NOT NULL THEN bal ' \
+ 'ELSE 0.0 END AS bal2, p.id as pid FROM ' \
+ '(SELECT (debit-credit) AS bal, partner_id ' \
+ 'FROM account_move_line l ' \
+ 'WHERE account_id IN ' \
+ '(SELECT id FROM account_account '\
+ 'WHERE type=%s AND active) ' \
+ 'AND reconcile_id IS NULL ' \
+ 'AND '+query+') AS l ' \
+ 'RIGHT JOIN res_partner p ' \
+ 'ON p.id = partner_id ) AS pl ' \
+ 'GROUP BY pid HAVING ' + where),
+ (type,) + having_values)
res = cr.fetchall()
if not res:
return [('id','=','0')]
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index 8b6af6cf269..40ed2e1424e 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -277,7 +277,7 @@ class res_partner(osv.osv):
else:
payment_action_date = fields.date.context_today(cr, uid, context)
if partner.payment_next_action:
- payment_next_action = partner.payment_next_action + " + " + action_text
+ payment_next_action = partner.payment_next_action + " \n " + action_text
else:
payment_next_action = action_text
self.write(cr, uid, [partner.id], {'payment_next_action_date': payment_action_date,
@@ -363,6 +363,28 @@ class res_partner(osv.osv):
return [('id','=','0')]
return [('id','in',map(itemgetter(0), res))]
+ def _payment_earliest_date_search(self, cr, uid, obj, name, args, context=None):
+ if not args:
+ return []
+ having_values = tuple(map(itemgetter(2), args))
+ where = ' AND '.join(
+ map(lambda x: '(MIN(l.date_maturity) %(operator)s %%s)' % {
+ 'operator':x[1]},args))
+ query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
+ cr.execute(('SELECT partner_id FROM account_move_line l '\
+ 'WHERE account_id IN '\
+ '(SELECT id FROM account_account '\
+ 'WHERE type=\'receivable\' AND active) '\
+ 'AND reconcile_id IS NULL '\
+ 'AND '+query+' '\
+ 'AND partner_id IS NOT NULL '\
+ 'GROUP BY partner_id HAVING '+where),
+ having_values)
+ res = cr.fetchall()
+ if not res:
+ return [('id','=','0')]
+ return [('id','in',map(itemgetter(0), res))]
+
def _payment_due_search(self, cr, uid, obj, name, args, context=None):
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
if not args:
@@ -395,12 +417,13 @@ class res_partner(osv.osv):
_inherit = "res.partner"
_columns = {
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Follow-up Responsible',
- help="Responsible for making sure the action happens."),
+ help="Responsible for making sure the action happens. "),
'payment_note':fields.text('Customer Payment Promise', help="Payment Note"),
- 'payment_next_action':fields.text('Next Action',
- help="This is the next action to be taken by the user. It will automatically be set when the action fields are empty and the partner gets a follow-up level that requires a manual action. "),
+ 'payment_next_action':fields.text('Next Action',
+ help="This is the next action to be taken. It will automatically be set when the partner gets a follow-up level that requires a manual action. "),
'payment_next_action_date':fields.date('Next Action Date',
- help="This is when further follow-up is needed. The date will have been set to the current date if the action fields are empty and the partner gets a follow-up level that requires a manual action. "),
+ help="This is when the manual follow-up is needed. " \
+ "The date will be set to the current date when the partner gets a follow-up level that requires a manual action. Can be practical to set manually e.g. to follow up his payment. "),
'unreconciled_aml_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '=', False), '&',
('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')]),
'latest_followup_date':fields.function(_get_latest, method=True, type='date', string="Latest Follow-up Date",
@@ -418,18 +441,18 @@ class res_partner(osv.osv):
store=False,
multi="latest"),
'payment_amount_due':fields.function(_get_amounts_and_date, method = True,
- type='float', string="Amount due",
+ type='float', string="Amount Due",
store = False, multi="amountsdate",
fnct_search=_payment_due_search),
'payment_amount_overdue':fields.function(_get_amounts_and_date, method = True,
- type='float', string="Amount overdue",
+ type='float', string="Amount Overdue",
store = False, multi="amountsdate",
fnct_search = _payment_overdue_search),
'payment_earliest_due_date':fields.function(_get_amounts_and_date, method=True,
type='date',
- string = "Most overdue date",
- multi="amountsdate",
- ),
+ string = "Worst Due Date",
+ multi="amountsdate",
+ fnct_search=_payment_earliest_date_search),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml
index 129232f475e..8959143698e 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -18,7 +18,7 @@
-
+
@@ -53,7 +53,7 @@
res.partnerformtree,form
- [('credit', '>', 0.0)]
+ [('payment_amount_due', '>', 0.0)]{'Followupfirst':True, 'search_default_todo': True}
@@ -70,7 +70,7 @@
+ help="If not specified by the latest follow-up level, it will send from the default email template" attrs="{'invisible':[('credit', '<=', 0.0)]}"/>
The , the latest payment follow-up
@@ -89,24 +89,22 @@
-
+
Below is the history of the transactions of this
- customer. You can set an invoice in litigation in
- order to not include it in the next payment
- follow-ups.
+ customer. You can check "No Follow-up" in
+ order to exclude it from the next follow-up actions.
-
+
-
+
-
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index c4a2e2188f4..af974a2b7e0 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -5,7 +5,7 @@
- Follow-up of overdue invoices level 0
+ First polite payment follow-up reminder email${user.email or '' | h}${user.company_id.name | h} Payment Reminder${object.email | h}
@@ -51,7 +51,7 @@ ${followup_table | h}
- Follow-up of overdue invoices level 1
+ A bit urging second payment follow-up reminder email${user.email or '' | h}${user.company_id.name | h} Payment Reminder${object.email | h}
@@ -95,7 +95,7 @@ ${followup_table | h}
- Follow-up of overdue invoices level 2
+ Urging payment follow-up reminder email${user.email or '' | h}${user.company_id.name | h} Payment Reminder${object.email | h}
@@ -138,7 +138,7 @@ ${object.followup_table(object, user) | h}
- Default follow-up of overdue invoices
+ Default payment follow-up reminder e-mail${user.email or '' | h}${user.company_id.name | h} Payment Reminder${object.email | h}
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index db93b3c63a8..2c9b41a7859 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -152,7 +152,7 @@ class account_followup_print(osv.osv_memory):
if partner.max_followup_id.manual_action:
partner_obj.do_partner_manual_action(cr, uid, [partner.partner_id.id], context=context)
nbmanuals = nbmanuals + 1
- key = partner.partner_id.payment_responsible_id.name or _("Nobody")
+ key = partner.partner_id.payment_responsible_id.name or _("Anybody")
if not key in manuals.keys():
manuals[key]= 1
else:
@@ -195,18 +195,10 @@ class account_followup_print(osv.osv_memory):
# Partnerlist is list to exclude
# Will clear the actions of partners that have no due payments anymore
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)]
- ids = self.pool.get('res.partner').search(cr, uid, ['&', ('id', 'not in', partner_list_ids), '|',
+ ids = self.pool.get('res.partner').search(cr, uid, ['&', ('credit', '<=', 0.0), '&', ('id', 'not in', partner_list_ids), '|',
('payment_responsible_id', '!=', False),
('payment_next_action_date', '!=', False)], context=context)
- partners = self.pool.get('res.partner').browse(cr, uid, ids, context=context)
- newids = []
- for part in partners:
- credit = 0
- for aml in part.unreconciled_aml_ids:
- credit +=aml.result
- if credit <= 0:
- newids.append(part.id)
- self.pool.get('res.partner').action_done(cr, uid, newids, context=context)
+ self.pool.get('res.partner').action_done(cr, uid, ids, context=context)
return len(ids)
def do_process(self, cr, uid, ids, context=None):
From bd2d663b229221154c3d3b35486bd9f9703b443b Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 6 Dec 2012 17:40:06 +0100
Subject: [PATCH 03/12] [IMP] currencies in mails + minor
bzr revid: jco@openerp.com-20121206164006-tx2paj5ybek6aupa
---
addons/account_followup/account_followup.py | 21 +++-------
.../account_followup_customers.xml | 1 -
.../account_followup_data.xml | 38 ++++---------------
.../account_followup_demo.xml | 4 +-
.../account_followup_view.xml | 12 +++---
.../report/account_followup_print.py | 10 +++--
.../wizard/account_followup_print.py | 7 +++-
.../wizard/account_followup_print_view.xml | 2 +-
8 files changed, 36 insertions(+), 59 deletions(-)
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index 40ed2e1424e..3f89ac09502 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -75,7 +75,7 @@ class followup_line(osv.osv):
Exception made if there was a mistake of ours, it seems that the following amount stays 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 ignore this message. Do not hesitate to contact our accounting department at (+32).10.68.94.39.
+Would your payment have been carried out after this mail was sent, please ignore this message. Do not hesitate to contact our accounting department.
Best Regards,
""",
@@ -180,10 +180,7 @@ class res_partner(osv.osv):
root.insert(0, first_node[0])
res['arch'] = etree.tostring(doc, encoding="utf-8")
return res
-
-# def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None):
-# if order and order[0] == '':
-# pass
+
def _get_latest(self, cr, uid, ids, names, arg, context=None, company_id=None):
res={}
@@ -328,10 +325,6 @@ class res_partner(osv.osv):
'payment_earliest_due_date': calc_date}
return res
-
- def _search_unreconciled(self, cr, uid, obj, name, args, field, context=None):
- pass
-
def _payment_overdue_search(self, cr, uid, obj, name, args, context=None):
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
if not args:
@@ -343,8 +336,7 @@ class res_partner(osv.osv):
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
cr.execute(('SELECT pid AS partner_id, SUM(bal2) FROM ' \
'(SELECT CASE WHEN bal IS NOT NULL THEN bal ' \
- 'ELSE 0.0 END AS bal2, p.id as pid ' \
- ' FROM ' \
+ 'ELSE 0.0 END AS bal2, p.id as pid FROM ' \
'(SELECT (debit-credit) AS bal, partner_id ' \
'FROM account_move_line l ' \
'WHERE account_id IN ' \
@@ -417,19 +409,18 @@ class res_partner(osv.osv):
_inherit = "res.partner"
_columns = {
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Follow-up Responsible',
- help="Responsible for making sure the action happens. "),
+ help="Optionally you can assign a user to this field, which will make him responsible for the action. "),
'payment_note':fields.text('Customer Payment Promise', help="Payment Note"),
'payment_next_action':fields.text('Next Action',
help="This is the next action to be taken. It will automatically be set when the partner gets a follow-up level that requires a manual action. "),
'payment_next_action_date':fields.date('Next Action Date',
help="This is when the manual follow-up is needed. " \
- "The date will be set to the current date when the partner gets a follow-up level that requires a manual action. Can be practical to set manually e.g. to follow up his payment. "),
+ "The date will be set to the current date when the partner gets a follow-up level that requires a manual action. Can be practical to set manually e.g. to see if he keeps his promises. "),
'unreconciled_aml_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '=', False), '&',
('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')]),
'latest_followup_date':fields.function(_get_latest, method=True, type='date', string="Latest Follow-up Date",
help="Latest date that the follow-up level of the partner was changed",
- store=False,
- multi="latest"),
+ store=False, multi="latest"),
'latest_followup_level_id':fields.function(_get_latest, method=True,
type='many2one', relation='account_followup.followup.line', string="Latest Follow-up Level",
help="The maximum follow-up level",
diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml
index 8959143698e..54bd334a2df 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -33,7 +33,6 @@
-
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index af974a2b7e0..ffb5ae8d854 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -26,20 +26,15 @@ contact our accounting department.
Best Regards,
-
+
${user.name | h}
-<%
- from openerp.addons.account_followup.report import account_followup_print
- rml_parse = account_followup_print.report_rappel(object._cr, user.id, "followup_rml_parser")
- followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
-%>
-${followup_table | h}
+${ctx['followup_table']}
@@ -74,19 +69,14 @@ Details of due payments is printed below.
Best Regards,
+
${user.name | h}
-<%
- from openerp.addons.account_followup.report import account_followup_print
- rml_parse = account_followup_print.report_rappel(object._cr, user.id, "followup_rml_parser")
- followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
-%>
-
-${followup_table | h}
+${ctx['followup_table']}
@@ -116,18 +106,13 @@ In case of any queries concerning this matter, do not hesitate to contact our ac
Best Regards,
+
${user.name | h}
-<%
- from openerp.addons.account_followup.report import account_followup_print
- rml_parse = account_followup_print.report_rappel(object._cr, user.id, "followup_rml_parser")
- followup_table = rml_parse.get_unreconciled_table(object, user.company_id, ctx)
-%>
-
-${followup_table | h}
+${ctx['followup_table']}
diff --git a/addons/account_followup/account_followup_demo.xml b/addons/account_followup/account_followup_demo.xml
index 053d611fc08..0c470f5980e 100644
--- a/addons/account_followup/account_followup_demo.xml
+++ b/addons/account_followup/account_followup_demo.xml
@@ -17,7 +17,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
-In case of any queries concerning this matter, do not hesitate to contact our accounting department at [TEL NUMBER].
+In case of any queries concerning this matter, do not hesitate to contact our accounting department.
Best Regards,
@@ -39,7 +39,7 @@ Unless full payment is made in next 8 days, then legal action for the recovery o
I trust that this action will prove unnecessary and details of due payments is printed below.
-In case of any queries concerning this matter, do not hesitate to contact our accounting department at [TEL NUMBER].
+In case of any queries concerning this matter, do not hesitate to contact our accounting department.
Best Regards,
diff --git a/addons/account_followup/account_followup_view.xml b/addons/account_followup/account_followup_view.xml
index c1b79d20369..5560ca822dc 100644
--- a/addons/account_followup/account_followup_view.xml
+++ b/addons/account_followup/account_followup_view.xml
@@ -76,9 +76,11 @@
To remind customers of paying their invoices, you can
define different actions depending on how severely
overdue the customer is. These actions are bundled
- into folow-up levels that are triggered when the due
- date of the most overdue invoice has passed a certain
- number of days.
+ into follow-up levels that are triggered when the due
+ date of an invoice has passed a certain
+ number of days. If there are other overdue invoices for the
+ same customer, the actions of the most
+ overdue invoice will be executed.
@@ -167,7 +169,7 @@
-
+
diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py
index 2b70f46142c..65a56957d07 100644
--- a/addons/account_followup/report/account_followup_print.py
+++ b/addons/account_followup/report/account_followup_print.py
@@ -85,7 +85,7 @@ class report_rappel(report_sxw.rml_parse):
final_res = self._lines_get_with_partner(partner, company.id)
followup_table = ''
for currency_dict in final_res:
- currency_symbol = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id'].symbol
+ currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id']
followup_table += '''
@@ -95,7 +95,7 @@ class report_rappel(report_sxw.rml_parse):
Amount (%s)
Lit.
- ''' % (currency_symbol)
+ ''' % (currency.symbol)
total = 0
ctx = context
for aml in currency_dict['line']:
@@ -107,8 +107,10 @@ class report_rappel(report_sxw.rml_parse):
if date <= ctx['current_date'] and aml['balance'] > 0:
strbegin = "
This action will send follow-up emails, print the letters and
- set the manual actions per customers.
+ set the manual actions per customer, according to the follow-up levels defined.