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 - - + +
-
- - - - - - - - - - - - - - - - -