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 @@
The
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.