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

[16.0][ADD] hr_timesheet_hours_billed #570

Conversation

solo4games
Copy link

This module allows to specify billed amount of time in timesheet while still keeping original time tracked. Additional field "Hours Billed" and "Approved" "Approved by" and "Approved on" are added to timesheet. These fields are visible only for "Timesheets: Administrator" group

@solo4games solo4games marked this pull request as draft February 18, 2023 18:51
hr_timesheet_hours_billed/__manifest__.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/__manifest__.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/so_line_hours_billed.py Outdated Show resolved Hide resolved
Copy link

@geomer198 geomer198 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
PR Name must be have format [verion][ADD] module_name

Exmaple: [16.0][ADD] hr_timesheet_hours_billed

@solo4games solo4games force-pushed the 16.0-t2367-hr_timesheet_hours_billed-add_hours_billed branch from 2f3dc42 to 8ab7b42 Compare March 6, 2023 09:08
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File names must follow OCA rules

hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
hr_timesheet_hours_billed/models/hours_billed.py Outdated Show resolved Hide resolved
@solo4games solo4games changed the title [16.0][ADD] hr_timesheet_hours_billed:hours_billed [16.0][ADD] hr_timesheet_hours_billed Mar 9, 2023
Copy link
Member

@GabbasovDinar GabbasovDinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM!

@solo4games solo4games marked this pull request as ready for review June 28, 2023 18:50
@solo4games solo4games force-pushed the 16.0-t2367-hr_timesheet_hours_billed-add_hours_billed branch 2 times, most recently from 27d023b to d7e7969 Compare July 3, 2023 21:44
@@ -29,7 +29,8 @@ def _inverse_approved(self):
def create(self, vals_list):
for vals in vals_list:
if not vals.get("unit_amount_billed"):
vals["unit_amount_billed"] = vals["unit_amount"]
unit_amount = vals.get("unit_amount")
vals["unit_amount_billed"] = 0.0 if not unit_amount else unit_amount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace these 2 lines with a single one:
vals["unit_amount_billed"] = vals.get("unit_amount", 0.0)

@solo4games solo4games force-pushed the 16.0-t2367-hr_timesheet_hours_billed-add_hours_billed branch 2 times, most recently from 5c2132d to 81b8fae Compare July 4, 2023 12:32
Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

1 similar comment
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@ivs-cetmix
Copy link
Member

Hey @OCA/project-service-maintainers any chances to have this merged?

Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tech review only. LG overall, some minor glitches.

"category": "Timesheet",
"website": "https://github.com/OCA/timesheet",
"maintainers": ["solo4games", "CetmixGitDrone"],
"author": "Odoo Community Association (OCA), Cetmix",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls keep OCA at the end of the list

def _inverse_approved(self):
user = self.env.user
now = fields.Datetime.now()
for record in self.filtered(lambda rec: rec.approved):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule of thumb: if you don't need a variable w/ the result of filtered to play with later, avoid this approach because you loop twice (possibly on the same recordset):

Suggested change
for record in self.filtered(lambda rec: rec.approved):
for record in self:
if not rec.approved:
continue

"analytic_line_ids.approved",
)
def _compute_qty_delivered(self):
"""This method compute the delivered quantity of the SO lines:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds more like a comment. A relevant info would be that you added some more field to depends

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to write after this text something like
"Added analytic_line_ids.so_line, analytic_line_ids.unit_amount_billed, ..."?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 26 to 29
"""Compute and write the delivered quantity of current SO lines,
based on their related analytic lines.
:param additional_domain: domain to restrict AAL to include in computation
(required since timesheet is an AAL with a project ...)
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem to write. Plus, having a get method that writes can be misleading and sometime dangerous.
Regarding the format of docstring, I always recommend to follow https://peps.python.org/pep-0257/#multi-line-docstrings (which is kind of the same guideline we have for commit messages).

Suggested change
"""Compute and write the delivered quantity of current SO lines,
based on their related analytic lines.
:param additional_domain: domain to restrict AAL to include in computation
(required since timesheet is an AAL with a project ...)
"""
"""Retrieve delivered quantity by line.
$longer-explanation-here-if-you-like
:param additional_domain: domain to restrict AAL to include in computation
(required since timesheet is an AAL with a project ...)
"""

uom.id: uom for uom in self.env["uom.uom"].browse(product_uom_ids)
}
for item in data:
if not item["product_uom_id"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this check be part of the domain?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not, because this is contains tuple, so this will be hard to check it from domain, but I can check approved in domain

so_line = lines_map[so_line_id]
result.setdefault(so_line_id, 0.0)
uom = product_uom_map.get(item["product_uom_id"][0])
if item.get("approved"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as it seems non approved lines and lines w/o uom are totally ignored here

@tagged("-at_install", "post_install")
class TestCommonHourBilled(TestCommonSaleTimesheet):
# @classmethod
def setUp(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to setUpClass and disable tracking unless you need it for functional purposes


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

This module allows to specify billed amount of time in timesheet while
still keeping original time tracked. Additional field "Hours Billed" and
"Approved" "Approved by" and "Approved on" are added to timesheet.
These fields are visible only for "Timesheets: Administrator" group
@solo4games solo4games force-pushed the 16.0-t2367-hr_timesheet_hours_billed-add_hours_billed branch from c3124d9 to 24ef59c Compare October 30, 2023 05:58
Copy link

@leemannd leemannd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, if I understand correctly, this module allows to:

  • specify an invoicable amount
  • adds fields to manage the approval status of the analytic lines

The base features of rounding are already present into sale_timesheet_rounding
https://github.com/OCA/timesheet/tree/15.0/sale_timesheet_rounded

I think it would be better if you port the already existing module and add a new one with the features of approval

@solo4games
Copy link
Author

Hello, if I understand correctly, this module allows to:

  • specify an invoicable amount
  • adds fields to manage the approval status of the analytic lines

The base features of rounding are already present into sale_timesheet_rounding https://github.com/OCA/timesheet/tree/15.0/sale_timesheet_rounded

I think it would be better if you port the already existing module and add a new one with the features of approval

I can not understand what the meaning of using sale_timesheet_rounding module, because, if I understand correctly, there is only rounding mechanism, but in hr_timesheet_hours_billed module we use approval mechanism to invoice only "approved" timesheets.

@ivs-cetmix
Copy link
Member

Hello, if I understand correctly, this module allows to:

  • specify an invoicable amount
  • adds fields to manage the approval status of the analytic lines

The base features of rounding are already present into sale_timesheet_rounding https://github.com/OCA/timesheet/tree/15.0/sale_timesheet_rounded

I think it would be better if you port the already existing module and add a new one with the features of approval

Thank you for the hint! Sounds reasonable. We will check this.

@leemannd
Copy link

leemannd commented Nov 1, 2023

Hello @solo4games ,
From my understanding, you're doing two things into your module.

Adding a field Hours Billed unit_amount_billed.
This field is pre-populated from unit_amount.
Then you can update the time to be billed, invoiced to the customer while keeping intact unit_amount

This feature possibility is fully covered in sale_timesheet_rounding.

The module, will add unit_amount_rounded. That is prepopulated at creation with the value of unit_amount.
If you want you can add a setup into your project, to have either:

This means it covers the possibility to keep track of the real time (for HR purpose), to maybe reduce manually the time to be invoiced or event better, to round it by default if your policy on support is to round hours to a given amount of time.

The only thing that is not handled into the module we created, is the strict handling of the approval that you're adding.

So my proposition is to migrate the module sale_timesheet_rounded and to create a second one that handles the validation.

Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 31, 2024
@github-actions github-actions bot closed this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants