clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00804
[Branch ~banking-addons-team/banking-addons/6.1] Rev 168: [RFR] Clarify code and fix consistency of _get_move_info
Merge authors:
Holger Brunn (Therp) (hbrunn)
Related merge proposals:
https://code.launchpad.net/~therp-nl/banking-addons/6.1_fix__get_move_info_semantics/+merge/162583
proposed by: Holger Brunn (Therp) (hbrunn)
review: Approve - Stefan Rijnhart (Therp) (stefan-therp)
review: Resubmit - Holger Brunn (Therp) (hbrunn)
https://code.launchpad.net/~therp-nl/banking-addons/6.1_lp1176783/+merge/162566
proposed by: Holger Brunn (Therp) (hbrunn)
review: Needs Fixing - Stefan Rijnhart (Therp) (stefan-therp)
------------------------------------------------------------
revno: 168 [merge]
author: hbrunn@xxxxxxxx
committer: Stefan Rijnhart <stefan@xxxxxxxx>
branch nick: 6.1
timestamp: Mon 2013-05-20 16:11:16 +0200
message:
[RFR] Clarify code and fix consistency of _get_move_info
modified:
account_banking/banking_import_transaction.py
--
lp:banking-addons
https://code.launchpad.net/~banking-addons-team/banking-addons/6.1
Your team CLEARCORP development team is subscribed to branch lp:banking-addons.
To unsubscribe from this branch go to https://code.launchpad.net/~banking-addons-team/banking-addons/6.1/+edit-subscription
=== 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-20 08:07:48 +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):