diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py index 285a3529ee7..aeee35c93dc 100644 --- a/addons/account_followup/account_followup.py +++ b/addons/account_followup/account_followup.py @@ -238,7 +238,12 @@ class res_partner(osv.osv): from report import account_followup_print assert len(ids) == 1 + if context is None: + context = {} partner = self.browse(cr, uid, ids[0], context=context) + #copy the context to not change global context. Overwrite it because _() looks for the lang in local variable 'context'. + #Set the language to use = the partner language + context = dict(context, lang=partner.lang) followup_table = '' if partner.unreconciled_aml_ids: company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id @@ -251,13 +256,14 @@ class res_partner(osv.osv): followup_table += ''' - - - - - + + + + + + - ''' % (currency.symbol) + ''' total = 0 for aml in currency_dict['line']: block = aml['blocked'] and 'X' or ' ' @@ -268,13 +274,28 @@ class res_partner(osv.osv): if date <= current_date and aml['balance'] > 0: strbegin = "" - followup_table +="" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "" + followup_table +="" + strbegin + str(aml['date']) + strend + strbegin + aml['name'] + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "" total = rml_parse.formatLang(total, dp='Account', currency_obj=currency) followup_table += '''
Invoice dateReferenceDue dateAmount (%s)Lit.''' + _("Invoice Date") + '''''' + _("Description") + '''''' + _("Reference") + '''''' + _("Due Date") + '''''' + _("Amount") + " (%s)" % (currency.symbol) + '''''' + _("Lit.") + '''
" strend = "
-
Amount due: %s
''' % (total) +
''' + _("Amount due") + ''' : %s
''' % (total) return followup_table + def write(self, cr, uid, ids, vals, context=None): + if vals.get("payment_responsible_id", False): + for part in self.browse(cr, uid, ids, context=context): + if part.payment_responsible_id <> vals["payment_responsible_id"]: + #Find partner_id of user put as responsible + responsible_partner_id = self.pool.get("res.users").browse(cr, uid, vals['payment_responsible_id'], context=context).partner_id.id + self.pool.get("mail.thread").message_post(cr, uid, 0, + body = _("You became responsible to do the next action for the payment follow-up of") + " " + part.name + " ", + type = 'comment', + subtype = "mail.mt_comment", context = context, + model = 'res.partner', res_id = part.id, + notified_partner_ids = [(6, 0, [responsible_partner_id])], + partner_ids = [(6, 0, [responsible_partner_id])]) + return super(res_partner, self).write(cr, uid, ids, vals, context=context) + def action_done(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'payment_next_action_date': False, 'payment_next_action':'', 'payment_responsible_id': False}, context=context) @@ -408,13 +429,16 @@ class res_partner(osv.osv): _inherit = "res.partner" _columns = { 'payment_responsible_id':fields.many2one('res.users', ondelete='set null', string='Follow-up Responsible', - help="Optionally you can assign a user to this field, which will make him responsible for the action."), - 'payment_note':fields.text('Customer Payment Promise', help="Payment Note"), + help="Optionally you can assign a user to this field, which will make him responsible for the action.", + track_visibility="onchange"), + 'payment_note':fields.text('Customer Payment Promise', help="Payment Note", track_visibility="onchange"), 'payment_next_action':fields.text('Next Action', - help="This is the next action to be taken. It will automatically be set when the partner gets a follow-up level that requires a manual action. "), + help="This is the next action to be taken. It will automatically be set when the partner gets a follow-up level that requires a manual action. ", + track_visibility="onchange"), 'payment_next_action_date':fields.date('Next Action Date', help="This is when the manual follow-up is needed. " \ - "The date will be set to the current date when the partner gets a follow-up level that requires a manual action. Can be practical to set manually e.g. to see if he keeps his promises."), + "The date will be set to the current date when the partner gets a follow-up level that requires a manual action. "\ + "Can be practical to set manually e.g. to see if he keeps his promises."), 'unreconciled_aml_ids':fields.one2many('account.move.line', 'partner_id', domain=['&', ('reconcile_id', '=', False), '&', ('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')]), 'latest_followup_date':fields.function(_get_latest, method=True, type='date', string="Latest Follow-up Date", diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml index 8a27730b003..691d1555e8d 100644 --- a/addons/account_followup/account_followup_customers.xml +++ b/addons/account_followup/account_followup_customers.xml @@ -35,10 +35,10 @@ - + - + @@ -132,6 +132,18 @@ - + + My Follow-Ups + + res.partner + form + tree,form + [('payment_amount_due', '>', 0.0)] + {'Followupfirst':True, 'search_default_todo': True, 'search_default_my': True} + + + + diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index e93b4dd8b69..76aee365e00 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -26,6 +26,8 @@ from openerp import tools from openerp.osv import fields, osv from openerp.tools.translate import _ +from openerp import SUPERUSER_ID + class account_followup_stat_by_partner(osv.osv): _name = "account_followup.stat.by.partner" _description = "Follow-up Statistics by Partner" @@ -127,7 +129,7 @@ class account_followup_print(osv.osv_memory): '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.'), + help='Check if you want to print follow-ups without changing follow-up level.'), } def _get_followup(self, cr, uid, context=None): @@ -204,7 +206,7 @@ class account_followup_print(osv.osv_memory): if not part.unreconciled_aml_ids: partners_to_clear.append(part.id) self.pool.get('res.partner').action_done(cr, uid, partners_to_clear, context=context) - return len(ids) + return len(partners_to_clear) def do_process(self, cr, uid, ids, context=None): if context is None: @@ -313,6 +315,13 @@ class account_followup_print(osv.osv_memory): if stat_line_id not in partner_list: partner_list.append(stat_line_id) to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': stat_line_id} + #Remove partners that are other companies in OpenERP + comp_obj = self.pool.get("res.company") + comp_ids = comp_obj.search(cr, SUPERUSER_ID, [], context=context) + for comp in comp_obj.browse(cr, SUPERUSER_ID, comp_ids, context=context): + company_partner_wiz_id = comp.partner_id.id * 10000 + company_id + if company_partner_wiz_id in partner_list: + partner_list.remove(company_partner_wiz_id) return {'partner_ids': partner_list, 'to_update': to_update} account_followup_print()