~ruchir.shukla/banking-addons/banking-addons-link_partner_without_remote_owner

« back to all changes in this revision

Viewing changes to account_banking/banking_import_transaction.py

[ADD] Module that allows for alternative partner journal accounts to be used
as defaults in imported bank statements (incl. small, necessary refactoring
in core module)

Show diffs side-by-side

added added

removed removed

Lines of Context:
875
875
            # when retrieving move_line_ids below.
876
876
            company = company_obj.browse(
877
877
                cr, uid, transaction.company_id.id, context)
878
 
            # Get default defaults
879
 
            def_pay_account_id = company.partner_id.property_account_payable.id
880
 
            def_rec_account_id = company.partner_id.property_account_receivable.id
881
878
 
882
879
            # Get interesting journals once
883
880
            # Added type 'general' to capture fund transfers
1112
1109
            account_id = move_info and move_info.get('account_id', False)
1113
1110
            if not account_id:
1114
1111
                # Use the default settings, but allow individual partner
1115
 
                # settings to overrule this. Note that you need to change
1116
 
                # the internal type of these accounts to either 'payable'
1117
 
                # or 'receivable' to enable usage like this.
 
1112
                # settings to overrule this.
 
1113
                bank_partner = (
 
1114
                    partner_banks[0].partner_id if len(partner_banks) == 1
 
1115
                    else False)
1118
1116
                if transaction.statement_line_id.amount < 0:
1119
 
                    account_type = 'payable'
1120
 
                else:
1121
 
                    account_type = 'receivable'
1122
 
                if len(partner_banks) == 1:
1123
 
                    partner = partner_banks[0].partner_id
1124
 
                    if partner.supplier and not partner.customer:
1125
 
                        account_type = 'payable'
1126
 
                    elif partner.customer and not partner.supplier:
1127
 
                        account_type = 'receivable'
1128
 
                    if partner['property_account_' + account_type]:
1129
 
                        account_id = partner['property_account_' + account_type].id
1130
 
                if not account_id or account_id in (def_pay_account_id, def_rec_account_id):
1131
 
                    if account_type == 'payable':
 
1117
                    if bank_partner:
 
1118
                        account_id = bank_partner.\
 
1119
                            def_journal_account_bank_decr()[bank_partner.id]
 
1120
                    else:
1132
1121
                        account_id = account_info.default_credit_account_id.id
 
1122
                else:
 
1123
 
 
1124
                    if bank_partner:
 
1125
                        account_id = bank_partner.\
 
1126
                            def_journal_account_bank_incr()[bank_partner.id]
1133
1127
                    else:
1134
1128
                        account_id = account_info.default_debit_account_id.id
1135
1129