From 863b991fb44a2f4227e654fabb2d98dbe26b8928 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 15 Nov 2012 09:16:34 +0100
Subject: [PATCH] [IMP] first changes after usabiliity review
bzr revid: jco@openerp.com-20121115081634-qz70ofb1cgftmn1e
---
addons/account/account.py | 4 +-
addons/account/account_invoice.py | 6 +-
addons/account_followup/__openerp__.py | 2 +-
addons/account_followup/account_followup.py | 45 +++--
.../account_followup_customers.xml | 158 ++++++++++++------
.../account_followup_view.xml | 90 +++++-----
.../wizard/account_followup_print.py | 91 +++++++++-
.../wizard/account_followup_print_view.xml | 35 ++--
8 files changed, 300 insertions(+), 131 deletions(-)
diff --git a/addons/account/account.py b/addons/account/account.py
index cfba30856a9..aa837ae29a2 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -293,7 +293,7 @@ class account_account(osv.osv):
null_result = dict((fn, 0.0) for fn in field_names)
if children_and_consolidated:
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
-
+
wheres = [""]
if query.strip():
wheres.append(query.strip())
@@ -1277,7 +1277,7 @@ class account_move(osv.osv):
if cond[1] in ['=like', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in', 'child_of']:
continue
- cr.execute("select move_id from account_move_line group by move_id having sum(debit) %s %%s" % (cond[1]),(amount,))
+ cr.execute("select partner_id from account_move_line group by partner_id having sum(balance) %s %%s" % (cond[1]),(amount,))
res_ids = set(id[0] for id in cr.fetchall())
ids = ids and (ids & res_ids) or res_ids
if ids:
diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py
index b01fc974bef..6266a7d6634 100644
--- a/addons/account/account_invoice.py
+++ b/addons/account/account_invoice.py
@@ -518,11 +518,11 @@ class account_invoice(osv.osv):
return result
def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):
- res = {}
- if not payment_term_id:
- return res
+ res = {}
if not date_invoice:
date_invoice = time.strftime('%Y-%m-%d')
+ if not payment_term_id:
+ return {'value':{'date_due': date_invoice}} #To make sure the invoice has a due date when no payment term
pterm_list = self.pool.get('account.payment.term').compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)
if pterm_list:
pterm_list = [line[0] for line in pterm_list]
diff --git a/addons/account_followup/__openerp__.py b/addons/account_followup/__openerp__.py
index bb0df3b7f44..6b0c12c0be3 100644
--- a/addons/account_followup/__openerp__.py
+++ b/addons/account_followup/__openerp__.py
@@ -51,12 +51,12 @@ Note that if you want to check the follow-up level for a given partner/account e
'data': [
'security/account_followup_security.xml',
'security/ir.model.access.csv',
- 'wizard/account_followup_print_view.xml',
'report/account_followup_report.xml',
'account_followup_data.xml',
'account_followup_demo.xml', # Defined by default
'account_followup_view.xml',
'account_followup_customers.xml',
+ 'wizard/account_followup_print_view.xml',
],
'demo': [],
'test': [
diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index 0c7fed2bd66..a7067bf7a8c 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -30,13 +30,13 @@ from tools.translate import _
class followup(osv.osv):
_name = 'account_followup.followup'
_description = 'Account Follow-up'
- #_rec_name = 'company_id'
+ _rec_name = 'name'
_columns = {
- 'name': fields.char('Name', size=64, required=True),
-
- 'description': fields.text('Description'),
+ #'name': fields.char('Name', size=64, required=True),
+ #'description': fields.text('Description'),
'followup_line': fields.one2many('account_followup.followup.line', 'followup_id', 'Follow-up'),
'company_id': fields.many2one('res.company', 'Company', required=True),
+ 'name': fields.related('company_id', 'name', string = "Name"),
}
_defaults = {
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'account_followup.followup', context=c),
@@ -297,8 +297,8 @@ class res_partner(osv.osv):
for partner in self.browse(cr, uid, ids, context):
res[partner.id] = 0.0
for aml in partner.accountmoveline_ids:
- if ((not aml.date_maturity) and (aml.date <= fields.date.context_today(cr, uid, context))) or (aml.date_maturity <= fields.date.context_today(cr, uid, context)):
- res[partner.id] = res[partner.id] + aml.debit - aml.credit #or by using function field
+ #if ((not aml.date_maturity) and (aml.date <= fields.date.context_today(cr, uid, context))) or (aml.date_maturity <= fields.date.context_today(cr, uid, context)):
+ res[partner.id] = res[partner.id] + aml.debit - aml.credit #or by using function field
return res
@@ -333,7 +333,6 @@ class res_partner(osv.osv):
# If not defined by latest level, it will the default template if it can find it
mtp = self.pool.get('email.template')
for partner in self.browse(cr, uid, partner_ids, context):
-
if partner.latest_followup_level_id_without_lit and partner.latest_followup_level_id_without_lit.send_email and partner.latest_followup_level_id_without_lit.email_template_id.id != False :
mtp.send_mail(cr, uid, partner.latest_followup_level_id_without_lit.email_template_id.id, partner.id, context=context)
else :
@@ -370,12 +369,28 @@ class res_partner(osv.osv):
partnerlist.append(aml.partner_id.id)
return partnerlist
- def _get_other_aml_storeids(self, cr, uid, ids, context=None):
- partnerlist = []
- for aml in self.pool.get("account.move.line").browse(cr, uid, ids, context):
- if aml.partner_id not in partnerlist:
- partnerlist.append(aml.partner_id.id)
- return partnerlist
+
+ def _search_amount(self, cr, uid, obj, name, args, context):
+ ids = set()
+ for cond in args:
+ amount = cond[2]
+ if isinstance(cond[2],(list,tuple)):
+ if cond[1] in ['in','not in']:
+ amount = tuple(cond[2])
+ else:
+ continue
+ else:
+ if cond[1] in ['=like', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in', 'child_of']:
+ continue
+
+ cr.execute("select move_id from account_move_line group by move_id having sum(debit) %s %%s" % (cond[1]),(amount,))
+ res_ids = set(id[0] for id in cr.fetchall())
+ ids = ids and (ids & res_ids) or res_ids
+ if ids:
+ return [('id', 'in', tuple(ids))]
+ return [('id', '=', '0')]
+
+
_inherit = "res.partner"
_columns = {
@@ -406,7 +421,9 @@ class res_partner(osv.osv):
string="Next Level", help="The next follow-up level to come when the customer still refuses to pay",
store={'account.move.line': (_get_aml_storeids, ['followup_line_id', 'followup_date'], 10)}),
'payment_amount_overdue':fields.function(_get_amount_overdue, method=True, type='float', string="Amount Overdue",
- help="Amount Overdue: The amount the customer should already have paid"),
+ help="Amount Overdue: The amount the customer should already have paid",
+ store={'account.move.line': (_get_aml_storeids, ['debit', 'credit'], 10)},
+ ),
}
res_partner()
diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml
index c8beaa144a4..f77729be2e9 100644
--- a/addons/account_followup/account_followup_customers.xml
+++ b/addons/account_followup/account_followup_customers.xml
@@ -77,19 +77,53 @@
-->
+
+
+
+
-
-
+
+
-
+
+
+ Search
+ res.partner
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Search
res.partner
search
@@ -104,10 +138,9 @@
-->
-
+
-
-
+
@@ -124,12 +157,12 @@
res.partner
form
tree,form
- []
+
+ {'search_default_todo': True, 'search_default_credits': True}
-
@@ -139,65 +172,86 @@
res.partner.followup.form.inherit
res.partner
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
The , the latest level that was executed, was .
+
+ He still owns us a total amount of
+
+
This is the action required now:
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ By clicking on BLUBS, you can put an invoice as litigation. This means you are still in discussion about it
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/addons/account_followup/account_followup_view.xml b/addons/account_followup/account_followup_view.xml
index 1c90d027538..c461888bb29 100644
--- a/addons/account_followup/account_followup_view.xml
+++ b/addons/account_followup/account_followup_view.xml
@@ -8,8 +8,10 @@
+
+
+
-
@@ -20,45 +22,45 @@
@@ -66,15 +68,17 @@
account_followup.followup.form
account_followup.followup
+
-
@@ -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 @@
-
+
@@ -30,7 +34,7 @@
@@ -63,25 +67,22 @@
-