[FIX]account: account bank statement - usability
authorARA (OpenERP) <ara@tinyerp.com>
Tue, 4 Jan 2011 12:40:45 +0000 (18:10 +0530)
committerARA (OpenERP) <ara@tinyerp.com>
Tue, 4 Jan 2011 12:40:45 +0000 (18:10 +0530)
lp bug: https://launchpad.net/bugs/696914 fixed

bzr revid: ara@tinyerp.com-20110104124045-7iyc6opd22ufqtww

addons/account/account_bank_statement.py
addons/account/account_view.xml

index a42d35c..0887c8b 100755 (executable)
@@ -405,6 +405,19 @@ account_bank_statement()
 
 class account_bank_statement_line(osv.osv):
 
+    def onchange_partner_id(self, cr, uid, partner_id, type, context={}):
+        part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
+        if not part.supplier and not part.customer :
+            type = 'general'
+        elif part.supplier == True and part.customer == True :
+            type = 'general'
+        else:
+            if part.supplier == True :
+                type = 'supplier'
+            if part.customer == True :
+                type = 'customer'
+        return type
+
     def onchange_type(self, cr, uid, line_id, partner_id, type, context=None):
         res = {'value': {}}
         obj_partner = self.pool.get('res.partner')
@@ -414,6 +427,8 @@ class account_bank_statement_line(osv.osv):
             return res
         account_id = False
         line = self.browse(cr, uid, line_id, context=context)
+        type=self.onchange_partner_id(cr, uid, partner_id=partner_id, type=type)
+        res.update({'value': {'type':type}})
         if not line or (line and not line[0].account_id):
             part = obj_partner.browse(cr, uid, partner_id, context=context)
             if type == 'supplier':
index b5b4e86..2eb66aa 100755 (executable)
                                 <form string="Statement lines">
                                     <field name="date"/>
                                     <field name="name"/>
-                                    <field name="type" on_change="onchange_type(partner_id, type)"/>
                                     <field name="partner_id" on_change="onchange_type(partner_id, type)"/>
+                                    <field name="type" on_change="onchange_type(partner_id, type)"/>
                                     <field domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id"/>
                                     <field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
                                     <field name="amount"/>