Josse Colpaert (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/7.0-followupclean-jco into 
lp:openobject-addons/7.0.

Requested reviews:
  qdp (OpenERP) (qdp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-followupclean-jco/+merge/144742

- extra field in wizard to avoid sending to your own companies
- new responsible gets warned through message_post
- change in followup table for translations and description field conform RML 
report
- sales my follow-up menu
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-followupclean-jco/+merge/144742
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/7.0-followupclean-jco.
=== modified file 'account_followup/account_followup.py'
--- account_followup/account_followup.py	2013-01-11 18:42:26 +0000
+++ account_followup/account_followup.py	2013-01-24 16:34:52 +0000
@@ -251,13 +251,14 @@
                 followup_table += '''
                 <table border="2" width=100%%>
                 <tr>
-                    <td>Invoice date</td>
-                    <td>Reference</td>
-                    <td>Due date</td>
-                    <td>Amount (%s)</td>
-                    <td>Lit.</td>
+                    <td>''' + _("Invoice date") + '''</td>
+                    <td>''' + _("Description") + '''</td>
+                    <td>''' + _("Reference") + '''</td>
+                    <td>''' + _("Due date") + '''</td>
+                    <td>''' + _("Amount") + " (%s)" % (currency.symbol) + '''</td>
+                    <td>''' + _("Lit.") + '''</td>
                 </tr>
-                ''' % (currency.symbol)
+                ''' 
                 total = 0
                 for aml in currency_dict['line']:
                     block = aml['blocked'] and 'X' or ' '
@@ -268,15 +269,31 @@
                     if date <= current_date and aml['balance'] > 0:
                         strbegin = "<TD><B>"
                         strend = "</B></TD>"
-                    followup_table +="<TR>" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "</TR>"
+                    followup_table +="<TR>" + 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 + "</TR>"
                 total = rml_parse.formatLang(total, dp='Account', currency_obj=currency)
                 followup_table += '''<tr> </tr>
                                 </table>
-                                <center>Amount due: %s </center>''' % (total)
+                                <center>''' + _("Amount due") + ''' : %s </center>''' % (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" ) + " <b><a href='#id=" + str(part.id) + "&view_type=form&model=res.partner'> " + part.name + " </a></b>",
+                                      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])])
+        res = super(res_partner, self).write(cr, uid, ids, vals, context=context)
+        return res
+
     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)
+        return self.write(cr, uid, ids, {'payment_next_action_date': False, 'payment_next_action':'', 'payment_responsible_id': False}, context=context) 
 
     def do_button_print(self, cr, uid, ids, context=None):
         assert(len(ids) == 1)
@@ -408,13 +425,16 @@
     _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", 

=== modified file 'account_followup/account_followup_customers.xml'
--- account_followup/account_followup_customers.xml	2012-12-18 10:10:49 +0000
+++ account_followup/account_followup_customers.xml	2013-01-24 16:34:52 +0000
@@ -35,10 +35,10 @@
                         <filter string="Follow-ups To Do" domain="[('payment_next_action_date', '&lt;=', time.strftime('%%Y-%%m-%%d')), ('payment_amount_overdue', '>', 0.0)]" name="todo"/>
                         <separator/>
                         <filter string="No Responsible" domain="[('payment_responsible_id', '=', False)]"/>
-                        <filter string="My Follow-ups" domain="[('payment_responsible_id','=', uid)]"/>
+                        <filter string="My Follow-ups" domain="[('payment_responsible_id','=', uid)]" name="my"/>
                     </group>
                     <group expand="1" string="Group By...">
-                        <filter string="Responsible" context="{'group_by':'payment_responsible_id'}"/>
+                        <filter string="Follow-up Responsible" context="{'group_by':'payment_responsible_id'}"/>
                     </group>
                 </search>
             </field>
@@ -132,6 +132,18 @@
         <!-- Menus about followup of customers -->
         <menuitem id="account_followup_s" action="action_customer_followup" 
             parent="menu_finance_followup" name="Do Manual Follow-Ups" sequence="3"/>
-
+        <record id="action_customer_my_followup" model="ir.actions.act_window">
+            <field name="name">My Follow-Ups</field>
+            <field name="view_id" ref="customer_followup_tree"/>
+            <field name="res_model">res.partner</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="domain">[('payment_amount_due', '>', 0.0)]</field>
+            <field name="context">{'Followupfirst':True, 'search_default_todo': True, 'search_default_my': True} </field>
+            <field name="search_view_id" ref="customer_followup_search_view"/>
+        </record>
+        <menuitem id="base.menu_sales_followup" parent="base.menu_base_partner" name="Payment Follow-up" groups="account.group_account_invoice" sequence="2"/>
+        <menuitem id="menu_sale_followup" parent="base.menu_sales_followup" sequence="10" 
+                  action="action_customer_my_followup"  groups="account.group_account_invoice"/>
     </data>
 </openerp>

=== modified file 'account_followup/wizard/account_followup_print.py'
--- account_followup/wizard/account_followup_print.py	2012-12-10 11:16:54 +0000
+++ account_followup/wizard/account_followup_print.py	2013-01-24 16:34:52 +0000
@@ -127,7 +127,8 @@
         '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.'),
+        'intercompany':fields.boolean('Do follow-up for own companies too')
     }
 
     def _get_followup(self, cr, uid, context=None):
@@ -204,7 +205,7 @@
             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:
@@ -301,6 +302,7 @@
         for partner_id, followup_line_id, date_maturity,date, id in move_lines:
             if not partner_id:
                 continue
+
             if followup_line_id not in fups:
                 continue
             stat_line_id = partner_id * 10000 + company_id
@@ -313,6 +315,16 @@
                 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 intercompany partners if asked for in the wizard
+        if not data.intercompany:
+            comp_obj = self.pool.get("res.company")
+            comp_ids = comp_obj.search(cr, 1, [], context=context)
+            for comp in comp_obj.browse(cr, 1, comp_ids, context=context): 
+                # With user 1 because it is possible there is access to the partner
+                # that is the company and not to the company itself
+                partner_ind = comp.partner_id.id * 10000 + company_id
+                if partner_ind in partner_list:
+                    partner_list.remove(partner_ind)
         return {'partner_ids': partner_list, 'to_update': to_update}
 
 account_followup_print()

=== modified file 'account_followup/wizard/account_followup_print_view.xml'
--- account_followup/wizard/account_followup_print_view.xml	2012-12-06 16:40:06 +0000
+++ account_followup/wizard/account_followup_print_view.xml	2013-01-24 16:34:52 +0000
@@ -10,8 +10,9 @@
                 <group col="4">
                     <field name="followup_id" groups="base.group_multi_company"/>
                     <field name="date" groups="base.group_no_one"/>
+                    <field name="intercompany"/>
                 </group>
-                	<p class ="oe_grey">
+                    <p class ="oe_grey">
                         This action will send follow-up emails, print the letters and
                         set the manual actions per customer, according to the follow-up levels defined. 
                     </p>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to