Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] hr_employee_cost_history: add comment field in history line #735

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ class HrEmployeeTimesheetCostHistory(models.Model):
help="The cost change has effect since this date.",
default=fields.Date.context_today,
)
comment = fields.Char()
25 changes: 25 additions & 0 deletions hr_employee_cost_history/tests/test_hr_timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,28 @@ def test_update_employee_history_cost(self):
)
last_timesheet = timesheet_cost_ids[-1]
self.assertEqual(last_timesheet.hourly_cost, 20.0)

@users("test_user_manager")
def test_field_comment(self):
"""Test comment field."""
wizard = Form(
self.env["hr.employee.timesheet.cost.wizard"].with_context(
default_employee_id=self.employee.id,
default_hourly_cost=123,
default_starting_date=date.today(),
default_comment="Test comment",
)
)
wizard_result = wizard.save()
wizard_result.update_employee_cost()
comment = (
self.env["hr.employee.timesheet.cost.history"]
.search(
[
("employee_id", "=", self.employee.id),
("hourly_cost", "=", 123),
]
)
.comment
)
self.assertEqual(comment, "Test comment")
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<tree>
<field name="hourly_cost" />
<field name="starting_date" />
<field name="comment" />
<field name="create_uid" optional="hide" />
<field name="create_date" optional="hide" />
</tree>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class HrEmployeeTimesheetCost(models.TransientModel):
default=fields.Datetime.now,
string="From Date",
)
comment = fields.Char()

@api.model
def default_get(self, fields):
Expand Down Expand Up @@ -54,6 +55,7 @@ def update_employee_cost(self):
"currency_id": self.currency_id.id,
"hourly_cost": self.hourly_cost,
"starting_date": self.starting_date,
"comment": self.comment,
}
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<field name="starting_date" />
</group>
</group>
<group>
<field name="comment" />
</group>
</sheet>
<footer>
<button
Expand Down
Loading