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 Mar 11, 2021
1 parent 9027218 commit 4dd6a95
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
3 changes: 3 additions & 0 deletions sale_timesheet_task_exclude/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Contributors

* Fernando La Chica <[email protected]>

* Dhara Solanki <[email protected]>


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

Expand Down
19 changes: 14 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,20 @@ 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 @@ -9,9 +9,12 @@ def setUp(self):
super().setUp()

self.uom_hour = self.env.ref("uom.product_uom_hour")
self.user_type_payable = self.env.ref("account.data_account_type_payable")
self.user_type_receivable = self.env.ref("account.data_account_type_receivable")
self.user_type_revenue = self.env.ref("account.data_account_type_revenue")
self.user_type_payable = self.env.ref(
"account.data_account_type_payable")
self.user_type_receivable = self.env.ref(
"account.data_account_type_receivable")
self.user_type_revenue = self.env.ref(
"account.data_account_type_revenue")
self.Partner = self.env["res.partner"]
self.SudoPartner = self.Partner.sudo()
self.Employee = self.env["hr.employee"]
Expand Down Expand Up @@ -42,7 +45,8 @@ 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 @@ -106,7 +110,8 @@ def test_exclude_from_sale_order(self):
}
)
sale_order.action_confirm()
task = self.SudoProjectTask.search([("sale_line_id", "=", sale_order_line.id)])
task = self.SudoProjectTask.search(
[("sale_line_id", "=", sale_order_line.id)])
timesheet = self.SudoAccountAnalyticLine.create(
{
"project_id": task.project_id.id,
Expand All @@ -116,16 +121,13 @@ def test_exclude_from_sale_order(self):
"employee_id": employee.id,
}
)
self.assertTrue(timesheet.so_line)
self.assertEqual(task.billable_type, "task_rate")
self.assertTrue(task.sale_order_id)

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

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

payment = (
self.env["sale.advance.payment.inv"]
Expand Down

0 comments on commit 4dd6a95

Please sign in to comment.