-
-
Notifications
You must be signed in to change notification settings - Fork 501
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
[12.0][MIG] date_range #25
Conversation
* [ADD] Basic structure for the new date range module * [IMP] Add a basic description into the README * [IMP] Basic implementation * [IMP] First working implementation * [IMP] Improve datamodel * [ADD] Add basic tests for date.range * [PEP8] * [PYLINT] * [DEL] Remove unused code * [IMP] Remove unsused dependencies into the JS * [IMP] Better operator label for date range * [DEL] Remove unused file * [IMP] Better user experience by showing the select input only once empty * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by using postgresql 9.4 * [FIX]Try with postgresql 9.2 since the daterange method has appeared in 9.2 * [IMP] Add a limitation into the module description to warm about the minimal version of postgresql to use * [IMP]Add multi-company rules * [IMP]Remove unused files * [FIX] Add missing brackets into JS * [FIX] Overlap detection when company_id is False * [IMP] Add default order for date.range * [IMP] Add date range generator * [FIX] OE compatibility * [FIX] Travis * [IMP] Code cleanup and improves test coverage * [FIX] Add missing dependency on 'web' * [PYLINT] remove unused import * [FIX] Add missing copyright * [FIX] Limits are included into the range * [IMP][date_range] Security * [IMP] Improve module description * [IMP] Spelling
* Improve 'name' for generator wizard ir.rule should be active by default * Don't auto-add '-' after prefix when generating date ranges via wizard * code fine tuning suggested by Sylvain Garancher
Currently translated at 89.1% (41 of 46 strings) Translation: server-ux-11.0/server-ux-11.0-date_range Translate-URL: https://translation.odoo-community.org/projects/server-ux-11-0/server-ux-11-0-date_range/ar/
If any module adds a required field on company, module fails. Executing it on post_install, there's no problem.
Currently translated at 82.6% (38 of 46 strings) Translation: server-ux-11.0/server-ux-11.0-date_range Translate-URL: https://translation.odoo-community.org/projects/server-ux-11-0/server-ux-11-0-date_range/da/
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 tested it and works fine. Code looks good too. 👍
@astirpe Thank you for the migration. A little change to do otherwise LGTM |
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 your contribution!
Please check the warning thrown by runbot too
date_range/models/date_range.py
Outdated
('date_range_uniq', 'unique (name,type_id, company_id)', | ||
'A date range must be unique per company !')] | ||
|
||
@api.onchange('company_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.
should depend on type_id
too
date_range/models/date_range_type.py
Outdated
for rec in self.sudo(): | ||
if not rec.company_id: | ||
continue | ||
if bool(self.date_range_ids.filtered( |
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 you don't need the cast to bool
.
Check on rec
instead of 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.
@SimoRubi I think you misunderstand the code.....
We check if a date_range with another company lambda r: r.company_id and r.company_id != rec.company_id
already exists into the list of date ranges (self.date_range_ids) with the same type.
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 the clarification @lmignon, but if self
is a recordset, then wouldn't self.date_range_ids
throw an Exception?
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.
@SimoRubi You're right, the logic here is not right.... may be something like
for rec in self.sudo():
company_ids = filtered(None, rec.date_range_ids.mapped('company_id'))
if company_ids and company_ids != rec.company_id:
raise ....
to be tested
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.
But replacing self by rec is even more easy and readable ;-)
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.
With latest commit, the self is replaced by rec. Is that enough? Do you all agree?
date_range/models/date_range_type.py
Outdated
raise ValidationError( | ||
_('You cannot change the company, as this ' | ||
'Date Range Type is assigned to Date Range ' | ||
'(%s).') % (self.date_range_ids.name_get()[0][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.
Use rec
instead of 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.
@SimoRubi see my previous comment. This code is right.
date_range/readme/INSTALL.rst
Outdated
@@ -0,0 +1,3 @@ | |||
The addon use the daterange method from postgres. This method is supported as of postgresql 9.2 | |||
|
|||
|
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.
Too many new lines.
}, | ||
|
||
get_value: function () { | ||
return parseInt(this.$el.val()); |
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 you specify the radix.
|
||
date_range_type_operator_selected: function (type_id){ | ||
this.$value.empty().show(); | ||
var ds = new data.DataSetSearch(this, 'date.range', this.context, [['type_id', '=', parseInt(type_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 you specify the radix?
@astirpe also note that the folder migrations has to be removed as stated in https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-12.0#tasks-to-do-in-the-migration:
|
@SimoRubi I think that the actual migration script ( |
@astirpe No, the rule is to always be on latest updated version of N-1 module for migrating to N. If not, you will get a lot of side effects. Trust me on this 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.
ok for me
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 runbot
Migration scripts are removed. |
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.
@astirpe It could be nice to backport the fix into the date_range_type constrains in previous version....
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!
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 for me
The code review done within this PR is backported to V11: #26 |
No description provided.