-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
[11.0][MIG] hr_timesheet_sheet #125
[11.0][MIG] hr_timesheet_sheet #125
Conversation
10e6fc2
to
6a0a064
Compare
Hey, you did it finally using 2D matrix! How do you perform the addition of a new row? |
black magic..... ;) |
hehe, I will check by curiosity when you tell me. |
My idea was more to add the feature on 2D matrix option instead any way. |
65ec009
to
319b8cf
Compare
PR is green 🍏 Reviews are welcome! @pedrobaeza right, that would be a nice feature, but I don't know much about javascript :S |
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.
Tried functionally, and it's working great. The only problem I have is with the tab key for moving inside the matrix, that is moving away from the full matrix instead of going to the next field inside the matrix, but I think this is something of the 2D matrix instead of this module. @lreficent and @simahawk I think this more for you.
Ah, and another flaw is that you can't remove a line once it's added, but well, it's not critical. |
@pedrobaeza I discussed the option to remove a line with @mreficent. Seems to me that the user should be able to select the project or project/task from the selectio and press a button 'Remove Line'. Although is not very intuitive. Perhaps another interesting option would be to allow the widget to handle a remove icon, but not sure. But for sure that is not critical. |
@pedrobaeza @lreficent @jbeficent being able to navigate easily across cells is a TODO item (in code comments). Tab indexes are set on each cell but they are ignored. Shouldn't be that hard to solve. |
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.
also, AFAIS there are no tests: would you mind adding some or - at least - drop a line in the roadmap section?
employee_id = fields.Many2one( | ||
comodel_name='hr.employee', | ||
string='Employee', | ||
default=_default_employee, |
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.
proxy default methods w/ lambda default=lambda self: self._default_foo()
return | ||
dates = sheet._get_dates() | ||
if not dates: | ||
return |
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.
shouldn't be continue
?
('sheet_id', 'in', [sheet and sheet.id or False, False]), | ||
]) | ||
lines = self.env['hr_timesheet.sheet.line'] | ||
for date in 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.
here we have N nested loops: any chance to improve it? If not possible now you can add a comment to not forget about it.
raise UserError( | ||
_('In order to create a sheet for this employee, ' | ||
'you must link him/her to an user.')) | ||
res = super(Sheet, self).create(vals) |
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.
you can use empty super()
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.
Yes, but I prefer filled supers 😋
|
||
@api.multi | ||
def write(self, vals): | ||
if 'employee_id' in vals: |
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 snippet is duplicated. What about moving it to _check_employee_user
method?
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 methods with @api.contrains
are executed at the last step of the write
but here it seems that interested them to be executed before the write
.
|
||
def clean_timesheets(self, timesheet): | ||
if self.id: | ||
for anal_line in timesheet.filtered(lambda a: not a.sheet_id): |
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 we change the spelling here? 😄
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.
hahaha
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.
@lreficent 😂
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.
here nobody was burned 😜
) | ||
|
||
@api.onchange('unit_amount') | ||
def onchange_unit_amount(self): |
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.
aren't we doing too many things here?
In any case, please, add a docstring saying what we do.
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.
Seems "too many things" but are "just a few". It's just that are many conditions. I will add docstring explaining it well.
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.
Added docstring. I will be sure to fully add full tests for this method.
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.
Method fully tested.
class AccountAnalyticLine(models.Model): | ||
_inherit = 'account.analytic.line' | ||
|
||
sheet_id_computed = fields.Many2one( |
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.
computed_sheet_id
? Also, would be nice to have a comment explaining the purpose of this field (compared w/ the next one)
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 think it's better as is, for having the same name beginning
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 is the same that v10. Here I didn't do any change.
Thank you for this porting! Are field 'account_ids' and model 'hr_timesheet.sheet.account' going to be removed? Or are they still present for some reason? |
@pedrobaeza Removing matrix lines was already not possible in v10. But, you can always delete timesheet lines from the "Details" tab. @simahawk Yes, my intention is to add tests but I wanted a preliminary review from all of you. It's easy to do changes if there aren't tests than doing changes when there are tests. @astirpe They are present because @jbeficent wanted them to be present. He wanted me to do the least changes possibles from v10. |
If they are useless, you can remove them in an extra commit, so we can review isolately each one. |
Looking good. Can you also sum up the total of the period in the 'overview' tab? The lines and the days has a total. It would be nice to have a grand total also. This already on the 'details' tab. |
@yung-wang but that's something of the matrix widget and this PR can't modify the widget. May @simahawk or @grindtildeath want to improve the widget in the |
@mreficent ah ok, it is also fine if that can be improved in the widget. thanks. |
hr_timesheet_sheet/__manifest__.py
Outdated
'author': 'Eficent, Odoo Community Association (OCA)', | ||
'website': 'https://github.com/OCA/hr-timesheet', | ||
'depends': [ | ||
'hr_timesheet', 'account', |
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.
Why is there a dependency on 'account' here?
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.
because v10 hr_timesheet
has a dependency on account
and v11 hr_timesheet
doesn't have it, and I thought that the previous dependencies of hr_timesheet_sheet
(although indirectly) should remain.
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.
Do you think I should remove it?
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 think so. I don't think you made use of any particular field introduced by 'account'. It should be fine to remove it, please do it and I will try with some extra tests ;)
('date', '>=', sheet.date_start), | ||
('employee_id', '=', sheet.employee_id.id), | ||
('sheet_id', 'in', [sheet and sheet.id or False, False]), | ||
]) |
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.
In a multicompany environment I guess we also need to search per company:
('company_id', '=', sheet.company_id.id)
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.
Yeah, as it is now, I haven't taken into account the multicompany yet.
default='new', track_visibility='onchange', | ||
string='Status', required=True, readonly=True, index=True, | ||
) | ||
account_ids = fields.One2many( |
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 remove field account_ids
and all the code regarding the hr_timesheet.sheet.account
model, since it's not used anymore
if r == WEEKLY: | ||
return today - relativedelta(days=today.weekday()) | ||
elif r == MONTHLY: | ||
return fields.Date.date(today.year, today.month, 1) |
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.
Monthly timesheet doesn't seem to work properly, could you have a try?
I got this:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/.repo_requirements/odoo/odoo/http.py", line 650, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/.repo_requirements/odoo/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/.repo_requirements/odoo/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/.repo_requirements/odoo/odoo/http.py", line 692, in dispatch
result = self._call_function(**self.params)
File "/.repo_requirements/odoo/odoo/http.py", line 342, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/.repo_requirements/odoo/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/.repo_requirements/odoo/odoo/http.py", line 335, in checked_call
result = self.endpoint(*a, **kw)
File "/.repo_requirements/odoo/odoo/http.py", line 936, in __call__
return self.method(*args, **kw)
File "/.repo_requirements/odoo/odoo/http.py", line 515, in response_wrap
response = f(*args, **kw)
File "/home/odoo/OCB-11.0/addons/web/controllers/main.py", line 931, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/odoo/OCB-11.0/addons/web/controllers/main.py", line 923, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/.repo_requirements/odoo/odoo/api.py", line 687, in call_kw
return call_kw_model(method, model, args, kwargs)
File "/.repo_requirements/odoo/odoo/api.py", line 672, in call_kw_model
result = method(recs, *args, **kwargs)
File "/.repo_requirements/odoo/odoo/models.py", line 1078, in default_get
defaults[name] = field.default(self)
File "/home/odoo/build/OCA/hr-timesheet/hr_timesheet_sheet/models/hr_timesheet_sheet.py", line 28, in _default_date_start
return fields.Date.date(today.year, today.month, 1)
AttributeError: type object 'Date' has no attribute 'date'
}, | ||
} | ||
|
||
def copy(self, *args, **argv): |
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 signature of this method is a bit "old fashioned"
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.
copypasted from v10
comodel_name='hr.department', | ||
string='Department' | ||
) | ||
project_ids = fields.Many2many( |
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.
Why do you need project_ids
?
'new': [('readonly', False)]}, | ||
) | ||
state = fields.Selection([ | ||
('new', 'New'), |
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.
Consider to remove the item 'new' of the state field.
Actually the timesheet sheet is created with state field as 'new' by default, but it automatically goes to 'draft' while created (see def create()
). Then 'new' is never used again ... so I would say that state 'new' is completely useless.
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 difference is that in new
, you select the dates. In draft
you can't change the 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.
Ok, then for me it's better to keep this part as it is. Thank you for checking!
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.
Well, I finally deleted this state.
@jbeficent about removing a line (row of the matrix), it could be done automatically in case you have a line containing only zeros. When you save the timesheet sheet, such line can be simply removed by the orm: no extra buttons needed. But as you said it is just a nice to have, not really needed at this moment. |
@astirpe as it is now, the module already removes rows that only contains zeros in |
b6d68d9
to
9a3a2ac
Compare
In Runbot i got this:
|
@astirpe what did you do to get this traceback? |
@mreficent this morning I just opened the Runbot instance of this PR and I clicked on "Timesheet Sheet" |
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
* [10.0] hr_timesheet_sheet * [11.0][MIG] hr_timesheet_sheet * [REMOVE] hr_timesheet.sheet.account * [REMOVE] 'new' state * [ADD] Tests * [UPD] Adapt to multicompany * [ADD] Add more tests (include multicompany tests) * [FIX] project_task_stage_allow_timesheet: show error message only if task * [ADD] Migration scripts to v11
Migrated from Odoo, 10.0 version.