mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Travis Fixes
This commit is contained in:
@@ -14,7 +14,7 @@ Configuration
|
||||
=============
|
||||
|
||||
To configure this module, you need to go to the menu
|
||||
*Invoicing > Configuration > Management > Payment Modes*.
|
||||
*Invoicing/Accounting > Configuration > Management > Payment Modes*.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
@@ -35,7 +35,7 @@ class AccountJournal(models.Model):
|
||||
('company_id', '!=', journal.company_id.id)], limit=1)
|
||||
if mode:
|
||||
raise ValidationError(_(
|
||||
"The company of the journal '%s', does not match "
|
||||
"The company of the journal '%s' does not match "
|
||||
"with the company of the payment mode '%s' where it is "
|
||||
"being used as Fixed Bank Journal.") % (
|
||||
journal.name, mode.name))
|
||||
@@ -44,7 +44,7 @@ class AccountJournal(models.Model):
|
||||
('company_id', '!=', journal.company_id.id)], limit=1)
|
||||
if mode:
|
||||
raise ValidationError(_(
|
||||
"The company of the journal '%s', does not match "
|
||||
"The company of the journal '%s' does not match "
|
||||
"with the company of the payment mode '%s' where it is "
|
||||
"being used in the Allowed Bank Journals.") % (
|
||||
journal.name, mode.name))
|
||||
|
||||
@@ -7,11 +7,10 @@ from odoo import models, fields, api
|
||||
|
||||
class AccountPaymentMethod(models.Model):
|
||||
_inherit = 'account.payment.method'
|
||||
_rec_name = 'display_name'
|
||||
|
||||
code = fields.Char(
|
||||
string='Code (Do Not Modify)',
|
||||
help="This code is used in the code of the Odoo module that handle "
|
||||
help="This code is used in the code of the Odoo module that handles "
|
||||
"this payment method. Therefore, if you change it, "
|
||||
"the generation of the payment file may fail.")
|
||||
active = fields.Boolean(string='Active', default=True)
|
||||
@@ -19,19 +18,20 @@ class AccountPaymentMethod(models.Model):
|
||||
string='Bank Account Required',
|
||||
help="Activate this option if this payment method requires you to "
|
||||
"know the bank account number of your customer or supplier.")
|
||||
display_name = fields.Char(
|
||||
compute='compute_display_name',
|
||||
store=True, string='Display Name')
|
||||
payment_mode_ids = fields.One2many(
|
||||
comodel_name='account.payment.mode', inverse_name='payment_method_id',
|
||||
string='Payment modes')
|
||||
|
||||
@api.multi
|
||||
@api.depends('code', 'name', 'payment_type')
|
||||
def compute_display_name(self):
|
||||
def name_get(self):
|
||||
result = []
|
||||
for method in self:
|
||||
method.display_name = u'[%s] %s (%s)' % (
|
||||
method.code, method.name, method.payment_type)
|
||||
result.append((
|
||||
method.id, u'[%s] %s (%s)' % (
|
||||
method.code, method.name, method.payment_type)
|
||||
))
|
||||
return result
|
||||
|
||||
_sql_constraints = [(
|
||||
'code_payment_type_unique',
|
||||
|
||||
@@ -28,7 +28,7 @@ class AccountPaymentMode(models.Model):
|
||||
"SEPA direct debit from suppliers), select "
|
||||
"'Fixed'. For payment modes that are not always attached to the same "
|
||||
"bank account (such as SEPA Direct debit for customers, wire transfer "
|
||||
"to suppliers), you should choose 'Variable', which means that you "
|
||||
"to suppliers), you should select 'Variable', which means that you "
|
||||
"will select the bank account on the payment order. If your company "
|
||||
"only has one bank account, you should always select 'Fixed'.")
|
||||
fixed_journal_id = fields.Many2one(
|
||||
@@ -120,4 +120,4 @@ class AccountPaymentMode(models.Model):
|
||||
mode.variable_journal_ids):
|
||||
raise ValidationError(_(
|
||||
"The company of the payment mode '%s', does not match "
|
||||
"with one of the Allowed Bank Journals.") % mode.name)
|
||||
"with the one of the Allowed Bank Journals.") % mode.name)
|
||||
|
||||
@@ -7,14 +7,13 @@ from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class TestAccountPaymentMode(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountPaymentMode, self).setUp()
|
||||
self.res_users_model = self.env['res.users']
|
||||
self.journal_model = self.env['account.journal']
|
||||
self.payment_mode_model = self.env['account.payment.mode']
|
||||
|
||||
#refs
|
||||
# refs
|
||||
self.manual_out = self.env.ref(
|
||||
'account.account_payment_method_manual_out')
|
||||
# Company
|
||||
@@ -54,13 +53,18 @@ class TestAccountPaymentMode(TransactionCase):
|
||||
# Assertion on the constraints to ensure the consistency
|
||||
# for company dependent fields
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.\
|
||||
self.payment_mode_c1. \
|
||||
write({'fixed_journal_id': self.journal_c2.id})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.\
|
||||
write({'variable_journal_ids': [
|
||||
(6, 0, [self.journal_c1.id, self.journal_c2.id,
|
||||
self.journal_c3.id])]})
|
||||
self.payment_mode_c1.write({
|
||||
'variable_journal_ids': [
|
||||
(6, 0, [
|
||||
self.journal_c1.id,
|
||||
self.journal_c2.id,
|
||||
self.journal_c3.id
|
||||
])
|
||||
]
|
||||
})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.journal_c1.write({'company_id': self.company_2.id})
|
||||
|
||||
@@ -84,3 +88,30 @@ class TestAccountPaymentMode(TransactionCase):
|
||||
'company_id': self.company.id,
|
||||
'variable_journal_ids': [(6, 0, [self.journal_c2.id])]
|
||||
})
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_model.create({
|
||||
'name': 'Direct Debit of suppliers from Bank 4',
|
||||
'bank_account_link': 'fixed',
|
||||
'payment_method_id': self.manual_out.id,
|
||||
'company_id': self.company.id,
|
||||
})
|
||||
self.journal_c1.outbound_payment_method_ids = False
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_model.create({
|
||||
'name': 'Direct Debit of suppliers from Bank 5',
|
||||
'bank_account_link': 'fixed',
|
||||
'payment_method_id': self.manual_out.id,
|
||||
'company_id': self.company.id,
|
||||
'fixed_journal_id': self.journal_c1.id
|
||||
})
|
||||
self.journal_c1.inbound_payment_method_ids = False
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_model.create({
|
||||
'name': 'Direct Debit of suppliers from Bank 5',
|
||||
'bank_account_link': 'fixed',
|
||||
'payment_method_id': self.env.ref(
|
||||
'account.account_payment_method_manual_in').id,
|
||||
'company_id': self.company.id,
|
||||
'fixed_journal_id': self.journal_c1.id
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<field name="bank_account_link"/>
|
||||
<field name="fixed_journal_id"
|
||||
attrs="{'invisible': [('bank_account_link', '!=', 'fixed')], 'required': [('bank_account_link', '=', 'fixed')]}"
|
||||
domain="[('company_id', '=', company_id)]"
|
||||
domain="[('company_id', '=', company_id), ('type', '=', 'bank')]"
|
||||
widget="selection"/>
|
||||
<field name="variable_journal_ids"
|
||||
attrs="{'invisible': [('bank_account_link', '!=', 'variable')], 'required': [('bank_account_link', '=', 'variable')]}"
|
||||
|
||||
1
setup/account_payment_mode/odoo/__init__.py
Normal file
1
setup/account_payment_mode/odoo/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
1
setup/account_payment_mode/odoo/addons/__init__.py
Normal file
1
setup/account_payment_mode/odoo/addons/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
1
setup/account_payment_mode/odoo/addons/account_payment_mode
Symbolic link
1
setup/account_payment_mode/odoo/addons/account_payment_mode
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../account_payment_mode/
|
||||
6
setup/account_payment_mode/setup.py
Normal file
6
setup/account_payment_mode/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user