Skip to content

Commit

Permalink
[MIG] Migrate module sale_timesheet_task_exclude to v14.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsolanki-initos committed Jun 1, 2021
1 parent 9027218 commit 9b7d838
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
2 changes: 2 additions & 0 deletions sale_timesheet_task_exclude/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Contributors

* Fernando La Chica <[email protected]>

* Dhara Solanki <[email protected]>

Maintainers
~~~~~~~~~~~

Expand Down
25 changes: 20 additions & 5 deletions sale_timesheet_task_exclude/models/project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@ class ProjectTask(models.Model):
),
)

@api.depends("exclude_from_sale_order")
def _compute_billable_type(self):
super()._compute_billable_type()
for task in self.filtered("exclude_from_sale_order"):
task.billable_type = "no"
@api.depends(
"sale_line_id",
"project_id",
"allow_billable",
"non_allow_billable",
"exclude_from_sale_order",
)
def _compute_sale_order_id(self):
for task in self:
if task.exclude_from_sale_order:
task.sale_order_id = False
elif not task.allow_billable or task.non_allow_billable:
task.sale_order_id = False
elif task.allow_billable:
if task.sale_line_id:
task.sale_order_id = task.sale_line_id.sudo().order_id
elif task.project_id.sale_order_id:
task.sale_order_id = task.project_id.sale_order_id
if task.sale_order_id and not task.partner_id:
task.partner_id = task.sale_order_id.partner_id

def write(self, vals):
res = super().write(vals)
Expand Down
2 changes: 2 additions & 0 deletions sale_timesheet_task_exclude/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
* `Guadaltech Soluciones Tecnológicas, S.L. <https://www.guadaltech.es/>`_:

* Fernando La Chica <[email protected]>

* Dhara Solanki <[email protected]>
2 changes: 1 addition & 1 deletion sale_timesheet_task_exclude/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# Go to *Project > All Tasks*
# Go to *Project > Tasks*
# Open specific task for editing
# Check *Exclude From Billing*
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_exclude_from_sale_order(self):
}
)
project = self.SudoProject.create(
{"name": "Project #1", "allow_timesheets": True}
{"name": "Project #1", "allow_timesheets": True, "allow_billable": True}
)
product = self.SudoProductProduct.create(
{
Expand Down Expand Up @@ -116,15 +116,12 @@ def test_exclude_from_sale_order(self):
"employee_id": employee.id,
}
)
self.assertTrue(timesheet.so_line)
self.assertEqual(task.billable_type, "task_rate")

task.exclude_from_sale_order = True
self.assertEqual(task.billable_type, "no")
task.allow_billable = False
self.assertFalse(timesheet.so_line)

task.exclude_from_sale_order = False
self.assertEqual(task.billable_type, "task_rate")
task.allow_billable = True
self.assertTrue(timesheet.so_line)

payment = (
Expand Down

0 comments on commit 9b7d838

Please sign in to comment.