-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
[14.0][IMP] hr_timesheet_purchase_order: create PO automatically #597
Conversation
0645995
to
ab44ec4
Compare
e051a34
to
b1e89ad
Compare
b5ee6ce
to
c825a10
Compare
a74f9e8
to
26c69a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I can't understand for what you use compute method in all fields.
- Readme need added.
- For functions need add comments and docstrings.
- Test coverage not cover complex methods need fixed it.
8d75845
to
751566c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check comment
There was a problem hiding this 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
This PR has the |
There was a problem hiding this 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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | ||
): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( | ||
[ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( | ||
[ |
There was a problem hiding this comment.
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
There was a problem hiding this 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 = { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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.
c200073
to
0aa1fbe
Compare
0aa1fbe
to
590052d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR has the |
@alexey-pelykh shall we merge? thanks! |
/ocabot merge minor |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at 017f2f2. Thanks a lot for contributing to OCA. ❤️ |
Create PO automatically