Skip to content

Commit

Permalink
[IMP] hr_timesheet_hours_billed: rewrite code with help of review
Browse files Browse the repository at this point in the history
  • Loading branch information
solo4games committed Oct 30, 2023
1 parent 81b8fae commit c3124d9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hr_timesheet_hours_billed/__manifest__.py
Expand Up @@ -6,7 +6,7 @@
"category": "Timesheet",
"website": "https://github.com/OCA/timesheet",
"maintainers": ["solo4games", "CetmixGitDrone"],
"author": "Odoo Community Association (OCA), Cetmix",
"author": "Cetmix, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
Expand Down
4 changes: 3 additions & 1 deletion hr_timesheet_hours_billed/models/account_analytic_line.py
Expand Up @@ -21,7 +21,9 @@ class AccountAnalyticLine(models.Model):
def _inverse_approved(self):
user = self.env.user
now = fields.Datetime.now()
for record in self.filtered(lambda rec: rec.approved):
for record in self:
if not record.approved:
continue
record.write({"approved_date": now, "approved_user_id": user})

# override create method to initialize unit_amount_billed
Expand Down
5 changes: 2 additions & 3 deletions hr_timesheet_hours_billed/models/sale_order_line.py
Expand Up @@ -23,8 +23,7 @@ def _compute_qty_delivered(self):
return super(SaleOrderLine, self)._compute_qty_delivered()

def _get_delivered_quantity_by_analytic(self, additional_domain):
"""Compute and write the delivered quantity of current SO lines,
based on their related analytic lines.
"""Retrieve delivered quantity by line
:param additional_domain: domain to restrict AAL to include in computation
(required since timesheet is an AAL with a project ...)
"""
Expand All @@ -35,7 +34,7 @@ def _get_delivered_quantity_by_analytic(self, additional_domain):
return result

# group analytic lines by product uom and so line
domain = expression.AND([[("so_line", "in", self.ids)], additional_domain])
domain = expression.AND([[("so_line", "in", self.ids), ("approved", "!=", False)], additional_domain])
data = self.env["account.analytic.line"].read_group(
domain,
["so_line", "unit_amount_billed", "approved", "product_uom_id"],
Expand Down
7 changes: 6 additions & 1 deletion hr_timesheet_hours_billed/tests/test_hours_billed.py
Expand Up @@ -7,7 +7,12 @@

@tagged("-at_install", "post_install")
class TestCommonHourBilled(TestCommonSaleTimesheet):
# @classmethod

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

def setUp(self):

super().setUp()
Expand Down

0 comments on commit c3124d9

Please sign in to comment.