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

[12.0][MIG] date_range #25

Merged
merged 23 commits into from
Oct 4, 2018
Merged

[12.0][MIG] date_range #25

merged 23 commits into from
Oct 4, 2018

Conversation

astirpe
Copy link
Member

@astirpe astirpe commented Oct 1, 2018

No description provided.

lmignon and others added 21 commits October 2, 2018 10:36
* [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/
Copy link
Contributor

@espo-tony espo-tony left a 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. 👍

@lmignon
Copy link
Sponsor Contributor

lmignon commented Oct 2, 2018

@astirpe Thank you for the migration. A little change to do otherwise LGTM

Copy link
Member

@SimoRubi SimoRubi left a 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_uniq', 'unique (name,type_id, company_id)',
'A date range must be unique per company !')]

@api.onchange('company_id')
Copy link
Member

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 Show resolved Hide resolved
for rec in self.sudo():
if not rec.company_id:
continue
if bool(self.date_range_ids.filtered(
Copy link
Member

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.

Copy link
Sponsor Contributor

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.

Copy link
Member

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?

Copy link
Sponsor Contributor

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

Copy link
Sponsor Contributor

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 ;-)

Copy link
Member Author

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?

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]))
Copy link
Member

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.

Copy link
Sponsor Contributor

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.

@@ -0,0 +1,3 @@
The addon use the daterange method from postgres. This method is supported as of postgresql 9.2


Copy link
Member

Choose a reason for hiding this comment

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

Too many new lines.

date_range/static/src/js/date_range.js Show resolved Hide resolved
},

get_value: function () {
return parseInt(this.$el.val());
Copy link
Member

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/static/src/js/date_range.js Show resolved Hide resolved

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)]]);
Copy link
Member

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?

@SimoRubi
Copy link
Member

SimoRubi commented Oct 2, 2018

@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:

Remove any possible migration script from previous version.

@astirpe
Copy link
Member Author

astirpe commented Oct 2, 2018

@SimoRubi I think that the actual migration script (11.0.2.0.0) should be kept as it is, to handle the case of migration directly from 11.0.1.0.0 to 12.0.1.0.0.

@pedrobaeza
Copy link
Member

@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 😉

Copy link
Member

@SimoRubi SimoRubi left a comment

Choose a reason for hiding this comment

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

ok for me

Copy link
Member

@SimoRubi SimoRubi 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 runbot

@astirpe
Copy link
Member Author

astirpe commented Oct 2, 2018

Migration scripts are removed.
The string="Type Name" is restored.
Latest commits are squashed.

Copy link
Sponsor Contributor

@lmignon lmignon left a 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....

Copy link
Member

@tarteo tarteo left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@SimoRubi SimoRubi left a comment

Choose a reason for hiding this comment

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

Ok for me

@astirpe
Copy link
Member Author

astirpe commented Oct 2, 2018

The code review done within this PR is backported to V11: #26

@pedrobaeza pedrobaeza merged commit a81479c into OCA:12.0 Oct 4, 2018
@astirpe astirpe deleted the 12_mig_date_range branch October 4, 2018 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet