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

[14.0][IMP] hr_timesheet_purchase_order: create PO automatically #597

Conversation

dessanhemrayev
Copy link
Contributor

@dessanhemrayev dessanhemrayev commented Jul 6, 2023

Create PO automatically

@dessanhemrayev dessanhemrayev force-pushed the 14.0-t2676-hr_timesheet_purchase_order-auto_create_po branch 4 times, most recently from 0645995 to ab44ec4 Compare July 20, 2023 00:10
@dessanhemrayev dessanhemrayev force-pushed the 14.0-t2676-hr_timesheet_purchase_order-auto_create_po branch 10 times, most recently from e051a34 to b1e89ad Compare August 3, 2023 20:12
@dessanhemrayev dessanhemrayev marked this pull request as ready for review August 3, 2023 20:13
@dessanhemrayev dessanhemrayev force-pushed the 14.0-t2676-hr_timesheet_purchase_order-auto_create_po branch 3 times, most recently from b5ee6ce to c825a10 Compare August 4, 2023 00:20
@dessanhemrayev dessanhemrayev force-pushed the 14.0-t2676-hr_timesheet_purchase_order-auto_create_po branch 3 times, most recently from a74f9e8 to 26c69a3 Compare August 15, 2023 18:30
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.

  1. I can't understand for what you use compute method in all fields.
  2. Readme need added.
  3. For functions need add comments and docstrings.
  4. Test coverage not cover complex methods need fixed it.

@dessanhemrayev dessanhemrayev force-pushed the 14.0-t2676-hr_timesheet_purchase_order-auto_create_po branch 3 times, most recently from 8d75845 to 751566c Compare October 17, 2023 20:39
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.

Please check comment

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!

[FIX]hr_timesheet_purchase_order:change field type

Change field type `selection` to `integer`
Add new method border min max and chech month `february`
Fix and update tests

[FIX] hr_timesheet_purchase_order: add method
@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). 🤖

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.

Please fix your code.


@api.constrains("repeat_day", "repeat_month")
def _check_repeat_day_or_month(self):
if 0 > self.repeat_day or self.repeat_day > 31:

Choose a reason for hiding this comment

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

Not all months have 31 days. Please add condition for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll fix it

return [DAYS.get(self.repeat_weekday)(n)]

@api.model
def _get_next_recurring_dates(

Choose a reason for hiding this comment

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

This method have so many arguments. Please use dict or recurrence record for this. For example:

def _get_next_recurring_dates(self, repeat_struct):

repeat_struct is a dict or recurrence record.
This solution is easier and compact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll fix it

repeat_week,
repeat_month,
**kwargs
):

Choose a reason for hiding this comment

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

Please add docstring for arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll add it

}


class HRTimeSheetRecurrence(models.Model):

Choose a reason for hiding this comment

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

Please add docstring for each method with describe arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll add it

readonly=False,
)
repeat_month = fields.Selection(
[

Choose a reason for hiding this comment

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

The same selection in prev model, would you create variable for this selection and use it in fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't do this because all these fields are calculated or modified by the user

Choose a reason for hiding this comment

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

Selection argument is static data. Just create variable MONTH_SELECTION

MONTH_SELECTION = [
("january", "January"),
("february", "February"),
....
]

...

repeat_month = fields.Selection(selection=MONTH_SELECTION)

The same for week day field

)
repeat_weekday = fields.Selection(
[
("mon", "Monday"),

Choose a reason for hiding this comment

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

The same selection in prev model, would you create variable for this selection and use it in fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't do this because all these fields are calculated or modified by the user

if self.repeat_month == "february" and self.repeat_day > 29:
self.repeat_day = 28

repeat_week = fields.Selection(

Choose a reason for hiding this comment

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

The same selection in prev model, would you create variable for this selection and use it in fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't do this because all these fields are calculated or modified by the user

from .common_po_recurrence import TestTimesheetPOrecurrenceCommon


class TestTimesheetPORecurrenceNotProduct(TestTimesheetPOrecurrenceCommon):

Choose a reason for hiding this comment

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

Only one test on the all model? Would you please upped test coverage and add docstrings and assertions messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand that it is unnecessary to use an entire class for one test, but this requires the test to cover other functions of this module. And what kind of testing options can there be when the most important thing of this module is not selected, what is it intended for?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add docstrings and assertions messages.

from .common_po_recurrence import TestTimesheetPOrecurrenceCommon


class TestTimesheetPOrecurrence(TestTimesheetPOrecurrenceCommon):

Choose a reason for hiding this comment

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

Would you add docstrings and assertions messages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll add it

readonly=False,
)
repeat_month = fields.Selection(
[

Choose a reason for hiding this comment

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

Selection argument is static data. Just create variable MONTH_SELECTION

MONTH_SELECTION = [
("january", "January"),
("february", "February"),
....
]

...

repeat_month = fields.Selection(selection=MONTH_SELECTION)

The same for week day field

Copy link
Contributor

@alexey-pelykh alexey-pelykh left a comment

Choose a reason for hiding this comment

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

Can't agree with amount of hardcoded calendar info

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError

MONTHS = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This hardcoded part should be used from corresponding library, calendar.monthrange

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, for feedback, I'll fix it

)
repeat_weekday = fields.Selection(
[
("mon", "Monday"),
Copy link
Contributor

Choose a reason for hiding this comment

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

import locale

locale.nl_langinfo(locale.DAY_1)

don't multiply static text without need.

@dessanhemrayev dessanhemrayev force-pushed the 14.0-t2676-hr_timesheet_purchase_order-auto_create_po branch 2 times, most recently from c200073 to 0aa1fbe Compare February 18, 2024 14:38
@dessanhemrayev dessanhemrayev force-pushed the 14.0-t2676-hr_timesheet_purchase_order-auto_create_po branch from 0aa1fbe to 590052d Compare February 18, 2024 14:47
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!

@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). 🤖

@francesco-ooops
Copy link
Contributor

@alexey-pelykh shall we merge? thanks!

@alexey-pelykh
Copy link
Contributor

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-597-by-alexey-pelykh-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit d602ed5 into OCA:14.0 Mar 18, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 017f2f2. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants