From 5228214882dac8857f29cc147e698620604a1b75 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 11 Oct 2017 16:26:54 +0200 Subject: [PATCH] Travis Fixes --- account_payment_mode/README.rst | 2 +- .../models/account_journal.py | 4 +- .../models/account_payment_method.py | 16 +++---- .../models/account_payment_mode.py | 4 +- .../tests/test_account_payment_mode.py | 45 ++++++++++++++++--- .../views/account_payment_mode.xml | 2 +- setup/account_payment_mode/odoo/__init__.py | 1 + .../odoo/addons/__init__.py | 1 + .../odoo/addons/account_payment_mode | 1 + setup/account_payment_mode/setup.py | 6 +++ 10 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 setup/account_payment_mode/odoo/__init__.py create mode 100644 setup/account_payment_mode/odoo/addons/__init__.py create mode 120000 setup/account_payment_mode/odoo/addons/account_payment_mode create mode 100644 setup/account_payment_mode/setup.py diff --git a/account_payment_mode/README.rst b/account_payment_mode/README.rst index b98639c95..3dbfd9339 100644 --- a/account_payment_mode/README.rst +++ b/account_payment_mode/README.rst @@ -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 ===== diff --git a/account_payment_mode/models/account_journal.py b/account_payment_mode/models/account_journal.py index c611ab14a..9af2173c6 100644 --- a/account_payment_mode/models/account_journal.py +++ b/account_payment_mode/models/account_journal.py @@ -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)) diff --git a/account_payment_mode/models/account_payment_method.py b/account_payment_mode/models/account_payment_method.py index 5e1cdecb7..554d1e0e5 100644 --- a/account_payment_mode/models/account_payment_method.py +++ b/account_payment_mode/models/account_payment_method.py @@ -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', diff --git a/account_payment_mode/models/account_payment_mode.py b/account_payment_mode/models/account_payment_mode.py index ecffd2b65..2a6cdf154 100644 --- a/account_payment_mode/models/account_payment_mode.py +++ b/account_payment_mode/models/account_payment_mode.py @@ -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) diff --git a/account_payment_mode/tests/test_account_payment_mode.py b/account_payment_mode/tests/test_account_payment_mode.py index dbbd7318c..24ef5823d 100644 --- a/account_payment_mode/tests/test_account_payment_mode.py +++ b/account_payment_mode/tests/test_account_payment_mode.py @@ -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 + }) diff --git a/account_payment_mode/views/account_payment_mode.xml b/account_payment_mode/views/account_payment_mode.xml index f9a576894..79c707da1 100644 --- a/account_payment_mode/views/account_payment_mode.xml +++ b/account_payment_mode/views/account_payment_mode.xml @@ -15,7 +15,7 @@