+ ''' % (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 = "