Skip to content

Commit

Permalink
[17.0][MIG] hr_timesheet_sheet : Migration to V17
Browse files Browse the repository at this point in the history
  • Loading branch information
SodexisTeam authored and atchuthan committed Feb 2, 2024
1 parent f2ace0f commit e31ae06
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion hr_timesheet_sheet/models/account_analytic_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AccountAnalyticAccount(models.Model):
def _check_timesheet_sheet_company_id(self):
for rec in self.sudo():
sheets = rec.line_ids.mapped("sheet_id").filtered(
lambda s: s.company_id and s.company_id != rec.company_id
lambda s, rec=rec: s.company_id and rec.company_id != s.company_id
)
if sheets:
raise ValidationError(
Expand Down
4 changes: 2 additions & 2 deletions hr_timesheet_sheet/models/hr_department.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class HrDepartment(models.Model):
)

def _compute_timesheet_to_approve(self):
timesheet_data = self.env["hr_timesheet.sheet"]._read_group(
timesheet_data = self.env["hr_timesheet.sheet"].read_group(
[("department_id", "in", self.ids), ("state", "=", "confirm")],
["department_id"],
["__count"],
["department_id"],
)
result = {
data["department_id"][0]: data["department_id_count"]
Expand Down
6 changes: 3 additions & 3 deletions hr_timesheet_sheet/models/hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def _is_line_of_row(self, aal, row):
def delete_empty_lines(self, delete_empty_rows=False):
self.ensure_one()
for name in list(set(self.line_ids.mapped("value_y"))):
rows = self.line_ids.filtered(lambda l: l.value_y == name)
rows = self.line_ids.filtered(lambda x, name=name: x.value_y == name)
if not rows:
continue
row = fields.first(rows)
Expand All @@ -711,7 +711,7 @@ def delete_empty_lines(self, delete_empty_rows=False):
if not check:
continue
row_lines = self.timesheet_ids.filtered(
lambda aal: self._is_line_of_row(aal, row)
lambda aal, row=row: self._is_line_of_row(aal, row)
)
row_lines.filtered(
lambda t: t.name == empty_name
Expand Down Expand Up @@ -765,7 +765,7 @@ def add_new_line(self, line):
self.ensure_one()
new_line_model = self.env["hr_timesheet.sheet.new.analytic.line"]
new_line = self.new_line_ids.filtered(
lambda l: self._is_compatible_new_line(l, line)
lambda x: self._is_compatible_new_line(x, line)
)
if new_line:
new_line.write({"unit_amount": line.unit_amount})
Expand Down
14 changes: 7 additions & 7 deletions hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def test_2(self):
line_form.unit_amount = 1.0
self.assertEqual(len(sheet.new_line_ids), 1)
line2 = fields.first(
sheet.line_ids.filtered(lambda l: l.date != timesheet.date)
sheet.line_ids.filtered(lambda x: x.date != timesheet.date)
)
self.assertEqual(line2.unit_amount, 1.0)
self.assertEqual(len(sheet.timesheet_ids), 2)
Expand Down Expand Up @@ -473,7 +473,7 @@ def test_4(self):
self.assertEqual(timesheet_1_or_2.unit_amount, 1.0)
self.assertEqual(timesheet_3.unit_amount, 0.0)

line = sheet.line_ids.filtered(lambda l: l.unit_amount != 0.0)
line = sheet.line_ids.filtered(lambda x: x.unit_amount != 0.0)
self.assertEqual(len(line), 1)
self.assertEqual(line.unit_amount, 1.0)

Expand Down Expand Up @@ -526,7 +526,7 @@ def test_5(self):
pass # trigger edit and save
self.assertEqual(len(sheet.line_ids), 7)
self.assertEqual(len(sheet.timesheet_ids), 2)
line = sheet.line_ids.filtered(lambda l: l.unit_amount != 0.0)
line = sheet.line_ids.filtered(lambda x: x.unit_amount != 0.0)
self.assertEqual(line.unit_amount, 4.0)

timesheet_2.name = empty_name
Expand Down Expand Up @@ -622,7 +622,7 @@ def test_6(self):
pass # trigger edit and save
self.assertEqual(len(sheet.line_ids), 7)
self.assertEqual(len(sheet.timesheet_ids), 5)
line = sheet.line_ids.filtered(lambda l: l.unit_amount != 0.0)
line = sheet.line_ids.filtered(lambda x: x.unit_amount != 0.0)
self.assertEqual(line.unit_amount, 10.0)

timesheet_2.name = empty_name
Expand Down Expand Up @@ -652,7 +652,7 @@ def test_6(self):
line_form.unit_amount = 3.0
self.assertEqual(len(sheet.new_line_ids), 1)
self.assertEqual(len(sheet.timesheet_ids), 4)
line = sheet.line_ids.filtered(lambda l: l.unit_amount != 0.0)
line = sheet.line_ids.filtered(lambda x: x.unit_amount != 0.0)
self.assertEqual(line.unit_amount, 3.0)

timesheet_3_4_and_5 = self.aal_model.search(
Expand All @@ -676,7 +676,7 @@ def test_6(self):
with Form(sheet.with_user(self.user)):
pass # trigger edit and save
self.assertEqual(len(sheet.timesheet_ids), 4)
line = sheet.line_ids.filtered(lambda l: l.unit_amount != 0.0)
line = sheet.line_ids.filtered(lambda x: x.unit_amount != 0.0)
self.assertEqual(len(line), 1)
self.assertEqual(line.unit_amount, 5.0)

Expand Down Expand Up @@ -866,7 +866,7 @@ def test_12_creating_sheet(self):
self.assertEqual(len(sheet.timesheet_ids), 1)
self.assertEqual(len(sheet.line_ids), 7)

line = sheet.line_ids.filtered(lambda l: l.unit_amount)
line = sheet.line_ids.filtered(lambda x: x.unit_amount)
self.assertEqual(len(line), 1)
self.assertEqual(line.unit_amount, 2.0)

Expand Down
5 changes: 1 addition & 4 deletions hr_timesheet_sheet/views/account_analytic_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form" />
<field name="arch" type="xml">
<field name="date" position="after">
<field
name="sheet_id"
invisible="[('sheet_id', '=', False)]"
/>
<field name="sheet_id" invisible="not sheet_id" />
</field>
</field>
</record>
Expand Down
16 changes: 8 additions & 8 deletions hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@
string="Submit to Reviewer"
type="object"
class="oe_highlight"
invisible="[('state', '!=', 'draft')]"
invisible="state != 'draft'"
/>
<button
name="action_timesheet_done"
string="Approve"
type="object"
class="oe_highlight"
invisible="['|', ('can_review', '!=', True), ('state', '!=', 'confirm')]"
invisible="not can_review or state != 'confirm'"
/>
<button
name="action_timesheet_draft"
string="Set to Draft"
type="object"
invisible="['|', ('can_review', '!=', True), ('state', '!=', 'done')]"
invisible="not can_review or state != 'done'"
/>
<button
name="action_timesheet_refuse"
string="Refuse"
type="object"
invisible="['|', ('can_review', '!=', True), ('state', '!=', 'confirm')]"
invisible="not can_review or state != 'confirm'"
/>
<field
name="state"
Expand Down Expand Up @@ -112,7 +112,7 @@
<field
name="line_ids"
nolabel="1"
readonly="[('state', 'not in', ['new', 'draft'])]"
readonly="state not in ('new', 'draft')"
widget="x2many_2d_matrix"
field_x_axis="value_x"
field_y_axis="value_y"
Expand Down Expand Up @@ -142,13 +142,13 @@
</field>
<group
class="oe_edit_only"
invisible="[('state', 'not in', ['new', 'draft'])]"
invisible="state not in ('new', 'draft')"
>
<field name="add_line_project_id" />
<field name="available_task_ids" invisible="1" />
<field
name="add_line_task_id"
invisible="[('add_line_project_id', '=', False)]"
invisible="not add_line_project_id"
context="{'default_project_id': add_line_project_id}"
/>
<button
Expand All @@ -157,7 +157,7 @@
colspan="2"
string="Add new line"
class="oe_highlight"
invisible="[('add_line_project_id', '=', False)]"
invisible="not add_line_project_id"
/>
</group>
</group>
Expand Down
5 changes: 3 additions & 2 deletions hr_timesheet_sheet/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!--
Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com)
Expand Down Expand Up @@ -39,8 +40,8 @@
</div>
<div
class="col-xs-12 col-md-6 o_setting_box"
invisible="[('sheet_range','!=','WEEKLY')]"
required="[('sheet_range','=','WEEKLY')]"
invisible="sheet_range != 'WEEKLY'"
required="sheet_range == 'WEEKLY'"
>
<div class="o_setting_right_pane">
<label for="timesheet_week_start" />
Expand Down

0 comments on commit e31ae06

Please sign in to comment.