[IMP] account_move_line_tax_editable: black, isort
This commit is contained in:
parent
87984b0dbb
commit
2a06faabdb
|
@ -2,18 +2,13 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Account Move Line Tax Editable',
|
"name": "Account Move Line Tax Editable",
|
||||||
'summary': """
|
"summary": """
|
||||||
Allows to edit taxes on non-posted account move lines""",
|
Allows to edit taxes on non-posted account move lines""",
|
||||||
'version': '12.0.1.0.0',
|
"version": "12.0.1.0.0",
|
||||||
'license': 'AGPL-3',
|
"license": "AGPL-3",
|
||||||
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
|
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
|
||||||
'website': 'https://github.com/OCA/account-financial-tools',
|
"website": "https://github.com/OCA/account-financial-tools",
|
||||||
'depends': [
|
"depends": ["account"],
|
||||||
'account',
|
"data": ["views/account_move.xml", "views/account_move_line.xml"],
|
||||||
],
|
|
||||||
'data': [
|
|
||||||
'views/account_move.xml',
|
|
||||||
'views/account_move_line.xml',
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,14 @@ from odoo import api, fields, models
|
||||||
|
|
||||||
class AccountMoveLine(models.Model):
|
class AccountMoveLine(models.Model):
|
||||||
|
|
||||||
_inherit = 'account.move.line'
|
_inherit = "account.move.line"
|
||||||
|
|
||||||
is_tax_editable = fields.Boolean(
|
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.multi
|
||||||
@api.depends('move_id.state')
|
@api.depends("move_id.state")
|
||||||
def _compute_is_tax_editable(self):
|
def _compute_is_tax_editable(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.is_tax_editable = (rec.move_id.state == 'draft')
|
rec.is_tax_editable = rec.move_id.state == "draft"
|
||||||
|
|
|
@ -1,57 +1,67 @@
|
||||||
# Copyright 2019 Tecnativa - Ernesto Tejeda
|
# Copyright 2019 Tecnativa - Ernesto Tejeda
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import fields
|
|
||||||
import odoo.tests.common as common
|
import odoo.tests.common as common
|
||||||
|
from odoo import fields
|
||||||
|
|
||||||
|
|
||||||
class TestAccountMoveLineTaxEditable(common.SavepointCase):
|
class TestAccountMoveLineTaxEditable(common.SavepointCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestAccountMoveLineTaxEditable, cls).setUpClass()
|
super(TestAccountMoveLineTaxEditable, cls).setUpClass()
|
||||||
|
|
||||||
acc_obj = cls.env['account.account']
|
acc_obj = cls.env["account.account"]
|
||||||
account100 = acc_obj.create({
|
account100 = acc_obj.create(
|
||||||
'code': '100',
|
{
|
||||||
'name': 'Account 100',
|
"code": "100",
|
||||||
'user_type_id': cls.env.ref(
|
"name": "Account 100",
|
||||||
'account.data_account_type_receivable').id,
|
"user_type_id": cls.env.ref("account.data_account_type_receivable").id,
|
||||||
'reconcile': True
|
"reconcile": True,
|
||||||
})
|
}
|
||||||
account300 = acc_obj.create({
|
)
|
||||||
'code': '300',
|
account300 = acc_obj.create(
|
||||||
'name': 'Account 300',
|
{
|
||||||
'user_type_id': cls.env.ref(
|
"code": "300",
|
||||||
'account.data_account_type_other_income').id
|
"name": "Account 300",
|
||||||
})
|
"user_type_id": cls.env.ref(
|
||||||
|
"account.data_account_type_other_income"
|
||||||
|
).id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
journal = cls.env['account.journal'].create({
|
journal = cls.env["account.journal"].create(
|
||||||
'name': 'Test journal',
|
{"name": "Test journal", "type": "sale", "code": "TEST"}
|
||||||
'type': 'sale',
|
)
|
||||||
'code': 'TEST',
|
|
||||||
})
|
|
||||||
move_vals = {
|
move_vals = {
|
||||||
'journal_id': journal.id,
|
"journal_id": journal.id,
|
||||||
'name': 'move test',
|
"name": "move test",
|
||||||
'date': fields.Date.today(),
|
"date": fields.Date.today(),
|
||||||
'line_ids': [
|
"line_ids": [
|
||||||
(0, 0, {
|
(
|
||||||
'name': 'move test',
|
0,
|
||||||
'debit': 0.0,
|
0,
|
||||||
'credit': 1000.0,
|
{
|
||||||
'account_id': account300.id}),
|
"name": "move test",
|
||||||
(0, 0, {
|
"debit": 0.0,
|
||||||
'name': 'move test',
|
"credit": 1000.0,
|
||||||
'debit': 1000.0,
|
"account_id": account300.id,
|
||||||
'credit': 0.0,
|
},
|
||||||
'account_id': account100.id})
|
),
|
||||||
]}
|
(
|
||||||
cls.move = cls.env['account.move'].create(move_vals)
|
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):
|
def test_compute_is_tax_editable(self):
|
||||||
self.assertEqual(self.move.line_ids.mapped('is_tax_editable'),
|
self.assertEqual(self.move.line_ids.mapped("is_tax_editable"), [True, True])
|
||||||
[True, True])
|
|
||||||
self.move.post()
|
self.move.post()
|
||||||
self.assertEqual(self.move.line_ids.mapped('is_tax_editable'),
|
self.assertEqual(self.move.line_ids.mapped("is_tax_editable"), [False, False])
|
||||||
[False, False])
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user