Holger Brunn (Therp) has proposed merging 
lp:~therp-nl/banking-addons/6.1_fix__get_move_info_semantics into 
lp:banking-addons.

Requested reviews:
  Banking Addons Team (banking-addons-team)

For more details, see:
https://code.launchpad.net/~therp-nl/banking-addons/6.1_fix__get_move_info_semantics/+merge/162583

Quote from the discussion on 
https://code.launchpad.net/~therp-nl/banking-addons/6.1_lp1176783/+merge/162566

The method should assign:
- match_type = 'invoice' if there are move lines and all have an invoice, or
- match_type = 'move_lines' if there are move lines,
- match_type = False otherwise

However, the code in your alternative branch does the same for partner and 
account. I do not think that that should be the case. The reason for this is 
that the code considers invoices a special case of move lines. If all move 
lines have invoices we prefer to ask the user to select the correct invoice 
instead of move lines.

There is no such specialization of partners and accounts. Whether the code 
should suggest the partner and account of the first match of multiple matches 
is just an interface issue. These are overwritten anyway when the user 
disambiguates the match.
-- 
https://code.launchpad.net/~therp-nl/banking-addons/6.1_fix__get_move_info_semantics/+merge/162583
Your team Banking Addons Team is requested to review the proposed merge of 
lp:~therp-nl/banking-addons/6.1_fix__get_move_info_semantics into 
lp:banking-addons.
=== modified file 'account_banking/banking_import_transaction.py'
--- account_banking/banking_import_transaction.py	2013-04-26 08:27:33 +0000
+++ account_banking/banking_import_transaction.py	2013-05-06 11:10:38 +0000
@@ -1016,49 +1016,34 @@
                   'account_id': False,
                   }
         move_lines = self.pool.get('account.move.line').browse(cr, uid, move_line_ids)
-        for move_line in move_lines:
-            if move_line.partner_id:
-                if retval['partner_id']:
-                    if retval['partner_id'] != move_line.partner_id.id:
-                        retval['partner_id'] = False
-                        break
-                else:
-                    retval['partner_id'] = move_line.partner_id.id
-            else:
-                if retval['partner_id']: 
-                    retval['partner_id'] = False
-                    break
-        for move_line in move_lines:
-            if move_line.account_id:
-                if retval['account_id']:
-                    if retval['account_id'] != move_line.account_id.id:
-                        retval['account_id'] = False
-                        break
-                else:
-                    retval['account_id'] = move_line.account_id.id
-            else:
-                if retval['account_id']: 
-                    retval['account_id'] = False
-                    break
-        for move_line in move_lines:
-            if move_line.invoice:
-                if retval['match_type']:
-                    if retval['match_type'] != 'invoice':
-                        retval['match_type'] = False
-                        break
-                else:
-                    retval['match_type'] = 'invoice'
-            else:
-                if retval['match_type']: 
-                    retval['match_type'] = False
-                    break
-        if move_lines and not retval['match_type']:
+
+        if not move_lines:
+            return retval
+
+        if move_lines[0].partner_id and all(
+                [move_line.partner_id == move_lines[0].partner_id
+                    for move_line in move_lines):
+            retval['partner_id'] = move_lines[0].partner_id.id
+
+        if move_lines[0].account_id and all(
+                [move_line.account_id == move_lines[0].account_id
+                    for move_line in move_lines]):
+            retval['account_id'] = move_lines[0].account_id.id
+
+        if move_lines[0].invoice and all(
+                [move_line.invoice == move_lines[0].invoice
+                    for move_line in move_lines]):
+            retval['match_type'] = 'invoice'
+            retval['type'] = type_map[move_lines[0].invoice.type]
+            retval['invoice_ids'] = list(
+                set([x.invoice.id for x in move_lines))
+
+        if not retval['match_type']:
             retval['match_type'] = 'move'
-        if move_lines and len(move_lines) == 1:
+
+        if len(move_lines) == 1:
             retval['reference'] = move_lines[0].ref
-        if retval['match_type'] == 'invoice':
-            retval['invoice_ids'] = list(set([x.invoice.id for x in move_lines]))
-            retval['type'] = type_map[move_lines[0].invoice.type]
+
         return retval
     
     def match(self, cr, uid, ids, results=None, context=None):

-- 
Mailing list: https://launchpad.net/~banking-addons-team
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~banking-addons-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to