banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #00828
lp:~therp-nl/banking-addons/ba70-select_account_by_customer_supplier_setting into lp:banking-addons
Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/banking-addons/ba70-select_account_by_customer_supplier_setting into lp:banking-addons.
Requested reviews:
Banking Addons Core Editors (banking-addons-team)
Related bugs:
Bug #1215891 in Banking Addons: "[ba70] Partner customer/supplier settings ignored when selecting account receivable or payable"
https://bugs.launchpad.net/banking-addons/+bug/1215891
For more details, see:
https://code.launchpad.net/~therp-nl/banking-addons/ba70-select_account_by_customer_supplier_setting/+merge/181818
--
https://code.launchpad.net/~therp-nl/banking-addons/ba70-select_account_by_customer_supplier_setting/+merge/181818
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~therp-nl/banking-addons/ba70-select_account_by_customer_supplier_setting into lp:banking-addons.
=== modified file 'account_banking/banking_import_transaction.py'
--- account_banking/banking_import_transaction.py 2013-08-12 09:20:35 +0000
+++ account_banking/banking_import_transaction.py 2013-08-23 12:51:00 +0000
@@ -1112,21 +1112,23 @@
# the internal type of these accounts to either 'payable'
# or 'receivable' to enable usage like this.
if transaction.statement_line_id.amount < 0:
- if len(partner_banks) == 1:
- account_id = (
- partner_banks[0].partner_id.property_account_payable and
- partner_banks[0].partner_id.property_account_payable.id)
- if len(partner_banks) != 1 or not account_id or account_id == def_pay_account_id:
- account_id = (account_info.default_credit_account_id and
- account_info.default_credit_account_id.id)
+ account_type = 'payable'
else:
- if len(partner_banks) == 1:
- account_id = (
- partner_banks[0].partner_id.property_account_receivable and
- partner_banks[0].partner_id.property_account_receivable.id)
- if len(partner_banks) != 1 or not account_id or account_id == def_rec_account_id:
- account_id = (account_info.default_debit_account_id and
- account_info.default_debit_account_id.id)
+ account_type = 'receivable'
+ if len(partner_banks) == 1:
+ partner = partner_banks[0].partner_id
+ if partner.supplier and not partner.customer:
+ account_type = 'payable'
+ elif partner.customer and not partner.supplier:
+ account_type = 'receivable'
+ if partner['property_account_' + account_type]:
+ account_id = partner['property_account_' + account_type].id
+ if not account_id or account_id in (def_pay_account_id, def_rec_account_id):
+ if account_type == 'payable':
+ account_id = account_info.default_credit_account_id.id
+ else:
+ account_id = account_info.default_debit_account_id.id
+
values = {'account_id': account_id}
self_values = {}
if move_info:
@@ -1495,7 +1497,7 @@
if (not statement_line.import_transaction_id or
not statement_line.import_transaction_id.remote_account):
- raise osv.except_osv(
+ raise orm.except_orm(
_("Error"),
_("No bank account available to link partner to"))
=== modified file 'account_banking/wizard/banking_transaction_wizard.py'
--- account_banking/wizard/banking_transaction_wizard.py 2013-08-12 09:20:35 +0000
+++ account_banking/wizard/banking_transaction_wizard.py 2013-08-23 12:51:00 +0000
@@ -256,14 +256,7 @@
account_id = False
journal_id = wiz.statement_line_id.statement_id.journal_id.id
setting_ids = settings_pool.find(cr, uid, journal_id, context=context)
- if len(setting_ids)>0:
- setting = settings_pool.browse(cr, uid, setting_ids[0], context=context)
- if wiz.amount < 0:
- account_id = setting.default_credit_account_id and setting.default_credit_account_id.id
- else:
- account_id = setting.default_debit_account_id and setting.default_debit_account_id.id
- statement_pool.write(cr, uid, wiz.statement_line_id.id, {'account_id':account_id})
-
+
# Restore partner id from the bank account or else reset
partner_id = False
if (wiz.statement_line_id.partner_bank_id and
@@ -271,6 +264,38 @@
partner_id = wiz.statement_line_id.partner_bank_id.partner_id.id
wiz.write({'partner_id': partner_id})
+ # Select account type by parter customer or supplier,
+ # or default based on amount sign
+ if wiz.amount < 0:
+ account_type = 'payable'
+ else:
+ account_type = 'receivable'
+
+ if partner_id:
+ partner = wiz.statement_line_id.partner_bank_id.partner_id
+ if partner.supplier and not partner.customer:
+ account_type = 'payable'
+ elif partner.customer and not partner.supplier:
+ account_type = 'receivable'
+ if partner['property_account_' + account_type]:
+ account_id = partner['property_account_' + account_type].id
+
+ company_partner = wiz.statement_line_id.statement_id.company_id.partner_id
+ if len(setting_ids) and (
+ not account_id
+ or account_id in (
+ company_partner.property_account_payable.id,
+ company_partner.property_account_receivable.id)
+ ):
+ setting = settings_pool.browse(cr, uid, setting_ids[0], context=context)
+ if account_type == 'payable':
+ account_id = setting.default_credit_account_id.id
+ else:
+ account_id = setting.default_debit_account_id.id
+
+ if account_id:
+ wiz.statement_line_id.write({'account_id': account_id})
+
if wiz.statement_line_id:
#delete splits causing an unsplit if this is a split
#transaction
Follow ups