Skip to content

Commit

Permalink
[FIX] refactor tier expense
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Jul 23, 2024
1 parent 1ac2822 commit 8cd54fe
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 52 deletions.
1 change: 0 additions & 1 deletion hr_expense_tier_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions hr_expense_tier_validation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
34 changes: 0 additions & 34 deletions hr_expense_tier_validation/models/hr_expense.py

This file was deleted.

2 changes: 2 additions & 0 deletions hr_expense_tier_validation/models/hr_expense_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
12 changes: 7 additions & 5 deletions hr_expense_tier_validation/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
: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.
Expand Down Expand Up @@ -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 }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -446,7 +446,9 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
1 change: 0 additions & 1 deletion hr_expense_tier_validation/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion hr_expense_tier_validation/views/hr_expense_sheet_view.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="hr_expense_sheet_view_search" model="ir.ui.view">
<field
Expand All @@ -11,7 +12,7 @@
<filter
name="needs_review"
string="Needs my Review"
domain="[('reviewer_ids','in',uid), ('state', 'not in', ['approve', 'post', 'done', 'cancel'])]"
domain="[('reviewer_ids', 'in', uid), ('state', 'not in', ['approve', 'post', 'done', 'cancel'])]"
help="My Expense report to review"
/>
<filter
Expand Down

0 comments on commit 8cd54fe

Please sign in to comment.