From 9716d3cc416c304620cd38b5d5976aa4ac6fb1ef Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Thu, 28 Jun 2018 10:55:39 +0200 Subject: [PATCH] [FIX+REF] account_move_line_tax_editable: fixes not being able to define the tax when creating a new journal entry Before this fix, when a new journal entry was created, the taxes fields were readonly. They were only editable after saving the entry for the first time and editing it again. Additionally, there's some refactoring too. --- account_move_line_tax_editable/__manifest__.py | 2 +- account_move_line_tax_editable/models/account_move_line.py | 6 +++--- account_move_line_tax_editable/views/account_move.xml | 6 +----- account_move_line_tax_editable/views/account_move_line.xml | 6 +----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/account_move_line_tax_editable/__manifest__.py b/account_move_line_tax_editable/__manifest__.py index 217050c8a..1a7d17dd3 100644 --- a/account_move_line_tax_editable/__manifest__.py +++ b/account_move_line_tax_editable/__manifest__.py @@ -6,7 +6,7 @@ 'name': 'Account Move Line Tax Editable', 'summary': """ Allows to edit taxes on non-posted account move lines""", - 'version': '10.0.1.0.0', + 'version': '10.0.1.0.1', 'license': 'AGPL-3', 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', 'website': 'https://www.acsone.eu', 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 551ce637a..b83f6af07 100644 --- a/account_move_line_tax_editable/models/account_move_line.py +++ b/account_move_line_tax_editable/models/account_move_line.py @@ -6,14 +6,14 @@ from odoo import api, fields, models class AccountMoveLine(models.Model): - _inherit = 'account.move.line' is_tax_editable = fields.Boolean( string="Is tax data editable?", compute='_compute_is_tax_editable') + move_state = fields.Selection(related="move_id.state", readonly=True) @api.multi - @api.depends('move_id.state') + @api.depends('move_state') def _compute_is_tax_editable(self): for rec in self: rec.is_tax_editable = rec._get_is_tax_editable() @@ -21,4 +21,4 @@ class AccountMoveLine(models.Model): @api.multi def _get_is_tax_editable(self): self.ensure_one() - return self.move_id.state == 'draft' + return self.move_state in (False, 'draft') diff --git a/account_move_line_tax_editable/views/account_move.xml b/account_move_line_tax_editable/views/account_move.xml index a430cb2d0..9da66cc50 100644 --- a/account_move_line_tax_editable/views/account_move.xml +++ b/account_move_line_tax_editable/views/account_move.xml @@ -1,16 +1,14 @@ - - - account.move.form (in account_move_line_tax_editable) account.move + - - diff --git a/account_move_line_tax_editable/views/account_move_line.xml b/account_move_line_tax_editable/views/account_move_line.xml index 30e556488..e1815a1cc 100644 --- a/account_move_line_tax_editable/views/account_move_line.xml +++ b/account_move_line_tax_editable/views/account_move_line.xml @@ -1,16 +1,14 @@ - - - account.move.line.form (in account_move_line_tax_editable) account.move.line + @@ -23,6 +21,4 @@ - -