diff --git a/hr_expense_tier_validation/__init__.py b/hr_expense_tier_validation/__init__.py
index 4fb530fd1..69f7babdf 100644
--- a/hr_expense_tier_validation/__init__.py
+++ b/hr_expense_tier_validation/__init__.py
@@ -1,4 +1,3 @@
-# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
diff --git a/hr_expense_tier_validation/models/__init__.py b/hr_expense_tier_validation/models/__init__.py
index dfb758b42..9b4f81ef0 100644
--- a/hr_expense_tier_validation/models/__init__.py
+++ b/hr_expense_tier_validation/models/__init__.py
@@ -1,6 +1,4 @@
-# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import hr_expense_sheet
-from . import hr_expense
from . import tier_definition
diff --git a/hr_expense_tier_validation/models/hr_expense.py b/hr_expense_tier_validation/models/hr_expense.py
deleted file mode 100644
index 9be934197..000000000
--- a/hr_expense_tier_validation/models/hr_expense.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2022 Ecosoft Co., Ltd. (http://ecosoft.co.th)
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-
-from odoo import _, api, models
-from odoo.exceptions import ValidationError
-
-
-class HrExpense(models.Model):
- _inherit = "hr.expense"
-
- @api.model
- def _get_under_validation_exceptions(self):
- """Extend for more field exceptions."""
- return ["message_follower_ids", "access_token"]
-
- def _check_allow_write_under_validation(self, vals):
- """Allow to add exceptions for fields that are allowed to be written
- even when the record is under validation."""
- exceptions = self._get_under_validation_exceptions()
- if any(val not in exceptions for val in vals):
- return False
- return True
-
- def write(self, vals):
- for rec in self:
- if (
- rec.sheet_id.state == "submit"
- and rec.sheet_id.review_ids
- and not rec.sheet_id.validated
- and not rec.sheet_id.rejected
- and not rec._check_allow_write_under_validation(vals)
- ):
- raise ValidationError(_("The expense report is under validation."))
- return super().write(vals)
diff --git a/hr_expense_tier_validation/models/hr_expense_sheet.py b/hr_expense_tier_validation/models/hr_expense_sheet.py
index b1d0316c5..e801a5f6a 100644
--- a/hr_expense_tier_validation/models/hr_expense_sheet.py
+++ b/hr_expense_tier_validation/models/hr_expense_sheet.py
@@ -7,6 +7,8 @@
class HrExpenseSheet(models.Model):
_name = "hr.expense.sheet"
_inherit = ["hr.expense.sheet", "tier.validation"]
+
+ _state_field = "approval_state"
_state_from = ["submit"]
_state_to = ["approve", "post", "done"]
diff --git a/hr_expense_tier_validation/static/description/index.html b/hr_expense_tier_validation/static/description/index.html
index 1877a32f0..be823f09c 100644
--- a/hr_expense_tier_validation/static/description/index.html
+++ b/hr_expense_tier_validation/static/description/index.html
@@ -1,4 +1,3 @@
-
@@ -9,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
-:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
+:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
+Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }
-pre.code .ln { color: grey; } /* line numbers */
+pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@
span.pre {
white-space: pre }
-span.problematic {
+span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -446,7 +446,9 @@
This module is maintained by the OCA.
-
+
+
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
diff --git a/hr_expense_tier_validation/tests/__init__.py b/hr_expense_tier_validation/tests/__init__.py
index 85b34ee31..2b9257d3f 100644
--- a/hr_expense_tier_validation/tests/__init__.py
+++ b/hr_expense_tier_validation/tests/__init__.py
@@ -1,4 +1,3 @@
-# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_hr_expense_tier_validation
diff --git a/hr_expense_tier_validation/tests/test_hr_expense_tier_validation.py b/hr_expense_tier_validation/tests/test_hr_expense_tier_validation.py
index b947f86ff..831eaba53 100644
--- a/hr_expense_tier_validation/tests/test_hr_expense_tier_validation.py
+++ b/hr_expense_tier_validation/tests/test_hr_expense_tier_validation.py
@@ -56,23 +56,18 @@ def test_edit_value_expense(self):
self.product_1,
)
sheet_dict = expense.action_submit_expenses()
- sheet = self.env["hr.expense.sheet"].browse(sheet_dict["res_id"])
+ sheet = self.expense_sheet_model.browse(sheet_dict["res_id"])
self.assertEqual(sheet.state, "draft")
sheet.action_submit_sheet()
self.assertEqual(sheet.state, "submit")
# Must request validation before approve
+ with self.assertRaises(ValidationError):
+ sheet.action_approve_expense_sheets()
sheet.request_validation()
self.assertTrue(sheet)
sheet.invalidate_model()
# tier validation but state still submit
self.assertEqual(sheet.state, "submit")
- # not allow edit expense when under validation
- with self.assertRaises(ValidationError):
- with Form(sheet) as s:
- s.name = "New name"
- with self.assertRaises(ValidationError):
- with Form(expense) as exp:
- exp.name = "Change name"
# Test change message follower
message = expense.write({"message_follower_ids": self.partner.ids})
self.assertEqual(message, True)
diff --git a/hr_expense_tier_validation/views/hr_expense_sheet_view.xml b/hr_expense_tier_validation/views/hr_expense_sheet_view.xml
index 41393f223..a1a773d2e 100644
--- a/hr_expense_tier_validation/views/hr_expense_sheet_view.xml
+++ b/hr_expense_tier_validation/views/hr_expense_sheet_view.xml
@@ -1,3 +1,4 @@
+