mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] account_banking: no results in wizard when no errors in process
[FIX] account_banking: currency from transaction was not taken into account [FIX] account_banking: last resulting bank statements tree was immutable [FIX] account_banking: right menu action in bank_statement triggered backtrace [IMP] account_banking: sorting now on id to maintain order of import
This commit is contained in:
@@ -111,6 +111,7 @@ class account_banking_imported_file(osv.osv):
|
||||
'''Imported Bank Statements File'''
|
||||
_name = 'account.banking.imported.file'
|
||||
_description = __doc__
|
||||
_rec_name = 'date'
|
||||
_columns = {
|
||||
'company_id': fields.many2one('res.company', 'Company',
|
||||
select=True, readonly=True
|
||||
@@ -147,8 +148,10 @@ class account_bank_statement(osv.osv):
|
||||
2. Extended 'button_confirm' trigger to cope with the period per
|
||||
statement_line situation.
|
||||
3. Added optional relation with imported statements file
|
||||
4. Ordering is based on auto generated id.
|
||||
'''
|
||||
_inherit = 'account.bank.statement'
|
||||
_order = 'id'
|
||||
|
||||
#def _currency(self, cursor, user, ids, name, args, context=None):
|
||||
# '''
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
id="menu_action_account_banking_bank_accounts"
|
||||
parent="account_banking.menu_finance_banking_settings"
|
||||
action="action_account_banking_res_partner_banks"
|
||||
sequence="12"
|
||||
sequence="10"
|
||||
/>
|
||||
|
||||
<!-- Create new view on default journals for bank accounts -->
|
||||
@@ -74,7 +74,7 @@
|
||||
id="menu_action_account_banking_bank_journals"
|
||||
parent="account_banking.menu_finance_banking_settings"
|
||||
action="action_account_banking_journals"
|
||||
sequence="12"
|
||||
sequence="20"
|
||||
/>
|
||||
|
||||
<!-- Create new view on imported statement files -->
|
||||
@@ -142,7 +142,7 @@
|
||||
|
||||
<!-- Create right menu entry to see statements -->
|
||||
<act_window name="Bank Statements File"
|
||||
domain="[('banking_id', '=', active_id)]"
|
||||
domain="[('id','=',banking_id)]"
|
||||
res_model="account.banking.imported.file"
|
||||
src_model="account.bank.statement"
|
||||
view_type="form"
|
||||
@@ -192,6 +192,36 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Add invisible column on bank statements tree for identification
|
||||
of import file
|
||||
-->
|
||||
<record id="view_banking_bank_statement_tree_2" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.tree.banking-2</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_tree" />
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="banking_id" invisible="True" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Add invisible field on bank statements form for identification
|
||||
of import file
|
||||
-->
|
||||
<record id="view_banking_bank_statement_form_4" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.form.banking-4</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form" />
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<field name="balance_end_real" position="after">
|
||||
<field name="banking_id" invisible="True"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Reset trigger on button_confirm to the trigger code in this module -->
|
||||
<record id="view_banking_bank_statement_form_4" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.form.banking-4</field>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,14 +56,14 @@ def get_period(pool, cursor, uid, date, company, log):
|
||||
])
|
||||
if not fiscalyear_ids:
|
||||
log.append(
|
||||
_('No suitable fiscal year found for company %(company_name)s')
|
||||
% dict(company_name=company.name)
|
||||
_('No suitable fiscal year found for date %(date)s and company %(company_name)s')
|
||||
% dict(company_name=company.name, date=date)
|
||||
)
|
||||
return False
|
||||
elif len(fiscalyear_ids) > 1:
|
||||
log.append(
|
||||
_('Multiple overlapping fiscal years found for date %(date)s')
|
||||
% dict(date=date)
|
||||
_('Multiple overlapping fiscal years found for date %(date)s and company %(company_name)s')
|
||||
% dict(company_name=company.name, date=date)
|
||||
)
|
||||
return False
|
||||
|
||||
@@ -73,13 +73,13 @@ def get_period(pool, cursor, uid, date, company, log):
|
||||
('fiscalyear_id','=',fiscalyear_id), ('state','=','draft')
|
||||
])
|
||||
if not period_ids:
|
||||
log.append(_('No suitable period found for date %(date)s')
|
||||
% dict(date=date)
|
||||
log.append(_('No suitable period found for date %(date)s and company %(company_name)s')
|
||||
% dict(company_name=company.name, date=date)
|
||||
)
|
||||
return False
|
||||
if len(period_ids) != 1:
|
||||
log.append(_('Multiple overlapping periods for date %(date)s')
|
||||
% dict(date=date)
|
||||
log.append(_('Multiple overlapping periods for date %(date)s and company %(company_name)s')
|
||||
% dict(company_name=company.name, date=date)
|
||||
)
|
||||
return False
|
||||
return period_ids[0]
|
||||
@@ -135,10 +135,11 @@ def get_or_create_partner(pool, cursor, uid, name, log):
|
||||
partner_id = partner_ids[0]
|
||||
return partner_obj.browse(cursor, uid, partner_id)[0]
|
||||
|
||||
def get_company_bank_account(pool, cursor, uid, account_number,
|
||||
def get_company_bank_account(pool, cursor, uid, account_number, currency,
|
||||
company, log):
|
||||
'''
|
||||
Get the matching bank account for this company.
|
||||
Get the matching bank account for this company. Currency is the ISO code
|
||||
for the requested currency.
|
||||
'''
|
||||
results = struct()
|
||||
bank_account = get_bank_account(pool, cursor, uid, account_number, log,
|
||||
@@ -154,12 +155,31 @@ def get_company_bank_account(pool, cursor, uid, account_number,
|
||||
return False
|
||||
results.account = bank_account
|
||||
bank_settings_obj = pool.get('account.banking.account.settings')
|
||||
bank_settings_ids = bank_settings_obj.search(cursor, uid, [
|
||||
('partner_bank_id', '=', bank_account.id)
|
||||
criteria = [('partner_bank_id', '=', bank_account.id)]
|
||||
|
||||
# Find matching journal for currency
|
||||
journal_obj = pool.get('account.journal')
|
||||
journal_ids = journal_obj.search(cursor, uid, [
|
||||
('type', '=', 'cash'),
|
||||
('currency', '=', currency or company.currency_id.code)
|
||||
])
|
||||
if not journal_ids and currency == company.currency_id.code:
|
||||
journal_ids = journal_obj.search(cursor, uid, [
|
||||
('type', '=', 'cash'), ('currency', '=', False)
|
||||
])
|
||||
if journal_ids:
|
||||
criteria.append(('journal_id', 'in', journal_ids))
|
||||
|
||||
# Find bank account settings
|
||||
bank_settings_ids = bank_settings_obj.search(cursor, uid, criteria)
|
||||
if bank_settings_ids:
|
||||
settings = bank_settings_obj.browse(cursor, uid, bank_settings_ids)[0]
|
||||
results.journal_id = settings.journal_id
|
||||
# Take currency from settings or from company
|
||||
if settings.journal_id.currency.id:
|
||||
results.currency_id = settings.journal_id.currency
|
||||
else:
|
||||
results.currency_id = company.currency_id
|
||||
results.default_debit_account_id = settings.default_debit_account_id
|
||||
results.default_credit_account_id = settings.default_credit_account_id
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user