From 2a06faabdb8964ddb23378675e5f22dc89358180 Mon Sep 17 00:00:00 2001 From: mreficent Date: Thu, 30 Jan 2020 18:23:55 +0100 Subject: [PATCH] [IMP] account_move_line_tax_editable: black, isort --- .../__manifest__.py | 21 ++--- .../models/account_move_line.py | 9 +- .../test_account_move_line_tax_editable.py | 92 ++++++++++--------- 3 files changed, 64 insertions(+), 58 deletions(-) diff --git a/account_move_line_tax_editable/__manifest__.py b/account_move_line_tax_editable/__manifest__.py index 5816763f..c5a925e7 100644 --- a/account_move_line_tax_editable/__manifest__.py +++ b/account_move_line_tax_editable/__manifest__.py @@ -2,18 +2,13 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Account Move Line Tax Editable', - 'summary': """ + "name": "Account Move Line Tax Editable", + "summary": """ Allows to edit taxes on non-posted account move lines""", - 'version': '12.0.1.0.0', - 'license': 'AGPL-3', - 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/account-financial-tools', - 'depends': [ - 'account', - ], - 'data': [ - 'views/account_move.xml', - 'views/account_move_line.xml', - ], + "version": "12.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-tools", + "depends": ["account"], + "data": ["views/account_move.xml", "views/account_move_line.xml"], } diff --git a/account_move_line_tax_editable/models/account_move_line.py b/account_move_line_tax_editable/models/account_move_line.py index fe3d1fc7..f026f570 100644 --- a/account_move_line_tax_editable/models/account_move_line.py +++ b/account_move_line_tax_editable/models/account_move_line.py @@ -6,13 +6,14 @@ from odoo import api, fields, models class AccountMoveLine(models.Model): - _inherit = 'account.move.line' + _inherit = "account.move.line" is_tax_editable = fields.Boolean( - string="Is tax data editable?", compute='_compute_is_tax_editable') + string="Is tax data editable?", compute="_compute_is_tax_editable" + ) @api.multi - @api.depends('move_id.state') + @api.depends("move_id.state") def _compute_is_tax_editable(self): for rec in self: - rec.is_tax_editable = (rec.move_id.state == 'draft') + rec.is_tax_editable = rec.move_id.state == "draft" diff --git a/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py b/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py index fc58339f..5be4161b 100644 --- a/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py +++ b/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py @@ -1,57 +1,67 @@ # Copyright 2019 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields import odoo.tests.common as common +from odoo import fields class TestAccountMoveLineTaxEditable(common.SavepointCase): - @classmethod def setUpClass(cls): super(TestAccountMoveLineTaxEditable, cls).setUpClass() - acc_obj = cls.env['account.account'] - account100 = acc_obj.create({ - 'code': '100', - 'name': 'Account 100', - 'user_type_id': cls.env.ref( - 'account.data_account_type_receivable').id, - 'reconcile': True - }) - account300 = acc_obj.create({ - 'code': '300', - 'name': 'Account 300', - 'user_type_id': cls.env.ref( - 'account.data_account_type_other_income').id - }) + acc_obj = cls.env["account.account"] + account100 = acc_obj.create( + { + "code": "100", + "name": "Account 100", + "user_type_id": cls.env.ref("account.data_account_type_receivable").id, + "reconcile": True, + } + ) + account300 = acc_obj.create( + { + "code": "300", + "name": "Account 300", + "user_type_id": cls.env.ref( + "account.data_account_type_other_income" + ).id, + } + ) - journal = cls.env['account.journal'].create({ - 'name': 'Test journal', - 'type': 'sale', - 'code': 'TEST', - }) + journal = cls.env["account.journal"].create( + {"name": "Test journal", "type": "sale", "code": "TEST"} + ) move_vals = { - 'journal_id': journal.id, - 'name': 'move test', - 'date': fields.Date.today(), - 'line_ids': [ - (0, 0, { - 'name': 'move test', - 'debit': 0.0, - 'credit': 1000.0, - 'account_id': account300.id}), - (0, 0, { - 'name': 'move test', - 'debit': 1000.0, - 'credit': 0.0, - 'account_id': account100.id}) - ]} - cls.move = cls.env['account.move'].create(move_vals) + "journal_id": journal.id, + "name": "move test", + "date": fields.Date.today(), + "line_ids": [ + ( + 0, + 0, + { + "name": "move test", + "debit": 0.0, + "credit": 1000.0, + "account_id": account300.id, + }, + ), + ( + 0, + 0, + { + "name": "move test", + "debit": 1000.0, + "credit": 0.0, + "account_id": account100.id, + }, + ), + ], + } + cls.move = cls.env["account.move"].create(move_vals) def test_compute_is_tax_editable(self): - self.assertEqual(self.move.line_ids.mapped('is_tax_editable'), - [True, True]) + self.assertEqual(self.move.line_ids.mapped("is_tax_editable"), [True, True]) self.move.post() - self.assertEqual(self.move.line_ids.mapped('is_tax_editable'), - [False, False]) + self.assertEqual(self.move.line_ids.mapped("is_tax_editable"), [False, False])