mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Enable the payment methods by default on bank journals (including existing bank journals via post_install scripts)
Enable "Generate Accounting Entries On File Upload" by default
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
# © 2010-2013 Akretion (www.akretion.com)
|
||||
|
||||
from . import models
|
||||
from .post_install import update_bank_journals
|
||||
|
||||
@@ -23,5 +23,6 @@
|
||||
'demo': [
|
||||
'demo/sepa_credit_transfer_demo.xml'
|
||||
],
|
||||
'post_init_hook': 'update_bank_journals',
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
19
account_banking_sepa_credit_transfer/post_install.py
Normal file
19
account_banking_sepa_credit_transfer/post_install.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
|
||||
def update_bank_journals(cr, pool):
|
||||
ajo = pool['account.journal']
|
||||
journal_ids = ajo.search(
|
||||
cr, SUPERUSER_ID, [('type', '=', 'bank')])
|
||||
sct_id = pool['ir.model.data'].xmlid_to_res_id(
|
||||
cr, SUPERUSER_ID,
|
||||
'account_banking_sepa_credit_transfer.sepa_credit_transfer')
|
||||
if sct_id:
|
||||
ajo.write(cr, SUPERUSER_ID, journal_ids, {
|
||||
'outbound_payment_method_ids': [(4, sct_id)],
|
||||
})
|
||||
return
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
from .post_install import update_bank_journals
|
||||
|
||||
@@ -31,5 +31,6 @@
|
||||
'views/report_sepa_direct_debit_mandate.xml',
|
||||
],
|
||||
'demo': ['demo/sepa_direct_debit_demo.xml'],
|
||||
'post_init_hook': 'update_bank_journals',
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
18
account_banking_sepa_direct_debit/post_install.py
Normal file
18
account_banking_sepa_direct_debit/post_install.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
|
||||
def update_bank_journals(cr, pool):
|
||||
ajo = pool['account.journal']
|
||||
journal_ids = ajo.search(cr, SUPERUSER_ID, [('type', '=', 'bank')])
|
||||
sdd_id = pool['ir.model.data'].xmlid_to_res_id(
|
||||
cr, SUPERUSER_ID,
|
||||
'account_banking_sepa_direct_debit.sepa_direct_debit')
|
||||
if sdd_id:
|
||||
ajo.write(cr, SUPERUSER_ID, journal_ids, {
|
||||
'inbound_payment_method_ids': [(4, sdd_id)],
|
||||
})
|
||||
return
|
||||
@@ -2,4 +2,5 @@
|
||||
|
||||
from . import account_payment_method
|
||||
from . import account_payment_mode
|
||||
from . import account_journal
|
||||
from . import res_partner_bank
|
||||
|
||||
24
account_payment_mode/models/account_journal.py
Normal file
24
account_payment_mode/models/account_journal.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import models, fields
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = 'account.journal'
|
||||
|
||||
def _default_outbound_payment_methods(self):
|
||||
all_out = self.env['account.payment.method'].search([
|
||||
('payment_type', '=', 'outbound')])
|
||||
return all_out
|
||||
|
||||
def _default_inbound_payment_methods(self):
|
||||
all_in = self.env['account.payment.method'].search([
|
||||
('payment_type', '=', 'inbound')])
|
||||
return all_in
|
||||
|
||||
outbound_payment_method_ids = fields.Many2many(
|
||||
default=_default_outbound_payment_methods)
|
||||
inbound_payment_method_ids = fields.Many2many(
|
||||
default=_default_inbound_payment_methods)
|
||||
@@ -54,11 +54,11 @@ class AccountPaymentMode(models.Model):
|
||||
"(other modules can set additional fields to restrict the "
|
||||
"grouping.)")
|
||||
generate_move = fields.Boolean(
|
||||
'Generate Accounting Entries On File Upload')
|
||||
string='Generate Accounting Entries On File Upload', default=True)
|
||||
offsetting_account = fields.Selection([
|
||||
('bank_account', 'Bank Account'),
|
||||
('transfer_account', 'Transfer Account'),
|
||||
], string='Offsetting Account')
|
||||
], string='Offsetting Account', default='bank_account')
|
||||
transfer_account_id = fields.Many2one(
|
||||
'account.account', string='Transfer Account',
|
||||
domain=[('internal_type', '=', 'other'), ('reconcile', '=', True)],
|
||||
@@ -72,7 +72,7 @@ class AccountPaymentMode(models.Model):
|
||||
move_option = fields.Selection([
|
||||
('date', 'One move per payment date'),
|
||||
('line', 'One move per payment line'),
|
||||
], string='Move Option')
|
||||
], string='Move Option', default='date')
|
||||
|
||||
@api.multi
|
||||
@api.constrains(
|
||||
|
||||
Reference in New Issue
Block a user