From 33aa8bad0944a84dcb2bc134d559f37036f90a91 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Fri, 27 Jan 2023 11:55:05 +0100 Subject: [PATCH] Limit tax kind of invoice tax based on invoice type --- modules/account_invoice/invoice.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 1ba31f6a0a..301a74aeb5 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -2746,10 +2746,19 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView): tax = fields.Many2One('account.tax', 'Tax', ondelete='RESTRICT', domain=[ + ['OR', + ('group', '=', None), + ('group.kind', 'in', + If(Eval('_parent_invoice', {}).get('type') == 'out', + ['sale', 'both'], + ['purchase', 'both']), + )], ('company', '=', Eval('_parent_invoice', {}).get('company', 0)), ], states={ - 'readonly': ~Eval('manual', False) | _states['readonly'], + 'readonly': ( + ~Eval('manual', False) | ~Bool(Eval('invoice')) + | _states['readonly']), }, depends={'invoice'}) legal_notice = fields.Text("Legal Notice", states=_states)