mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[IMP] Taxes data should not be editable if linked move is not in draft
This commit is contained in:
committed by
mreficent
parent
cd45b9383b
commit
1b152af798
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
'name': 'Account Move Line Tax Editable',
|
||||
'summary': """
|
||||
Allows to edit taxes on account move lines""",
|
||||
Allows to edit taxes on non-posted account move lines""",
|
||||
'version': '10.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
|
||||
|
||||
1
account_move_line_tax_editable/models/__init__.py
Normal file
1
account_move_line_tax_editable/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import account_move_line
|
||||
24
account_move_line_tax_editable/models/account_move_line.py
Normal file
24
account_move_line_tax_editable/models/account_move_line.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
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')
|
||||
|
||||
@api.multi
|
||||
@api.depends('move_id.state')
|
||||
def _compute_is_tax_editable(self):
|
||||
for rec in self:
|
||||
rec.is_tax_editable = rec._get_is_tax_editable()
|
||||
|
||||
@api.multi
|
||||
def _get_is_tax_editable(self):
|
||||
self.ensure_one()
|
||||
return self.move_id.state == 'draft'
|
||||
@@ -11,8 +11,10 @@
|
||||
<field name="inherit_id" ref="account.view_move_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='line_ids']/tree/field[@name='name']" position="after">
|
||||
<field name="tax_line_id"/>
|
||||
<field name="tax_ids" widget="many2many_tags"/>
|
||||
<field name="is_tax_editable" invisible="1"/>
|
||||
<field name="tax_line_id" attrs="{'readonly': [('is_tax_editable', '=', False)]}"/>
|
||||
<field name="tax_ids" attrs="{'readonly': [('is_tax_editable', '=', False)]}"
|
||||
widget="many2many_tags"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -10,11 +10,16 @@
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="inherit_id" ref="account.view_move_line_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="tax_line_id" position="before">
|
||||
<field name="is_tax_editable" invisible="1"/>
|
||||
</field>
|
||||
<field name="tax_line_id" position="attributes">
|
||||
<attribute name="readonly">0</attribute>
|
||||
<attribute name="attrs">{'readonly': [('is_tax_editable', '=', False)]}</attribute>
|
||||
</field>
|
||||
<field name="tax_ids" position="attributes">
|
||||
<attribute name="readonly">0</attribute>
|
||||
<attribute name="attrs">{'readonly': [('is_tax_editable', '=', False)]}</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user