From 1f27c7a37442494cd35130a8c7c99529f5ced0ea Mon Sep 17 00:00:00 2001 From: Kitti U Date: Fri, 5 Nov 2021 14:18:20 +0700 Subject: [PATCH] FIX, track PIT in case not 150,000, on Exp --- l10n_th_account_tax/models/account_move.py | 10 ++++-- .../views/account_move_view.xml | 2 +- .../views/account_payment_view.xml | 2 +- .../models/account_move.py | 32 +++++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/l10n_th_account_tax/models/account_move.py b/l10n_th_account_tax/models/account_move.py index 5f04a5376..db1da899b 100644 --- a/l10n_th_account_tax/models/account_move.py +++ b/l10n_th_account_tax/models/account_move.py @@ -377,8 +377,14 @@ class AccountMove(models.Model): ) def _compute_has_wht(self): + """Has WHT when + 1. Has wht_tax_id + 2. Is not invoice (move_type == 'entry') + """ for rec in self: - rec.has_wht = len(rec.line_ids.mapped("wht_tax_id")) > 0 + wht_tax = True if rec.line_ids.mapped("wht_tax_id") else False + not_inv = rec.move_type == "entry" + rec.has_wht = wht_tax and not_inv @api.depends("wht_cert_ids.state") def _compute_wht_cert_status(self): @@ -486,7 +492,7 @@ def _post(self, soft=True): for wht_move in wht_moves ] move.write({"wht_move_ids": [(5, 0, 0)] + withholding_moves}) - # On payment JE, keep track of move when PIT not withheld, use date from vendor bill + # On payment JE, keep track of move when PIT not withheld, use data from vendor bill if move.payment_id and not move.payment_id.wht_move_ids.mapped("is_pit"): if self.env.context.get("active_model") == "account.move": bills = self.env["account.move"].browse( diff --git a/l10n_th_account_tax/views/account_move_view.xml b/l10n_th_account_tax/views/account_move_view.xml index 60942ec80..ddd031947 100644 --- a/l10n_th_account_tax/views/account_move_view.xml +++ b/l10n_th_account_tax/views/account_move_view.xml @@ -23,7 +23,7 @@ class="alert alert-warning" role="alert" style="margin-bottom:0px;" - attrs="{'invisible': ['|', '|', ('move_type', '!=', 'entry'), ('wht_cert_status', '!=', 'none'), ('state', '!=', 'posted')]}" + attrs="{'invisible': ['|', ('wht_cert_status', '!=', 'none'), ('state', '!=', 'posted')]}" > This entry containg withholding tax, but no withholding tax certs. created yet.