' % body,
+ 'email_to': dest,
+ 'email_from': data_user.email or tools.config.options['email_from']}
+ self.pool.get('mail.mail').create(cr, uid, vals, context=context)
+ msg_sent += partner.name + '\n'
+ except Exception, e:
+ raise osv.except_osv('Error !', e )
+ else:
+ msg += partner.name + '\n'
+ msg_unsent += msg
if not msg_unsent:
summary = _("All Emails have been successfully sent to Partners:.\n\n%s") % msg_sent
else:
@@ -312,8 +326,9 @@ class account_followup_print_all(osv.osv_memory):
if context is None:
context = {}
data = self.read(cr, uid, ids, [], context=context)[0]
- res = self._get_partners_followp(cr, uid, ids, context)['to_update']
+ res = self._get_partners_followp(cr, uid, ids, context)['to_update'] #-> only to_update part
to_update = res
+
data['followup_id'] = 'followup_id' in context and context['followup_id'] or False
date = 'date' in context and context['date'] or data['date']
if not data['test_print']:
@@ -326,6 +341,7 @@ class account_followup_print_all(osv.osv_memory):
(to_update[id]['level'],
date, int(id),))
data.update({'date': context['date']})
+ print data
datas = {
'ids': [],
'model': 'account_followup.followup',
@@ -337,6 +353,7 @@ class account_followup_print_all(osv.osv_memory):
'datas': datas,
}
+
account_followup_print_all()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml
index fe77dbc053e..8fac644664c 100644
--- a/addons/account_followup/wizard/account_followup_print_view.xml
+++ b/addons/account_followup/wizard/account_followup_print_view.xml
@@ -71,33 +71,12 @@
+
+
or
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
From 5518ab757bd49d14cc8b2cc90526c3150e8c867a Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Wed, 24 Oct 2012 17:37:34 +0200
Subject: [PATCH 06/38] [IMP] Wizard extra button try + next level field
bzr revid: jco@openerp.com-20121024153734-rda572kyd627yims
---
addons/account_followup/account_followup.py | 50 ++++++++++++++++---
.../account_followup_customers.xml | 47 +++++++++++++----
.../wizard/account_followup_print.py | 28 ++++++++++-
.../wizard/account_followup_print_view.xml | 6 +++
4 files changed, 110 insertions(+), 21 deletions(-)
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index cee0feaf574..e3fc28b58ff 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -127,8 +127,7 @@ class res_partner(osv.osv):
# if (accountmoveline.followup_date != False) and (latest_date < accountmoveline.followup_date):
# latest_date = accountmoveline.followup_date
#if accountmovelines:
- amls2 = filter(lambda a: (a.state != 'draft') and (a.account_id.type is 'receivable')
- and (a.debit > 0), accountmovelines)
+ amls2 = filter(lambda a: (a.state != 'draft') and (a.debit > 0), accountmovelines)
res[partner.id] = max(x.followup_date for x in amls2) if len(amls2) else False
#else:
# res[partner.id] = False
@@ -149,23 +148,58 @@ class res_partner(osv.osv):
res[partner.id] = False
for accountmoveline in amls:
- if (accountmoveline.followup_line_id != False) and (level_days < accountmoveline.followup_line_id.delay) and (accountmoveline.state != "draft"): # and (accountmoveline.debit > 0):
+ if (accountmoveline.followup_line_id != False) and (level_days < accountmoveline.followup_line_id.delay):
+ # and (accountmoveline.debit > 0): (accountmoveline.state != "draft") and
+ #and (accountmoveline.reconcile_id == None)
level_days = accountmoveline.followup_line_id.delay
latest_level = accountmoveline.followup_line_id.id
res[partner.id] = latest_level
#res[partner.id] = max(x.followup_line_id.delay for x in amls) if len(amls) else False
return res
+ def get_latest_followup_level(self):
+ amls = self.accountmoveline_ids
+
+
+ def _get_next_followup_level_id(self, cr, uid, ids, name, arg, context=None):
+ res = {}
+ for partner in self.browse(cr, uid, ids):
+ latest_id = self._get_latest_followup_level_id(cr, uid, [partner.id], name, arg, context)[partner.id]
+ latest = self.pool.get('account_followup.followup.line').browse(cr, uid, [latest_id], context)[0]
+ delay = False
+ newlevel = False
+ if latest: #if latest exists
+ newlevel = latest.id
+ old_delay = latest.delay
+ else:
+ old_delay = False
+
+ for fl in self.pool.get('account_followup.followup.line').search(cr, uid, []): #('followup_id.company_id','=',latest.followup_id.company_id)
+ fl_obj = self.pool.get('account_followup.followup.line').browse(cr, uid, [fl])[0]
+ if not old_delay:
+ if not delay or fl_obj.delay < delay:
+ delay = fl_obj.delay
+ newlevel = fl_obj.id
+ else:
+ if (not delay and (fl_obj.delay > old_delay)) or ((fl_obj.delay < delay) and (fl_obj.delay > old_delay)):
+ delay = fl_obj.delay
+ newlevel = fl_obj.id
+ res[partner.id] = newlevel
+ #Now search one level higher
+ return res
+
_inherit = "res.partner"
_columns = {
- 'payment_responsible_id':fields.many2one('res.users', ondelete='set null'),
+ 'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Responsible', help="Responsible"),
#'payment_followup_level_id':fields.many2one('account_followup.followup.line', 'Followup line'),
- 'payment_note':fields.text('Payment note', help="Payment note"),
+ 'payment_note':fields.text('Payment note', help="Payment note"),
'payment_new_action':fields.text('New action'), #one2many/selection?
- 'accountmoveline_ids':fields.one2many('account.move.line', 'partner_id'),
- 'latest_followup_date':fields.function(_get_latest_followup_date, method=True, type='date', string="latest followup date"),
+ 'accountmoveline_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('debit', '>', 0.0), '&', ('reconcile_id', '=', False), '&',
+ ('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')]),
+ 'latest_followup_date':fields.function(_get_latest_followup_date, method=True, type='date', string="latest followup date", store=True),
'latest_followup_level_id':fields.function(_get_latest_followup_level_id, method=True,
- type='many2one', relation='account_followup.followup.line', string="latest followup level"),
+ type='many2one', relation='account_followup.followup.line', string="latest followup level", store=True),
+ 'next_followup_level_id':fields.function(_get_next_followup_level_id, method=True, type='many2one', relation='account_followup.followup.line', string="next level"),
}
diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml
index 5c659db2903..d5a6e36112a 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -16,30 +16,37 @@
-
+
-
-
+
+
+
+
-
-
-
+
+
+
+
+
+
+
-
+
+
@@ -48,23 +55,38 @@
dddres.partner
-
+
-
+
+
+
-
+
+
+ Search
+ res.partner
+ search
+
+
+
+
+
+
+
+
+ Customer Follow Up
@@ -72,12 +94,15 @@
res.partnerformtree,form
- [('customer', '=', True)]
+
+
+
+
form
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index e17b1669087..605fe5b6347 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -188,7 +188,6 @@ class account_followup_print_all(osv.osv_memory):
if result['start'] == 'end_of_month':
fups[old][0].replace(day=1)
old = result['id']
-
fups[old] = (datetime.date(datetime.MAXYEAR, 12, 31), old)
partner_list = []
@@ -239,7 +238,7 @@ class account_followup_print_all(osv.osv_memory):
msg_unsent = ''
data_user = user_obj.browse(cr, uid, uid, context=context)
for partner in self.pool.get('res.partner').browse(cr, uid, partners, context=context):
- if True: #partner.latest_followup_level_id.send_email:
+ if partner.next_followup_level_id.send_email:
ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable']),('company_id','=',context.get('company_id', False))])
data_lines = move_obj.browse(cr, uid, ids_lines, context=context)
total_amt = 0.0
@@ -353,6 +352,31 @@ class account_followup_print_all(osv.osv_memory):
'datas': datas,
}
+ def do_process(self, cr, uid, ids, context=None):
+ resu = self.do_mail(cr,uid,ids,context)
+ mod_obj = self.pool.get('ir.model.data')
+ move_obj = self.pool.get('account.move.line')
+ user_obj = self.pool.get('res.users')
+ if context is None:
+ context = {}
+ data = self.browse(cr, uid, ids, context=context)[0]
+ stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
+ partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
+ model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ print "start changeof new action..."
+
+ partnersfilt = []
+ partner_obj = self.pool.get('res.partner')
+ for partner in partner_obj.browse(cr, uid, partners, context):
+ if partner.next_followup_level_id.phonecall:
+ partnersfilt.append(partner.id)
+ print "Should have been changed"
+ print partner.name
+ partner_obj = self.pool.get('res.partner').write(cr, uid, partnersfilt, {'payment_new_action': "Take your phone and call him, please!!!"})
+ resu2 = self.do_print(cr,uid,ids,context)
+ return resu2
+
account_followup_print_all()
diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml
index 8fac644664c..e8ea58aa2b3 100644
--- a/addons/account_followup/wizard/account_followup_print_view.xml
+++ b/addons/account_followup/wizard/account_followup_print_view.xml
@@ -100,5 +100,11 @@
formnew
+
+
+
+
+
+
From 60372263decd212845bc55711c3587f4249643e2 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 25 Oct 2012 10:08:22 +0200
Subject: [PATCH 07/38] [IMP] Changes dates
bzr revid: jco@openerp.com-20121025080822-7pbbpwoveuqv3u64
---
addons/account_followup/account_followup.py | 5 ++--
.../account_followup_customers.xml | 30 ++++++++-----------
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index e3fc28b58ff..d0e9da38e52 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -79,7 +79,7 @@ class account_move_line(osv.osv):
'payment_commitment':fields.text('Commitment'),
'payment_date':fields.date('Date'),
#'payment_note':fields.text('Payment note'),
- 'payment_new_action':fields.text('New action'),
+ 'payment_next_action':fields.text('New action'),
}
account_move_line()
@@ -193,7 +193,8 @@ class res_partner(osv.osv):
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Responsible', help="Responsible"),
#'payment_followup_level_id':fields.many2one('account_followup.followup.line', 'Followup line'),
'payment_note':fields.text('Payment note', help="Payment note"),
- 'payment_new_action':fields.text('New action'), #one2many/selection?
+ 'payment_next_action':fields.text('Next action', help="Write here the comments of your customer"), #Just a note
+ 'payment_next_action_date':fields.date('Next action date', help="Next date to take action"), # next action date
'accountmoveline_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('debit', '>', 0.0), '&', ('reconcile_id', '=', False), '&',
('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')]),
'latest_followup_date':fields.function(_get_latest_followup_date, method=True, type='date', string="latest followup date", store=True),
diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml
index d5a6e36112a..859170f1beb 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -37,16 +37,14 @@
-
-
+
-
-
-
+
+
@@ -59,16 +57,17 @@
-
-
-
+
+
+
-
-
+
-
-
-
+
+
+
@@ -94,15 +93,12 @@
res.partnerformtree,form
-
+ []
-
-
-
form
From 43f0cb9b1f9887d9ac194a7725af88bf73c98857 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Thu, 25 Oct 2012 11:15:44 +0200
Subject: [PATCH 08/38] [WIP] account_followup: refactoring of whole followup
process.
bzr revid: qdp-launchpad@openerp.com-20121025091544-pbnjs4yg9vfnta2w
---
.../account_followup_data.xml | 102 ++++-
.../wizard/account_followup_print.py | 411 ++++++++++--------
2 files changed, 318 insertions(+), 195 deletions(-)
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index 2a33e65b2c8..52e6180a887 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -1,19 +1,101 @@
-
-
- Date : %(date)s
+
+
-Dear %(partner_name)s,
+
+
+
+ ${object.user_id.email or ''}
+ ${object.company_id.name} Followup
+ ${object.email}
+
+
+
+TYPE HERE THE MAIL CONTENT YOU WANT
+
Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
+
+
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:
-Please find in attachment a reminder of all your unpaid invoices, for a total amount due of:
+
+ REFERENCES
+ Order number: ${object.name}
+ Order total: ${object.amount_total} ${object.pricelist_id.currency_id.name}
+ Order date: ${object.date_order}
+ % if object.origin:
+ Order reference: ${object.origin}
+ % endif
+ % if object.client_order_ref:
+ Your reference: ${object.client_order_ref}
+ % endif
+ Your contact: ${object.user_id.name}
+
-%(followup_amount).2f %(company_currency)s
+
+ You can view the ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} document, download it and pay online using the following link:
+
+ View Order
-Thanks,
---
-%(user_signature)s
-%(company_name)s
+ % if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state not in ('draft', 'sent'):
+ <%
+ comp_name = quote(object.company_id.name)
+ order_name = quote(object.name)
+ paypal_account = quote(object.company_id.paypal_account)
+ order_amount = quote(str(object.amount_total))
+ cur_name = quote(object.pricelist_id.currency_id.name)
+ paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Order%%20%s" \
+ "&invoice=%s&amount=%s¤cy_code=%s&button_subtype=services&no_note=1" \
+ "&bn=OpenERP_Order_PayNow_%s" % \
+ (paypal_account,comp_name,order_name,order_name,order_amount,cur_name,cur_name)
+ %>
+
+
+
+ ]]>
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index 605fe5b6347..e3366af8041 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -26,49 +26,6 @@ import tools
from osv import fields, osv
from tools.translate import _
-class account_followup_print(osv.osv_memory):
- _name = 'account.followup.print'
- _description = 'Print Follow-up & Send Mail to Customers'
- _columns = {
- 'date': fields.date('Follow-up Sending Date', required=True, help="This field allow you to select a forecast date to plan your follow-ups"),
- 'followup_id': fields.many2one('account_followup.followup', 'Follow-Up', required=True, readonly = True),
- }
-
- def _get_followup(self, cr, uid, context=None):
- if context is None:
- context = {}
- if context.get('active_model', 'ir.ui.menu') == 'account_followup.followup':
- return context.get('active_id', False)
- company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
- followp_id = self.pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)], context=context)
- return followp_id and followp_id[0] or False
-
- def do_continue(self, cr, uid, ids, context=None):
- mod_obj = self.pool.get('ir.model.data')
-
- if context is None:
- context = {}
- data = self.browse(cr, uid, ids, context=context)[0]
- model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all')], context=context)
- resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
- context.update({'followup_id': data.followup_id.id, 'date': data.date, 'company_id': data.followup_id.company_id.id})
- return {
- 'name': _('Select Partners'),
- 'view_type': 'form',
- 'context': context,
- 'view_mode': 'tree,form',
- 'res_model': 'account.followup.print.all',
- 'views': [(resource_id,'form')],
- 'type': 'ir.actions.act_window',
- 'target': 'new',
- }
-
- _defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
- 'followup_id': _get_followup,
- }
-account_followup_print()
-
class account_followup_stat_by_partner(osv.osv):
_name = "account_followup.stat.by.partner"
_description = "Follow-up Statistics by Partner"
@@ -116,37 +73,109 @@ class account_followup_stat_by_partner(osv.osv):
)""")
account_followup_stat_by_partner()
-class account_followup_print_all(osv.osv_memory):
- _name = 'account.followup.print.all'
+class account_followup_print(osv.osv_memory):
+ _name = 'account.followup.print'
_description = 'Print Follow-up & Send Mail to Customers'
_columns = {
- 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True),
- 'email_conf': fields.boolean('Send Email Confirmation'),
- 'email_subject': fields.char('Email Subject', size=64),
- 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'),
- 'email_body': fields.text('Email Body'),
- 'summary': fields.text('Summary', required=True, readonly=True),
- 'test_print': fields.boolean('Test Print', help='Check if you want to print follow-ups without changing follow-ups level.')
+ 'date': fields.date('Follow-up Sending Date', required=True, help="This field allow you to select a forecast date to plan your follow-ups"),
+ 'followup_id': fields.many2one('account_followup.followup', 'Follow-Up', required=True, readonly = True),
}
- def _get_summary(self, cr, uid, context=None):
+
+ def _get_followup(self, cr, uid, context=None):
if context is None:
context = {}
- return context.get('summary', '')
+ if context.get('active_model', 'ir.ui.menu') == 'account_followup.followup':
+ return context.get('active_id', False)
+ company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
+ followp_id = self.pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)], context=context)
+ return followp_id and followp_id[0] or False
- def _get_partners(self, cr, uid, context=None):
- return self._get_partners_followp(cr, uid, [], context=context)['partner_ids']
-
- def _get_msg(self, cr, uid, context=None):
- return self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg
+# def do_continue(self, cr, uid, ids, context=None):
+# mod_obj = self.pool.get('ir.model.data')
+#
+# if context is None:
+# context = {}
+# data = self.browse(cr, uid, ids, context=context)[0]
+# model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all')], context=context)
+# resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+# context.update({'followup_id': data.followup_id.id, 'date': data.date, 'company_id': data.followup_id.company_id.id})
+# return {
+# 'name': _('Select Partners'),
+# 'view_type': 'form',
+# 'context': context,
+# 'view_mode': 'tree,form',
+# 'res_model': 'account.followup.print.all',
+# 'views': [(resource_id,'form')],
+# 'type': 'ir.actions.act_window',
+# 'target': 'new',
+# }
_defaults = {
- 'email_body': _get_msg,
- 'email_subject': _('Invoices Reminder'),
- 'partner_lang': True,
- 'partner_ids': _get_partners,
- 'summary': _get_summary,
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'followup_id': _get_followup,
}
+ def process_partner(self, cr, uid, partner_id, context=None):
+ partner = self.pool.get('account_followup.stat.by.partner').browse(cr, uid, partner_id, context=context)
+ if partner.next_followup_level_id.phonecall:
+ self.do_partner_phonecall(cr, uid, partner_id, context)
+ if partner.next_followup_level_id.mail:
+ self.do_partner_mail()
+ if partner.next_followup_level_id.manual:
+ self.do_partner_manual()
+
+ def do_update_followup_level(self, cr, uid, to_update, context=None):
+ #update the followupo level on account.move.line
+ for id in to_update.keys():
+ if to_update[id]['partner_id'] in data['partner_ids']:
+ cr.execute(
+ "UPDATE account_move_line "\
+ "SET followup_line_id=%s, followup_date=%s "\
+ "WHERE id=%s",
+ (to_update[id]['level'],
+ date, int(id),))
+
+ def do_process(self, cr, uid, ids, context=None):
+ tmp = self._get_partners_followp(cr, uid, ids, context=context)
+ partner_list = tmp['partner_ids']
+ to_update = tmp['to_update']
+ self.do_update_followup_level(cr, uid, to_update, context=context)
+ for partner in partner_list:
+ process_partner(cr, uid, partner, context=context)
+#account_followup_print()
+
+
+#class account_followup_print_all(osv.osv_memory):
+# _name = 'account.followup.print.all'
+# _description = 'Print Follow-up & Send Mail to Customers'
+# _columns = {
+# 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True),
+# 'email_conf': fields.boolean('Send Email Confirmation'),
+# 'email_subject': fields.char('Email Subject', size=64),
+# 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'),
+# 'email_body': fields.text('Email Body'),
+# 'summary': fields.text('Summary', required=True, readonly=True),
+# 'test_print': fields.boolean('Test Print', help='Check if you want to print follow-ups without changing follow-ups level.')
+# }
+# def _get_summary(self, cr, uid, context=None):
+# if context is None:
+# context = {}
+# return context.get('summary', '')
+#
+# def _get_partners(self, cr, uid, context=None):
+# return self._get_partners_followp(cr, uid, [], context=context)['partner_ids']
+#
+# def _get_msg(self, cr, uid, context=None):
+# return self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg
+#
+# _defaults = {
+# 'email_body': _get_msg,
+# 'email_subject': _('Invoices Reminder'),
+# 'partner_lang': True,
+# 'partner_ids': _get_partners,
+# 'summary': _get_summary,
+# }
+
def _get_partners_followp(self, cr, uid, ids, context=None):
data = {}
if context is None:
@@ -221,105 +250,112 @@ class account_followup_print_all(osv.osv_memory):
return {'partner_ids': partner_list, 'to_update': to_update}
- def do_mail(self, cr, uid, ids, context=None):
- mod_obj = self.pool.get('ir.model.data')
- move_obj = self.pool.get('account.move.line')
- user_obj = self.pool.get('res.users')
+ def do_partner_mail(self, cr, uid, partner_ids, context=None):
+ #get the mail template to use
+ mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup', context=context)
+ #complete the mail body with partner information
+ #(to be discussed with fp) attach the report to the mail or include the move lines in the mail body
+ #send the mail (need to check the function name)
- if context is None:
- context = {}
- data = self.browse(cr, uid, ids, context=context)[0]
- stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
- partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
- model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
- resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
- if True: #should not depend on this
- msg_sent = ''
- msg_unsent = ''
- data_user = user_obj.browse(cr, uid, uid, context=context)
- for partner in self.pool.get('res.partner').browse(cr, uid, partners, context=context):
- if partner.next_followup_level_id.send_email:
- ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable']),('company_id','=',context.get('company_id', False))])
- data_lines = move_obj.browse(cr, uid, ids_lines, context=context)
- total_amt = 0.0
- for line in data_lines:
- total_amt += line.debit - line.credit
- dest = False
- if partner:
- dest = [partner.email]
- if not data.partner_lang:
- body = data.email_body
- else:
- cxt = context.copy()
- cxt['lang'] = partner.lang
- body = user_obj.browse(cr, uid, uid, context=cxt).company_id.follow_up_msg
- move_line = ''
- subtotal_due = 0.0
- subtotal_paid = 0.0
- subtotal_maturity = 0.0
- balance = 0.0
- l = '--------------------------------------------------------------------------------------------------------------------------'
- head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Due date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
- for i in data_lines:
- maturity = 0.00
- if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
- maturity = i.debit - i.credit
- subtotal_due = subtotal_due + i.debit
- subtotal_paid = subtotal_paid + i.credit
- subtotal_maturity = subtotal_maturity + int(maturity)
- balance = balance + (i.debit - i.credit)
- move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
- move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
- move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
- val = {
- 'partner_name':partner.name,
- 'followup_amount':total_amt,
- 'user_signature':data_user.name,
- 'company_name':data_user.company_id.name,
- 'company_currency':data_user.company_id.currency_id.name,
- 'line':move_line,
- 'heading': head,
- 'date':time.strftime('%Y-%m-%d'),
- }
- body = body%val
- sub = tools.ustr(data.email_subject)
- msg = ''
- if dest:
- try:
- vals = {'state': 'outgoing',
- 'subject': sub,
- 'body_html': '
%s
' % body,
- 'email_to': dest,
- 'email_from': data_user.email or tools.config.options['email_from']}
- self.pool.get('mail.mail').create(cr, uid, vals, context=context)
- msg_sent += partner.name + '\n'
- except Exception, e:
- raise osv.except_osv('Error !', e )
- else:
- msg += partner.name + '\n'
- msg_unsent += msg
- if not msg_unsent:
- summary = _("All Emails have been successfully sent to Partners:.\n\n%s") % msg_sent
- else:
- msg_unsent = _("Email not sent to following Partners, Email not available !\n\n%s") % msg_unsent
- msg_sent = msg_sent and _("\n\nEmail sent to following Partners successfully. !\n\n%s") % msg_sent
- line = '=========================================================================='
- summary = msg_unsent + line + msg_sent
- context.update({'summary': summary})
- else:
- context.update({'summary': '\n\n\nEmail has not been sent to any partner. If you want to send it, please tick send email confirmation on wizard.'})
-
- return {
- 'name': _('Followup Summary'),
- 'view_type': 'form',
- 'context': context,
- 'view_mode': 'tree,form',
- 'res_model': 'account.followup.print.all',
- 'views': [(resource_id,'form')],
- 'type': 'ir.actions.act_window',
- 'target': 'new',
- 'nodestroy': True
- }
+
+# mod_obj = self.pool.get('ir.model.data')
+# move_obj = self.pool.get('account.move.line')
+# user_obj = self.pool.get('res.users')
+#
+# if context is None:
+# context = {}
+# data = self.browse(cr, uid, ids, context=context)[0]
+# stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
+# partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
+# model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
+# resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+# if True: #should not depend on this
+# msg_sent = ''
+# msg_unsent = ''
+# data_user = user_obj.browse(cr, uid, uid, context=context)
+# for partner in self.pool.get('res.partner').browse(cr, uid, partners, context=context):
+# if partner.next_followup_level_id.send_email:
+# ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable']),('company_id','=',context.get('company_id', False))])
+# data_lines = move_obj.browse(cr, uid, ids_lines, context=context)
+# total_amt = 0.0
+# for line in data_lines:
+# total_amt += line.debit - line.credit
+# dest = False
+# if partner:
+# dest = [partner.email]
+# if not data.partner_lang:
+# body = data.email_body
+# else:
+# cxt = context.copy()
+# cxt['lang'] = partner.lang
+# body = user_obj.browse(cr, uid, uid, context=cxt).company_id.follow_up_msg
+# move_line = ''
+# subtotal_due = 0.0
+# subtotal_paid = 0.0
+# subtotal_maturity = 0.0
+# balance = 0.0
+# l = '--------------------------------------------------------------------------------------------------------------------------'
+# head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Due date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
+# for i in data_lines:
+# maturity = 0.00
+# if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
+# maturity = i.debit - i.credit
+# subtotal_due = subtotal_due + i.debit
+# subtotal_paid = subtotal_paid + i.credit
+# subtotal_maturity = subtotal_maturity + int(maturity)
+# balance = balance + (i.debit - i.credit)
+# move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
+# move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
+# move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
+# val = {
+# 'partner_name':partner.name,
+# 'followup_amount':total_amt,
+# 'user_signature':data_user.name,
+# 'company_name':data_user.company_id.name,
+# 'company_currency':data_user.company_id.currency_id.name,
+# 'line':move_line,
+# 'heading': head,
+# 'date':time.strftime('%Y-%m-%d'),
+# }
+# body = body%val
+# sub = tools.ustr(data.email_subject)
+# msg = ''
+# if dest:
+# try:
+# vals = {'state': 'outgoing',
+# 'subject': sub,
+# 'body_html': '
%s
' % body,
+# 'email_to': dest,
+# 'email_from': data_user.email or tools.config.options['email_from']}
+# self.pool.get('mail.mail').create(cr, uid, vals, context=context)
+# msg_sent += partner.name + '\n'
+# except Exception, e:
+# raise osv.except_osv('Error !', e )
+# else:
+# msg += partner.name + '\n'
+# msg_unsent += msg
+# if not msg_unsent:
+# summary = _("All Emails have been successfully sent to Partners:.\n\n%s") % msg_sent
+# else:
+# msg_unsent = _("Email not sent to following Partners, Email not available !\n\n%s") % msg_unsent
+# msg_sent = msg_sent and _("\n\nEmail sent to following Partners successfully. !\n\n%s") % msg_sent
+# line = '=========================================================================='
+# summary = msg_unsent + line + msg_sent
+# context.update({'summary': summary})
+# else:
+# context.update({'summary': '\n\n\nEmail has not been sent to any partner. If you want to send it, please tick send email confirmation on wizard.'})
+#
+# return {
+# 'name': _('Followup Summary'),
+# 'view_type': 'form',
+# 'context': context,
+# 'view_mode': 'tree,form',
+# 'res_model': 'account.followup.print.all',
+# 'views': [(resource_id,'form')],
+# 'type': 'ir.actions.act_window',
+# 'target': 'new',
+# 'nodestroy': True
+# }
def do_print(self, cr, uid, ids, context=None):
if context is None:
@@ -352,30 +388,35 @@ class account_followup_print_all(osv.osv_memory):
'datas': datas,
}
- def do_process(self, cr, uid, ids, context=None):
- resu = self.do_mail(cr,uid,ids,context)
- mod_obj = self.pool.get('ir.model.data')
- move_obj = self.pool.get('account.move.line')
- user_obj = self.pool.get('res.users')
- if context is None:
- context = {}
- data = self.browse(cr, uid, ids, context=context)[0]
- stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
- partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
- model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
- resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
- print "start changeof new action..."
- partnersfilt = []
- partner_obj = self.pool.get('res.partner')
- for partner in partner_obj.browse(cr, uid, partners, context):
- if partner.next_followup_level_id.phonecall:
- partnersfilt.append(partner.id)
- print "Should have been changed"
- print partner.name
- partner_obj = self.pool.get('res.partner').write(cr, uid, partnersfilt, {'payment_new_action': "Take your phone and call him, please!!!"})
- resu2 = self.do_print(cr,uid,ids,context)
- return resu2
+
+
+
+
+#jco tests
+# resu = self.do_mail(cr,uid,ids,context)
+# mod_obj = self.pool.get('ir.model.data')
+# move_obj = self.pool.get('account.move.line')
+# user_obj = self.pool.get('res.users')
+# if context is None:
+# context = {}
+# data = self.browse(cr, uid, ids, context=context)[0]
+# stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
+# partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
+# model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
+# resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+# print "start changeof new action..."
+#
+# partnersfilt = []
+# partner_obj = self.pool.get('res.partner')
+# for partner in partner_obj.browse(cr, uid, partners, context):
+# if partner.next_followup_level_id.phonecall:
+# partnersfilt.append(partner.id)
+# print "Should have been changed"
+# print partner.name
+# partner_obj = self.pool.get('res.partner').write(cr, uid, partnersfilt, {'payment_new_action': "Take your phone and call him, please!!!"})
+# resu2 = self.do_print(cr,uid,ids,context)
+# return resu2
account_followup_print_all()
From c953d9978c0e847f40ceffb2485f842695511190 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 26 Oct 2012 10:09:14 +0200
Subject: [PATCH 09/38] before merge from trunk
bzr revid: jco@openerp.com-20121026080914-8az79d9rkbfoucyf
---
addons/account_followup/account_followup.py | 146 ++++++++++++++-
.../wizard/account_followup_print.py | 168 +++++-------------
.../wizard/account_followup_print_view.xml | 12 +-
3 files changed, 188 insertions(+), 138 deletions(-)
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index d0e9da38e52..0da848aa1f2 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -188,6 +188,150 @@ class res_partner(osv.osv):
#Now search one level higher
return res
+
+ def do_partner_phonecall(self, cr, uid, partner_ids, context=None):
+ #partners = self.browse(cr, uid, partner_ids, context)
+ print partner_ids
+ self.write(cr, uid, partner_ids, {'payment_next_action': 'Phone...'}, context)
+
+ def do_partner_print(self, cr, uid, partner_ids, data, context=None):
+ #data.update({'date': context['date']})
+ if not partner_ids:
+ return {}
+ data['partner_ids'] = partner_ids
+ print data
+ datas = {
+ 'ids': [],
+ 'model': 'account_followup.followup',
+ 'form': data
+ }
+
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'account_followup.followup.print',
+ 'datas': datas,
+ }
+
+ def do_partner_mail(self, cr, uid, partner_ids, context=None):
+ #get the mail template to use
+ mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup')
+ mtp = self.pool.get('email.template')
+ #mtp.subject = "Invoices overdue"
+
+ #user_obj = self.pool.get('res.users')
+
+ #mtp.email_from = user_obj.browse(cr, uid, uid, context=context)
+ for partner in self.browse(cr, uid, partner_ids, context):
+ pass
+ # mtp.send_mail(cr, uid, partner.id, mail_template_id, context=context)
+
+
+ #complete the mail body with partner information
+ #(to be discussed with fp) attach the report to the mail or include the move lines in the mail body
+ #send the mail (need to check the function name)
+
+
+# mod_obj = self.pool.get('ir.model.data')
+# move_obj = self.pool.get('account.move.line')
+# user_obj = self.pool.get('res.users')
+#
+# if context is None:
+# context = {}
+# data = self.browse(cr, uid, ids, context=context)[0]
+# stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
+# partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
+# model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
+# resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+# if True: #should not depend on this
+# msg_sent = ''
+# msg_unsent = ''
+# data_user = user_obj.browse(cr, uid, uid, context=context)
+# for partner in self.pool.get('res.partner').browse(cr, uid, partners, context=context):
+# if partner.next_followup_level_id.send_email:
+# ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable']),('company_id','=',context.get('company_id', False))])
+# data_lines = move_obj.browse(cr, uid, ids_lines, context=context)
+# total_amt = 0.0
+# for line in data_lines:
+# total_amt += line.debit - line.credit
+# dest = False
+# if partner:
+# dest = [partner.email]
+# if not data.partner_lang:
+# body = data.email_body
+# else:
+# cxt = context.copy()
+# cxt['lang'] = partner.lang
+# body = user_obj.browse(cr, uid, uid, context=cxt).company_id.follow_up_msg
+# move_line = ''
+# subtotal_due = 0.0
+# subtotal_paid = 0.0
+# subtotal_maturity = 0.0
+# balance = 0.0
+# l = '--------------------------------------------------------------------------------------------------------------------------'
+# head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Due date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
+# for i in data_lines:
+# maturity = 0.00
+# if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
+# maturity = i.debit - i.credit
+# subtotal_due = subtotal_due + i.debit
+# subtotal_paid = subtotal_paid + i.credit
+# subtotal_maturity = subtotal_maturity + int(maturity)
+# balance = balance + (i.debit - i.credit)
+# move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
+# move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
+# move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
+# val = {
+# 'partner_name':partner.name,
+# 'followup_amount':total_amt,
+# 'user_signature':data_user.name,
+# 'company_name':data_user.company_id.name,
+# 'company_currency':data_user.company_id.currency_id.name,
+# 'line':move_line,
+# 'heading': head,
+# 'date':time.strftime('%Y-%m-%d'),
+# }
+# body = body%val
+# sub = tools.ustr(data.email_subject)
+# msg = ''
+# if dest:
+# try:
+# vals = {'state': 'outgoing',
+# 'subject': sub,
+# 'body_html': '
%s
' % body,
+# 'email_to': dest,
+# 'email_from': data_user.email or tools.config.options['email_from']}
+# self.pool.get('mail.mail').create(cr, uid, vals, context=context)
+# msg_sent += partner.name + '\n'
+# except Exception, e:
+# raise osv.except_osv('Error !', e )
+# else:
+# msg += partner.name + '\n'
+# msg_unsent += msg
+# if not msg_unsent:
+# summary = _("All Emails have been successfully sent to Partners:.\n\n%s") % msg_sent
+# else:
+# msg_unsent = _("Email not sent to following Partners, Email not available !\n\n%s") % msg_unsent
+# msg_sent = msg_sent and _("\n\nEmail sent to following Partners successfully. !\n\n%s") % msg_sent
+# line = '=========================================================================='
+# summary = msg_unsent + line + msg_sent
+# context.update({'summary': summary})
+# else:
+# context.update({'summary': '\n\n\nEmail has not been sent to any partner. If you want to send it, please tick send email confirmation on wizard.'})
+#
+# return {
+# 'name': _('Followup Summary'),
+# 'view_type': 'form',
+# 'context': context,
+# 'view_mode': 'tree,form',
+# 'res_model': 'account.followup.print.all',
+# 'views': [(resource_id,'form')],
+# 'type': 'ir.actions.act_window',
+# 'target': 'new',
+# 'nodestroy': True
+# }
+
+
+
_inherit = "res.partner"
_columns = {
'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Responsible', help="Responsible"),
@@ -201,8 +345,8 @@ class res_partner(osv.osv):
'latest_followup_level_id':fields.function(_get_latest_followup_level_id, method=True,
type='many2one', relation='account_followup.followup.line', string="latest followup level", store=True),
'next_followup_level_id':fields.function(_get_next_followup_level_id, method=True, type='many2one', relation='account_followup.followup.line', string="next level"),
- }
+ }
res_partner()
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index e3366af8041..262f4e43403 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -79,6 +79,14 @@ class account_followup_print(osv.osv_memory):
_columns = {
'date': fields.date('Follow-up Sending Date', required=True, help="This field allow you to select a forecast date to plan your follow-ups"),
'followup_id': fields.many2one('account_followup.followup', 'Follow-Up', required=True, readonly = True),
+ 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True),
+ 'company_id':fields.related('followup_id', 'company_id', type='many2one', relation='res.company'),
+ #'email_conf': fields.boolean('Send Email Confirmation'),
+ #'email_subject': fields.char('Email Subject', size=64),
+ #'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'),
+ #'email_body': fields.text('Email Body'),
+ 'summary': fields.text('Summary', required=True, readonly=True),
+ 'test_print': fields.boolean('Test Print', help='Check if you want to print follow-ups without changing follow-ups level.')
}
def _get_followup(self, cr, uid, context=None):
@@ -115,19 +123,28 @@ class account_followup_print(osv.osv_memory):
'followup_id': _get_followup,
}
- def process_partner(self, cr, uid, partner_id, context=None):
- partner = self.pool.get('account_followup.stat.by.partner').browse(cr, uid, partner_id, context=context)
- if partner.next_followup_level_id.phonecall:
- self.do_partner_phonecall(cr, uid, partner_id, context)
- if partner.next_followup_level_id.mail:
- self.do_partner_mail()
- if partner.next_followup_level_id.manual:
- self.do_partner_manual()
- def do_update_followup_level(self, cr, uid, to_update, context=None):
+
+ def process_partners(self, cr, uid, partner_ids, data, context=None):
+ partner_obj = self.pool.get('res.partner')
+ partner_ids_to_print = []
+ for partner in self.pool.get('account_followup.stat.by.partner').browse(cr, uid, partner_ids, context=context):
+ if partner.max_followup_id.phonecall:
+ partner_obj.do_partner_phonecall(cr, uid, [partner.id], context)
+ if partner.max_followup_id.send_email:
+ partner_obj.do_partner_mail(cr, uid, [partner.id], context)
+ if partner.max_followup_id.send_letter:
+ partner_ids_to_print.append(partner.id)
+
+ action = partner_obj.do_partner_print(cr, uid, partner_ids_to_print, data, context)
+ return action or {}
+
+
+ def do_update_followup_level(self, cr, uid, to_update, partner_list, date, context=None):
#update the followupo level on account.move.line
for id in to_update.keys():
- if to_update[id]['partner_id'] in data['partner_ids']:
+ if to_update[id]['partner_id'] in partner_list:
+
cr.execute(
"UPDATE account_move_line "\
"SET followup_line_id=%s, followup_date=%s "\
@@ -139,9 +156,12 @@ class account_followup_print(osv.osv_memory):
tmp = self._get_partners_followp(cr, uid, ids, context=context)
partner_list = tmp['partner_ids']
to_update = tmp['to_update']
- self.do_update_followup_level(cr, uid, to_update, context=context)
- for partner in partner_list:
- process_partner(cr, uid, partner, context=context)
+ date = self.browse(cr, uid, ids, context)[0].date
+ data = self.read(cr, uid, ids, [], context)[0]
+ self.do_update_followup_level(cr, uid, to_update, partner_list, date, context=context)
+ res = self.process_partners(cr, uid, partner_list, data, context=context)
+ return res
+
#account_followup_print()
@@ -177,13 +197,9 @@ class account_followup_print(osv.osv_memory):
# }
def _get_partners_followp(self, cr, uid, ids, context=None):
- data = {}
- if context is None:
- context = {}
- if ids:
- data = self.browse(cr, uid, ids, context=context)[0]
- company_id = 'company_id' in context and context['company_id'] or data.company_id.id
-
+ data = {}
+ data = self.browse(cr, uid, ids, context=context)[0]
+ company_id = data.company_id.id
cr.execute(
"SELECT l.partner_id, l.followup_line_id,l.date_maturity, l.date, l.id "\
@@ -250,112 +266,8 @@ class account_followup_print(osv.osv_memory):
return {'partner_ids': partner_list, 'to_update': to_update}
- def do_partner_mail(self, cr, uid, partner_ids, context=None):
- #get the mail template to use
- mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup', context=context)
- #complete the mail body with partner information
- #(to be discussed with fp) attach the report to the mail or include the move lines in the mail body
- #send the mail (need to check the function name)
-
-# mod_obj = self.pool.get('ir.model.data')
-# move_obj = self.pool.get('account.move.line')
-# user_obj = self.pool.get('res.users')
-#
-# if context is None:
-# context = {}
-# data = self.browse(cr, uid, ids, context=context)[0]
-# stat_by_partner_line_ids = [partner_id.id for partner_id in data.partner_ids]
-# partners = [stat_by_partner_line / 10000 for stat_by_partner_line in stat_by_partner_line_ids]
-# model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
-# resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
-# if True: #should not depend on this
-# msg_sent = ''
-# msg_unsent = ''
-# data_user = user_obj.browse(cr, uid, uid, context=context)
-# for partner in self.pool.get('res.partner').browse(cr, uid, partners, context=context):
-# if partner.next_followup_level_id.send_email:
-# ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable']),('company_id','=',context.get('company_id', False))])
-# data_lines = move_obj.browse(cr, uid, ids_lines, context=context)
-# total_amt = 0.0
-# for line in data_lines:
-# total_amt += line.debit - line.credit
-# dest = False
-# if partner:
-# dest = [partner.email]
-# if not data.partner_lang:
-# body = data.email_body
-# else:
-# cxt = context.copy()
-# cxt['lang'] = partner.lang
-# body = user_obj.browse(cr, uid, uid, context=cxt).company_id.follow_up_msg
-# move_line = ''
-# subtotal_due = 0.0
-# subtotal_paid = 0.0
-# subtotal_maturity = 0.0
-# balance = 0.0
-# l = '--------------------------------------------------------------------------------------------------------------------------'
-# head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Due date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
-# for i in data_lines:
-# maturity = 0.00
-# if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
-# maturity = i.debit - i.credit
-# subtotal_due = subtotal_due + i.debit
-# subtotal_paid = subtotal_paid + i.credit
-# subtotal_maturity = subtotal_maturity + int(maturity)
-# balance = balance + (i.debit - i.credit)
-# move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
-# move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
-# move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
-# val = {
-# 'partner_name':partner.name,
-# 'followup_amount':total_amt,
-# 'user_signature':data_user.name,
-# 'company_name':data_user.company_id.name,
-# 'company_currency':data_user.company_id.currency_id.name,
-# 'line':move_line,
-# 'heading': head,
-# 'date':time.strftime('%Y-%m-%d'),
-# }
-# body = body%val
-# sub = tools.ustr(data.email_subject)
-# msg = ''
-# if dest:
-# try:
-# vals = {'state': 'outgoing',
-# 'subject': sub,
-# 'body_html': '
%s
' % body,
-# 'email_to': dest,
-# 'email_from': data_user.email or tools.config.options['email_from']}
-# self.pool.get('mail.mail').create(cr, uid, vals, context=context)
-# msg_sent += partner.name + '\n'
-# except Exception, e:
-# raise osv.except_osv('Error !', e )
-# else:
-# msg += partner.name + '\n'
-# msg_unsent += msg
-# if not msg_unsent:
-# summary = _("All Emails have been successfully sent to Partners:.\n\n%s") % msg_sent
-# else:
-# msg_unsent = _("Email not sent to following Partners, Email not available !\n\n%s") % msg_unsent
-# msg_sent = msg_sent and _("\n\nEmail sent to following Partners successfully. !\n\n%s") % msg_sent
-# line = '=========================================================================='
-# summary = msg_unsent + line + msg_sent
-# context.update({'summary': summary})
-# else:
-# context.update({'summary': '\n\n\nEmail has not been sent to any partner. If you want to send it, please tick send email confirmation on wizard.'})
-#
-# return {
-# 'name': _('Followup Summary'),
-# 'view_type': 'form',
-# 'context': context,
-# 'view_mode': 'tree,form',
-# 'res_model': 'account.followup.print.all',
-# 'views': [(resource_id,'form')],
-# 'type': 'ir.actions.act_window',
-# 'target': 'new',
-# 'nodestroy': True
-# }
+
def do_print(self, cr, uid, ids, context=None):
if context is None:
@@ -376,7 +288,7 @@ class account_followup_print(osv.osv_memory):
(to_update[id]['level'],
date, int(id),))
data.update({'date': context['date']})
- print data
+
datas = {
'ids': [],
'model': 'account_followup.followup',
@@ -406,7 +318,7 @@ class account_followup_print(osv.osv_memory):
# model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context)
# resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
# print "start changeof new action..."
-#
+#
# partnersfilt = []
# partner_obj = self.pool.get('res.partner')
# for partner in partner_obj.browse(cr, uid, partners, context):
@@ -419,6 +331,6 @@ class account_followup_print(osv.osv_memory):
# return resu2
-account_followup_print_all()
+#account_followup_print_all()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml
index e8ea58aa2b3..c9992954445 100644
--- a/addons/account_followup/wizard/account_followup_print_view.xml
+++ b/addons/account_followup/wizard/account_followup_print_view.xml
@@ -12,7 +12,7 @@
@@ -63,7 +63,7 @@
-
+
From 4cedd4a505671e4e50dbf40d1e1fbe866cbbaf91 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 26 Oct 2012 13:23:31 +0200
Subject: [PATCH 10/38] [IMP] wizard default values work
bzr revid: jco@openerp.com-20121026112331-k5aphdh5tfani5s1
---
.../account_followup/wizard/account_followup_print.py | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index 74b6571f347..a9646b1733c 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -118,10 +118,7 @@ class account_followup_print(osv.osv_memory):
# 'target': 'new',
# }
- _defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
- 'followup_id': _get_followup,
- }
+
@@ -173,12 +170,14 @@ class account_followup_print(osv.osv_memory):
return self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg
_defaults = {
- 'email_body': _get_msg,
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'followup_id': _get_followup,
+ 'email_body': _get_msg,
'email_subject': _('Invoices Reminder'),
'partner_lang': True,
'partner_ids': _get_partners,
'summary': _get_summary,
- }
+ }
#account_followup_print()
From 1453d24688447f79a1f582cae76c719e90225674 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 26 Oct 2012 13:34:54 +0200
Subject: [PATCH 11/38] Removed partner_ids default
bzr revid: jco@openerp.com-20121026113454-h0l4xlledmnkhohs
---
.../wizard/account_followup_print.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index a9646b1733c..a0ecd86ce45 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -163,19 +163,19 @@ class account_followup_print(osv.osv_memory):
context = {}
return context.get('summary', '')
- def _get_partners(self, cr, uid, context=None):
- return self._get_partners_followp(cr, uid, [], context=context)['partner_ids']
+ #def _get_partners(self, cr, uid, context=None):
+ # return self._get_partners_followp(cr, uid, [], context=context)['partner_ids']
def _get_msg(self, cr, uid, context=None):
return self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.follow_up_msg
_defaults = {
- 'date': lambda *a: time.strftime('%Y-%m-%d'),
- 'followup_id': _get_followup,
- 'email_body': _get_msg,
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
+ 'followup_id': _get_followup,
+ 'email_body': _get_msg,
'email_subject': _('Invoices Reminder'),
'partner_lang': True,
- 'partner_ids': _get_partners,
+ #'partner_ids': _get_partners,
'summary': _get_summary,
}
#account_followup_print()
From 81a802b22bad49857ee98097fb9a6798ef69980f Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 26 Oct 2012 17:11:25 +0200
Subject: [PATCH 12/38] [IMP] Solved error printing tuple many2one
bzr revid: jco@openerp.com-20121026151125-utppa71g4a5a53c5
---
addons/account_followup/account_followup.py | 33 ++++++++++---------
.../account_followup_data.xml | 3 +-
.../account_followup_view.xml | 1 +
.../wizard/account_followup_print.py | 4 ++-
4 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index 25338677c6d..14362eca733 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -21,6 +21,7 @@
from osv import fields, osv
from datetime import date
+import time
class followup(osv.osv):
_name = 'account_followup.followup'
@@ -50,6 +51,7 @@ class followup_line(osv.osv):
'send_email':fields.boolean('Send email', help="When processing, it will send an email"),
'send_letter':fields.boolean('Print email'),
'phonecall':fields.boolean('Phone call'),
+ 'email_template_id':fields.many2one('email.template', 'Email template', required = False, ondelete='set null')
}
_defaults = {
'start': 'days',
@@ -143,12 +145,11 @@ class res_partner(osv.osv):
for partner in self.browse(cr, uid, ids):
amls = partner.accountmoveline_ids
level_id = 0
- level_days = -1000 #TO BE IMPROVED with boolean checking first time or by using MAX
+ level_days = False #TO BE IMPROVED with boolean checking first time or by using MAX
latest_level = False
res[partner.id] = False
-
for accountmoveline in amls:
- if (accountmoveline.followup_line_id != False) and (level_days < accountmoveline.followup_line_id.delay):
+ if (accountmoveline.followup_line_id != False) and (not level_days or level_days < accountmoveline.followup_line_id.delay):
# and (accountmoveline.debit > 0): (accountmoveline.state != "draft") and
#and (accountmoveline.reconcile_id == None)
level_days = accountmoveline.followup_line_id.delay
@@ -177,9 +178,9 @@ class res_partner(osv.osv):
old_delay = latest.delay
else:
old_delay = False
-
- for fl in self.pool.get('account_followup.followup.line').search(cr, uid, []): #('followup_id.company_id','=',latest.followup_id.company_id)
- fl_obj = self.pool.get('account_followup.followup.line').browse(cr, uid, [fl])[0]
+ fl_ar = self.pool.get('account_followup.followup.line').search(cr, uid, [('followup_id.company_id.id','=', partner.company_id.id)])
+
+ for fl_obj in self.pool.get('account_followup.followup.line').browse(cr, uid, fl_ar):
if not old_delay:
if not delay or fl_obj.delay < delay:
delay = fl_obj.delay
@@ -193,19 +194,18 @@ class res_partner(osv.osv):
return res
- def do_partner_phonecall(self, cr, uid, partner_ids, context=None):
+ def do_partner_phonecall(self, cr, uid, partner_ids, context=None):
#partners = self.browse(cr, uid, partner_ids, context)
- print partner_ids
- #for partner in self.browse(cr, uid, partner_ids, context):
- # print partner.is_company
- self.write(cr, uid, partner_ids, {'payment_note': 'Phone...'}, context)
+ #print partner_ids
+ self.write(cr, uid, partner_ids, {'payment_next_date': fields.date.context_today(cr, uid, context), 'payment_next_action':'Phony'}, context)
+
+
def do_partner_print(self, cr, uid, partner_ids, data, context=None):
#data.update({'date': context['date']})
if not partner_ids:
return {}
data['partner_ids'] = partner_ids
- print data
datas = {
'ids': [],
'model': 'account_followup.followup',
@@ -229,9 +229,12 @@ class res_partner(osv.osv):
#mtp.email_from = user_obj.browse(cr, uid, uid, context=context)
for partner in self.browse(cr, uid, partner_ids, context):
pass
- # mtp.send_mail(cr, uid, partner.id, mail_template_id, context=context)
-
-
+ #Get max level of ids
+# if partner.latest_followup_level_id.email_template_id != False:
+# mtp.send_mail(cr, uid, partner.id, partner.latest_followup_level_id.email_template_id.id, context=context)
+# else:
+# mtp.send_mail(cr, uid, partner.id, mail_template_id.id, context=context)
+
#complete the mail body with partner information
#(to be discussed with fp) attach the report to the mail or include the move lines in the mail body
#send the mail (need to check the function name)
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index a14f32b2747..05df2b9a179 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -10,11 +10,12 @@
${object.user_id.email or ''}${object.company_id.name} Followup${object.email}
+ ${object.lang}
-TYPE HERE THE MAIL CONTENT YOU WANT
+ ${object.latest_followup_level_id.description}
Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:
diff --git a/addons/account_followup/account_followup_view.xml b/addons/account_followup/account_followup_view.xml
index f15395d1c33..1a080d71b45 100644
--- a/addons/account_followup/account_followup_view.xml
+++ b/addons/account_followup/account_followup_view.xml
@@ -30,6 +30,7 @@
+
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index a0ecd86ce45..f926c1f1b16 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -80,7 +80,7 @@ class account_followup_print(osv.osv_memory):
'date': fields.date('Follow-up Sending Date', required=True, help="This field allow you to select a forecast date to plan your follow-ups"),
'followup_id': fields.many2one('account_followup.followup', 'Follow-Up', required=True, readonly = True),
'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True),
- 'company_id':fields.related('followup_id', 'company_id', type='many2one', relation='res.company'),
+ 'company_id':fields.related('followup_id', 'company_id', type='many2one', relation='res.company', store=True, readonly=True),
'email_conf': fields.boolean('Send Email Confirmation'),
'email_subject': fields.char('Email Subject', size=64),
'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'),
@@ -132,6 +132,7 @@ class account_followup_print(osv.osv_memory):
partner_obj.do_partner_mail(cr, uid, [partner.partner_id.id], context)
if partner.max_followup_id.send_letter:
partner_ids_to_print.append(partner.id)
+
action = partner_obj.do_partner_print(cr, uid, partner_ids_to_print, data, context)
return action or {}
@@ -154,6 +155,7 @@ class account_followup_print(osv.osv_memory):
to_update = tmp['to_update']
date = self.browse(cr, uid, ids, context)[0].date
data = self.read(cr, uid, ids, [], context)[0]
+ data['followup_id'] = data['followup_id'][0]
self.do_update_followup_level(cr, uid, to_update, partner_list, date, context=context)
res = self.process_partners(cr, uid, partner_list, data, context=context)
return res
From c74e937b0d9e0cc2a879c3ba712de3c74f0931d4 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 29 Oct 2012 10:29:01 +0100
Subject: [PATCH 13/38] Adjusted email template
bzr revid: jco@openerp.com-20121029092901-gc8y4d1o04ijexkb
---
addons/account_followup/account_followup.py | 20 +++--
.../account_followup_data.xml | 88 ++-----------------
2 files changed, 18 insertions(+), 90 deletions(-)
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index 14362eca733..2fdc1e3969a 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -197,7 +197,9 @@ class res_partner(osv.osv):
def do_partner_phonecall(self, cr, uid, partner_ids, context=None):
#partners = self.browse(cr, uid, partner_ids, context)
#print partner_ids
- self.write(cr, uid, partner_ids, {'payment_next_date': fields.date.context_today(cr, uid, context), 'payment_next_action':'Phony'}, context)
+ print "Testing: " , fields.date.context_today(cr, uid, context)
+ self.write(cr, uid, partner_ids, {'payment_next_action_date': fields.date.context_today(cr, uid, context), 'payment_next_action' : 'Phoning'}, context)
+
@@ -223,18 +225,18 @@ class res_partner(osv.osv):
mail_template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_followup', 'email_template_account_followup')
mtp = self.pool.get('email.template')
#mtp.subject = "Invoices overdue"
-
#user_obj = self.pool.get('res.users')
-
#mtp.email_from = user_obj.browse(cr, uid, uid, context=context)
for partner in self.browse(cr, uid, partner_ids, context):
- pass
+
#Get max level of ids
-# if partner.latest_followup_level_id.email_template_id != False:
-# mtp.send_mail(cr, uid, partner.id, partner.latest_followup_level_id.email_template_id.id, context=context)
-# else:
-# mtp.send_mail(cr, uid, partner.id, mail_template_id.id, context=context)
-
+ if partner.latest_followup_level_id.email_template_id != False:
+ #print "From latest followup level", partner.latest_followup_level_id.email_template_id.id
+ mtp.send_mail(cr, uid, partner.latest_followup_level_id.email_template_id.id, partner.id, context=context)
+ else:
+ #print "From mail template", mail_template_id.id
+ mtp.send_mail(cr, uid, mail_template_id.id, partner.id, context=context)
+
#complete the mail body with partner information
#(to be discussed with fp) attach the report to the mail or include the move lines in the mail body
#send the mail (need to check the function name)
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index 05df2b9a179..85a8f493189 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -6,7 +6,7 @@
-
+ Followup of outstanding accounts${object.user_id.email or ''}${object.company_id.name} Followup${object.email}
@@ -16,94 +16,20 @@
${object.latest_followup_level_id.description}
-
Hello${object.partner_id.name and ' ' or ''}${object.partner_id.name or ''},
+
Hello${object.name and ' ' or ''},
-
Here is your ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} from ${object.company_id.name}:
+
We see in our books that some accounts are not settled yet:
+
+ <%for aml in ${object.accountmoveline_ids}>
+ ${aml.debit}
+ <%endfor>
REFERENCES
Order number: ${object.name}
- Order total: ${object.amount_total} ${object.pricelist_id.currency_id.name}
- Order date: ${object.date_order}
- % if object.origin:
- Order reference: ${object.origin}
- % endif
- % if object.client_order_ref:
- Your reference: ${object.client_order_ref}
- % endif
Your contact: ${object.user_id.name}
-
-
- Testing
-
-
-
-
-
-
-
- You can view the ${object.state in ('draft', 'sent') and 'quotation' or 'order confirmation'} document, download it and pay online using the following link:
-
- View Order
-
- % if object.order_policy in ('prepaid','manual') and object.company_id.paypal_account and object.state not in ('draft', 'sent'):
- <%
- comp_name = quote(object.company_id.name)
- order_name = quote(object.name)
- paypal_account = quote(object.company_id.paypal_account)
- order_amount = quote(str(object.amount_total))
- cur_name = quote(object.pricelist_id.currency_id.name)
- paypal_url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=%s&item_name=%s%%20Order%%20%s" \
- "&invoice=%s&amount=%s¤cy_code=%s&button_subtype=services&no_note=1" \
- "&bn=OpenERP_Order_PayNow_%s" % \
- (paypal_account,comp_name,order_name,order_name,order_amount,cur_name,cur_name)
- %>
-
-
We see in our books that some accounts are not settled yet:
+
Dear ${object.name and ' ' or ''},
+
+ 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.
+
+
+Best Regards,
-
+
-
Debit
-
Credit
-
Reference
+
Invoice date
+
Reference
+
Maturity date
+
Amount
+
Lit.
-
% for aml in object.accountmoveline_ids :
-${aml.debit}
-
-
-${aml.credit}
+${aml.date}
${aml.ref}
+
+% if aml.date_maturity and aml.date_maturity > fields.date.context_today(cr, uid, context):
+${aml.date_maturity}
+% else:
+${aml.date}
+% endif
+
-% if aml.date_maturity:
-${aml.date_maturity}
-% else:
-${aml.date}
-% endif
-
-
-${aml.debit}
-
-
-% if aml.blocked:
- X
-% endif
-
+
+% for aml in amls:
+
+${mel[aml.id]}
% endfor
-
+
+
+
+
Total overdue amount: ${object.payment_amount_overdue}
]]>
@@ -142,7 +171,7 @@ ${aml.debit}
Followup of overdue invoices level 2${user.email or ''}
- ${object.company_id.name} Followup
+ ${object.company_id.name} Payments Follow-up${object.email}${object.lang}
@@ -161,44 +190,59 @@ In case of any queries concerning this matter, do not hesitate to contact our ac
Best Regards,
+
+${user.name}
+
+
+
Invoice date
Reference
-
Maturity date
+
Due date
Amount
Lit.
-% for aml in object.accountmoveline_ids :
-
+<%
+ amls = object.accountmoveline_ids
+ mel = {}
+ for aml in amls:
+ strbegin = "
"
+ strend = "
"
+ date = False
+ if aml.date_maturity:
+ date = aml.date_maturity
+ if aml.date_maturity <= ctx['current_date'] and aml.debit > 0:
+ strbegin = "
"
+ strend = "
"
+ else:
+ if aml.date <= ctx['current_date'] and aml.debit > 0:
+ strbegin = "
Here we define the different follow-up levels for the company.
+ Every level defines actions that need to be taken after a certain amount of days after the due date of an invoice
+
@@ -84,8 +88,8 @@
account_followup.followup
-
-
+
+
@@ -95,8 +99,9 @@
account_followup.followup
-
+
+
@@ -118,7 +123,12 @@
-
+
+
+
+
+
+
diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py
index 81483ca374d..bf7399f6444 100644
--- a/addons/account_followup/wizard/account_followup_print.py
+++ b/addons/account_followup/wizard/account_followup_print.py
@@ -74,6 +74,35 @@ class account_followup_stat_by_partner(osv.osv):
)""") #Blocked is to take into account litigation
account_followup_stat_by_partner()
+
+class account_followup_sending_results(osv.osv_memory):
+
+
+ def do_report(self, cr, uid, ids, context=None):
+ res = {}
+ #print "context:", self.report_data
+ return context['report_data']
+
+
+ def _get_description(self, cr, uid, context=None):
+ res = ""
+ if context!=None:
+ res = context['description']
+ self.report_data = context['report_data']
+ return res
+
+ _name = 'account.followup.sending.results'
+ _description = 'Results from the sending of the different letters and emails'
+ _columns = {
+ 'description':fields.text("Description", required=False),
+ }
+ _defaults = {
+ 'description':_get_description
+ }
+
+account_followup_sending_results()
+
+
class account_followup_print(osv.osv_memory):
_name = 'account.followup.print'
_description = 'Print Follow-up & Send Mail to Customers'
@@ -87,7 +116,7 @@ class account_followup_print(osv.osv_memory):
'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'),
'email_body': fields.text('Email Body'),
'summary': fields.text('Summary', readonly=True),
- 'test_print': fields.boolean('Test Print', help='Check if you want to print follow-ups without changing follow-ups level.'),
+ 'test_print': fields.boolean('Test Print', help='Check if you want to print follow-ups without changing follow-ups level.'),
}
def _get_followup(self, cr, uid, context=None):
@@ -126,14 +155,27 @@ class account_followup_print(osv.osv_memory):
def process_partners(self, cr, uid, partner_ids, data, context=None):
partner_obj = self.pool.get('res.partner')
partner_ids_to_print = []
+ self.resulttext = "Report"
+ nbmanuals = 0
+ manuals = {}
+ nbmails = 0
+ nbprints = 0
for partner in self.pool.get('account_followup.stat.by.partner').browse(cr, uid, partner_ids, context=context):
if partner.max_followup_id.manual_action:
partner_obj.do_partner_manual_action(cr, uid, [partner.partner_id.id], context)
+ nbmanuals = nbmanuals + 1
+ key = partner.partner_id.payment_responsible_id.name or "Empty"
+ manuals[key]= "Y"
if partner.max_followup_id.send_email:
partner_obj.do_partner_mail(cr, uid, [partner.partner_id.id], context)
+ nbmails = nbmails + 1
if partner.max_followup_id.send_letter:
partner_ids_to_print.append(partner.id)
+ nbprints = nbprints+ 1
partner_obj.message_post(cr, uid, [partner.partner_id.id], body=_("Follow-up letter will be sent"), context=context)
+ self.resulttext = self.resulttext + str(nbmanuals) + "Changed \n" + str(nbmails) + " Emailed \n " + str(nbprints) + "Printed \n"
+ for item in manuals:
+ self.resulttext = self.resulttext + item + ":" + manuals[item] + "\n"
action = partner_obj.do_partner_print(cr, uid, partner_ids_to_print, data, context)
return action or {}
@@ -159,7 +201,52 @@ class account_followup_print(osv.osv_memory):
data['followup_id'] = data['followup_id'][0]
self.do_update_followup_level(cr, uid, to_update, partner_list, date, context=context)
res = self.process_partners(cr, uid, partner_list, data, context=context)
- return res
+ mod_obj = self.pool.get('ir.model.data')
+ if context is None:
+ context = {}
+ data = self.browse(cr, uid, ids, context=context)[0]
+ model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_sending_results')], context=context)
+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ context.update({'description': self.resulttext, 'report_data': res})
+# res['name'] = _('Incredibly interesting report')
+# res['view_type'] = 'form'
+# res['context'] = context
+# res['view_mode'] = 'tree,form'
+# res['res_model'] = 'account.followup.sending.results'
+# res['views'] = [(resource_id,'form')]
+# res['type'] = 'ir.actions.act_window'
+# res['target'] = 'new'
+ return {
+ 'name': _('Incredibly interesting report'),
+ 'view_type': 'form',
+ 'context': context,
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.followup.sending.results',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+
+ #This can go away afterwards
+ def do_second_button(self, cr, uid, ids, context=None):
+ mod_obj = self.pool.get('ir.model.data')
+ if context is None:
+ context = {}
+ data = self.browse(cr, uid, ids, context=context)[0]
+ model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_sending_results')], context=context)
+ resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+ context.update({'description': "Let's write a very interesting report here"})
+ return {
+ 'name': _('Incredibly interesting report'),
+ 'view_type': 'form',
+ 'context': context,
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.followup.sending.results',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
def _get_summary(self, cr, uid, context=None):
if context is None:
diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml
index c9992954445..37995d822be 100644
--- a/addons/account_followup/wizard/account_followup_print_view.xml
+++ b/addons/account_followup/wizard/account_followup_print_view.xml
@@ -8,16 +8,20 @@
-
-
+
+
+
+ And again some explanation why this is the greatest wizard of Oz ever.
+
The , the latest level that was executed, was .
-
- He still owns us a total amount of
+
+
The partner owns us
-
This is the action required now:
+
-
+
-
-
-
-
+
+ to be done by:
+
+ No action defined right now.
+
+
+
+
+
+
- By clicking on BLUBS, you can put an invoice as litigation. This means you are still in discussion about it
+ By clicking on the light bulb, you can put an invoice as litigation. This means you are still in discussion about it and it
+ won't be taken into account for going to the next follow-up level.
-
+
@@ -252,12 +197,15 @@
-
+
+
+
@@ -267,7 +215,7 @@
-
+
\ No newline at end of file
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index 98e148fde84..a138af60dc6 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -42,7 +42,6 @@ ${user.name}
Amount
Lit.
-
<%
amls = object.accountmoveline_ids
mel = {}
@@ -267,7 +266,6 @@ ${mel[aml.id]}
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.
-Best Regards,
Best Regards,
diff --git a/addons/account_followup/account_followup_demo.xml b/addons/account_followup/account_followup_demo.xml
index 0e06f5c5e63..d82f85a0e3d 100644
--- a/addons/account_followup/account_followup_demo.xml
+++ b/addons/account_followup/account_followup_demo.xml
@@ -5,14 +5,14 @@
Default Follow-up
- First letter after 15 net days, 30 net days and 45 days end of month levels.
- Level 0 : 15 days
+ Send first reminder email015
+ True
Dear %(partner_name)s,
@@ -26,11 +26,13 @@ Best Regards,
- Level 1 : 30 days
+ Send reminder letter and email130
+ True
+ True
Dear %(partner_name)s,
@@ -46,13 +48,17 @@ Details of due payments is printed below.
Best Regards,
-
+
+
- Level 2 : 45 days
- 2
- 45
+ Call the customer on the phone
+ 3
+ 40
+
+ True
+ Call the customer on the phone!
Dear %(partner_name)s,
@@ -68,5 +74,51 @@ Best Regards,
+
+ More agressive reminder email
+ 4
+ 50
+
+ True
+
+
+Dear %(partner_name)s,
+
+Despite several reminders, your account is still not settled.
+
+Unless full payment is made in next 8 days, then 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.
+
+Best Regards,
+
+
+
+ More agressive reminder letter
+ 5
+ 60
+
+
+ True
+
+
+Dear %(partner_name)s,
+
+Despite several reminders, your account is still not settled.
+
+Unless full payment is made in next 8 days, then 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.
+
+Best Regards,
+
+
+
+
+
diff --git a/addons/account_followup/account_followup_view.xml b/addons/account_followup/account_followup_view.xml
index c461888bb29..da7ea67e4f1 100644
--- a/addons/account_followup/account_followup_view.xml
+++ b/addons/account_followup/account_followup_view.xml
@@ -23,38 +23,48 @@
+
After days, do the following actions:
+
-
-
-
-
+
+ Manual actions can be followed up in the Customers Requiring Action report for
+ every customer and will only be set when the previous action has been marked as done,
+ which can be done in the Payments Follow-up tab of the Customer Form.
+
+
+ The format for the letters and emails can be specified. For the letters (PDF report),
+ the legend is specified below. For emails, we make use of an email template. Changing the text,
+ will change the text of the email template.
+
+
-
+
-
-
+
+
+
-
+
+
@@ -76,9 +86,20 @@
Follow-up
-
Here we define the different follow-up levels for the company.
- Every level defines actions that need to be taken after a certain amount of days after the due date of an invoice
-
+
+ To remind our customers to pay their invoices when they are overdue,
+ we define different levels of severity for paying the invoices.
+ Every level defines actions that need to be taken after a certain amount of days after the due date of an invoice
+
+
+
+
+ When the wizard for processing the follow-ups is run, for every partner the most overdue invoice (without litigation) is checked.
+ If the amount of days overdue is greater or equal than the amount of days specified
+ and the actions of the previous follow-up level were done, then the actions checked
+ for the new follow-up level will be executed.
+
+
@@ -114,24 +135,20 @@
form
- Click to define follow-up levels and their related messages.
+ Click to define follow-up levels and their related actions.
- For each step, specify the message and the day of delay. Use
- the legend to know the using code to adapt the email content to
- the good context (good name, good date) and you can manage the
- multi language of messages.
+ For each step, specify the actions to be taken and delay in days. It is
+ possible to use print and e-mail templates to send specific messages to
+ the customer.
- And again some explanation why this is the greatest wizard of Oz ever.
+ This wizard will check the customers with overdue invoices and will execute the actions needed to
+ send to the customer according to the Follow-up Levels defined. By clicking on the button, the emails will be sent
+ a report will be generated for the letters. In the next screen you will see which actions were executed and be able to
+ print the letters if there are any. Also the manual actions will be set when needed.