2
0

[IMP] account_move_line_tax_editable: black, isort

This commit is contained in:
mreficent 2020-01-30 18:23:55 +01:00 committed by Luis J. Salvatierra
parent 87984b0dbb
commit 2a06faabdb
3 changed files with 64 additions and 58 deletions

View File

@ -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"],
}

View File

@ -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"

View File

@ -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])