diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index 2c6e651b14b..26fa4632117 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 b5e0a9538ef..2b4c4a49cb4 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 3a09707c4b3..17a09d51e6e 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -24,7 +24,6 @@ from lxml import etree
from tools.translate import _
-
class followup(osv.osv):
_name = 'account_followup.followup'
_description = 'Account Follow-up'
@@ -74,7 +73,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,
""",
@@ -118,12 +117,61 @@ class account_move_line(osv.osv):
class email_template(osv.osv):
_inherit = 'email.template'
- # 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)
- return super(email_template, self).render_template(cr, uid, template, model, res_id, context=context)
+ def _get_followup_table_html(self, cr, uid, res_id, context=None):
+ '''
+ Build the html tables to be included in emails send to partners, when reminding them their
+ overdue invoices.
+ :param res_id: ID of the partner for whom we are building the tables
+ :rtype: string
+ '''
+ from report import account_followup_print
+
+ partner = self.pool.get('res.partner').browse(cr, uid, res_id, context=context)
+ followup_table = ''
+ if partner.unreconciled_aml_ids:
+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
+ current_date = fields.date.context_today(cr, uid, context)
+ rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser")
+ final_res = rml_parse._lines_get_with_partner(partner, company.id)
+
+ for currency_dict in final_res:
+ currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id']
+ followup_table += '''
+
+
+
Invoice date
+
Reference
+
Due date
+
Amount (%s)
+
Lit.
+
+ ''' % (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
+
+
+ def render_template(self, cr, uid, template, model, res_id, context=None):
+ if model == 'res.partner' and context.get('followup'):
+ context['followup_table'] = self._get_followup_table_html(cr, uid, res_id, context=context)
+ # 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
+ context['current_date'] = fields.date.context_today(cr, uid, context)
+ return super(email_template, self).render_template(cr, uid, template, model, res_id, context=context)
class res_partner(osv.osv):
@@ -209,32 +257,36 @@ class res_partner(osv.osv):
}
def do_partner_mail(self, cr, uid, partner_ids, context=None):
+ if context is None:
+ context = {}
+ ctx = context.copy()
+ ctx['followup'] = True
#partner_ids are res.partner ids
# If not defined by latest follow-up level, it will be the default template if it can find it
mtp = self.pool.get('email.template')
unknown_mails = 0
- for partner in self.browse(cr, uid, partner_ids, context=context):
+ for partner in self.browse(cr, uid, partner_ids, context=ctx):
if partner.email and partner.email.strip():
level = partner.latest_followup_level_id_without_lit
if level and level.send_email and level.email_template_id and level.email_template_id.id:
- mtp.send_mail(cr, uid, level.email_template_id.id, partner.id, context=context)
+ mtp.send_mail(cr, uid, level.email_template_id.id, partner.id, context=ctx)
else:
mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid,
'account_followup', 'email_template_account_followup_default')
- mtp.send_mail(cr, uid, mail_template_id[1], partner.id, context=context)
+ mtp.send_mail(cr, uid, mail_template_id[1], partner.id, context=ctx)
else:
unknown_mails = unknown_mails + 1
action_text = _("Email not sent because of email address of partner not filled in")
if partner.payment_next_action_date:
- payment_action_date = min(fields.date.context_today(cr, uid, context), partner.payment_next_action_date)
+ payment_action_date = min(fields.date.context_today(cr, uid, ctx), partner.payment_next_action_date)
else:
- payment_action_date = fields.date.context_today(cr, uid, context)
+ payment_action_date = fields.date.context_today(cr, uid, ctx)
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,
- 'payment_next_action': payment_next_action}, context=context)
+ 'payment_next_action': payment_next_action}, context=ctx)
return unknown_mails
def action_done(self, cr, uid, ids, context=None):
@@ -256,21 +308,122 @@ class res_partner(osv.osv):
}
+ def _get_amounts_and_date(self, cr, uid, ids, name, arg, context=None):
+ '''
+ Function that computes values for the followup functional fields. Note that 'payment_amount_due'
+ is similar to 'credit' field on res.partner except it filters on user's company.
+ '''
+ res = {}
+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
+ current_date = fields.date.context_today(cr, uid, context)
+ for partner in self.browse(cr, uid, ids, context=context):
+ worst_due_date = False
+ amount_due = amount_overdue = 0.0
+ for aml in partner.unreconciled_aml_ids:
+ if (aml.company_id == company):
+ date_maturity = aml.date_maturity or aml.date
+ if not worst_due_date or date_maturity < worst_due_date:
+ worst_due_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': worst_due_date}
+ return res
+
+ def _get_followup_overdue_query(self, cr, uid, args, overdue_only=False, context=None):
+ '''
+ This function is used to build the query and arguments to use when making a search on functional fields
+ * payment_amount_due
+ * payment_amount_overdue
+ Basically, the query is exactly the same except that for overdue there is an extra clause in the WHERE.
+
+ :param args: arguments given to the search in the usual domain notation (list of tuples)
+ :param overdue_only: option to add the extra argument to filter on overdue accounting entries or not
+ :returns: a tuple with
+ * the query to execute as first element
+ * the arguments for the execution of this query
+ :rtype: (string, [])
+ '''
+ company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ having_where_clause = ' AND '.join(map(lambda x: '(SUM(bal2) %s %%s)' % (x[1]), args))
+ having_values = [x[2] for x in args]
+ query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
+ overdue_only_str = overdue_only and 'AND date_maturity <= NOW()' or ''
+ return ('''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)
+ ''' + overdue_only_str + '''
+ 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 ''' + having_where_clause, [company_id] + having_values)
+
+ def _payment_overdue_search(self, cr, uid, obj, name, args, context=None):
+ if not args:
+ return []
+ query, query_args = self._get_followup_overdue_query(cr, uid, args, overdue_only=True, context=context)
+ cr.execute(query, query_args)
+ res = cr.fetchall()
+ if not res:
+ return [('id','=','0')]
+ return [('id','in', [x[0] for x in res])]
+
+ def _payment_earliest_date_search(self, cr, uid, obj, name, args, context=None):
+ if not args:
+ return []
+ company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ having_where_clause = ' AND '.join(map(lambda x: '(MIN(l.date_maturity) %s %%s)' % (x[1]), args))
+ having_values = [x[2] for x in 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 l.company_id = %s '
+ 'AND reconcile_id IS NULL '\
+ 'AND '+query+' '\
+ 'AND partner_id IS NOT NULL '\
+ 'GROUP BY partner_id HAVING '+ having_where_clause,
+ [company_id] + having_values)
+ res = cr.fetchall()
+ if not res:
+ return [('id','=','0')]
+ return [('id','in', [x[0] for x in res])]
+
+ def _payment_due_search(self, cr, uid, obj, name, args, context=None):
+ if not args:
+ return []
+ query, query_args = self._get_followup_overdue_query(cr, uid, args, overdue_only=False, context=context)
+ cr.execute(query, query_args)
+ res = cr.fetchall()
+ if not res:
+ return [('id','=','0')]
+ return [('id','in', [x[0] for x in res])]
+
_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 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 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",
@@ -281,7 +434,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,
+ type='float', string="Amount Due",
+ store = False, multi="followup",
+ fnct_search=_payment_due_search),
+ 'payment_amount_overdue':fields.function(_get_amounts_and_date,
+ type='float', string="Amount Overdue",
+ store = False, multi="followup",
+ fnct_search = _payment_overdue_search),
+ 'payment_earliest_due_date':fields.function(_get_amounts_and_date,
+ type='date',
+ string = "Worst Due Date",
+ multi="followup",
+ 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 df703773303..0471eb52fbe 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -16,7 +16,9 @@
-
+
+
+
@@ -28,10 +30,9 @@
-
+
-
-
+
@@ -43,29 +44,7 @@
-
- Search
- res.partner
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Manual Follow-Ups
@@ -73,7 +52,7 @@
res.partnerformtree,form
- {}
+ [('payment_amount_due', '>', 0.0)]{'Followupfirst':True, 'search_default_todo': True}
@@ -88,9 +67,9 @@
+ help="Print overdue payments report independent of follow-up line" attrs="{'invisible':[('payment_amount_due', '<=', 0.0)]}" />
+ help="If not specified by the latest follow-up level, it will send from the default email template" attrs="{'invisible':[('payment_amount_due', '<=', 0.0)]}"/>
The , the latest payment follow-up
@@ -105,22 +84,22 @@
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
- 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.
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}
+${ctx.get('followup_table','')}
@@ -79,72 +46,37 @@ ${followup_table}
- Follow-up of overdue invoices level 1
- ${user.email or ''}
- ${user.company_id.name} Payment Follow-up
- ${object.email}
- ${object.lang}
+ A bit urging second payment follow-up reminder email
+ ${user.email or '' | h}
+ ${user.company_id.name | h} Payment Reminder
+ ${object.email | h}
+ ${object.lang | h}
-
Dear ${object.name},
+
Dear ${object.name | h},
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.
Best Regards,
-
-${user.name}
-
+
+${user.name | h}
- ''' % (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.
Best Regards,
-
-
-${user.name}
-
+
+${user.name | h}
- ''' % (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}
-
-
+${ctx.get('followup_table','')}
+
]]>
-
-
-
-
@@ -319,7 +170,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 +193,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 +218,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..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 (+32).10.68.94.39.
+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 (+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_view.xml b/addons/account_followup/account_followup_view.xml
index 1df87feac76..5560ca822dc 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
-
@@ -91,7 +92,7 @@
account_followup.followup
-
+
@@ -180,18 +181,5 @@
-
-
-
diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py
index 90dd5969d53..f101aeaa369 100644
--- a/addons/account_followup/report/account_followup_print.py
+++ b/addons/account_followup/report/account_followup_print.py
@@ -25,6 +25,8 @@ import pooler
from report import report_sxw
class report_rappel(report_sxw.rml_parse):
+ _name = "account_followup.report.rappel"
+
def __init__(self, cr, uid, name, context=None):
super(report_rappel, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
@@ -79,7 +81,6 @@ class report_rappel(report_sxw.rml_parse):
final_res.append({'line': line_cur[cur]['line']})
return final_res
-
def _get_text(self, stat_line, followup_id, context=None):
if context is None:
context = {}
@@ -108,7 +109,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',
diff --git a/addons/account_followup/tests/test_account_followup.py b/addons/account_followup/tests/test_account_followup.py
index c46977bd6b5..4495ffa6469 100644
--- a/addons/account_followup/tests/test_account_followup.py
+++ b/addons/account_followup/tests/test_account_followup.py
@@ -108,7 +108,7 @@ class TestAccountFollowup(TransactionCase):
def test_03_filter_on_credit(self):
""" Check the partners can be filtered on having credits """
cr, uid = self.cr, self.uid
- ids = self.partner.search(cr, uid, [('credit', '>=', 0.0)])
+ ids = self.partner.search(cr, uid, [('payment_amount_due', '>=', 0.0)])
self.assertIn(self.partner_id, ids)
def test_04_action_done(self):
@@ -153,7 +153,6 @@ class TestAccountFollowup(TransactionCase):
}, context={"followup_id": self.followup_id})
self.wizard.do_process(cr, uid, [self.wizard_id], context={"followup_id": self.followup_id})
partner_ref = self.partner.browse(cr, uid, self.partner_id)
- print partner_ref.credit, partner_ref.payment_next_action_date, partner_ref.payment_responsible_id
- self.assertEqual(0, self.partner.browse(cr, uid, self.partner_id).credit, "Credit != 0")
+ self.assertEqual(0, self.partner.browse(cr, uid, self.partner_id).payment_amount_due, "Amount Due != 0")
self.assertFalse(self.partner.browse(cr, uid, self.partner_id).payment_next_action_date, "Next action date not cleared")
-
\ 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 db93b3c63a8..3f8bba1830f 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:
@@ -198,15 +198,12 @@ class account_followup_print(osv.osv_memory):
ids = self.pool.get('res.partner').search(cr, uid, ['&', ('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)
+
+ partners_to_clear = []
+ for part in self.pool.get('res.partner').browse(cr, uid, ids, context=context):
+ if not part.unreconciled_aml_ids:
+ partners_to_clear.append(part.id)
+ self.pool.get('res.partner').action_done(cr, uid, partners_to_clear, context=context)
return len(ids)
def do_process(self, cr, uid, ids, context=None):
diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml
index 29f36522d05..62943330d63 100644
--- a/addons/account_followup/wizard/account_followup_print_view.xml
+++ b/addons/account_followup/wizard/account_followup_print_view.xml
@@ -13,7 +13,7 @@
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.