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

[18.0][MIG] date_range #956

Open
wants to merge 71 commits into
base: 18.0
Choose a base branch
from

Conversation

BertVGroenendael
Copy link

No description provided.

lmignon and others added 30 commits October 15, 2024 13:26
* [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
If any module adds a required field on company, module fails. Executing it on
post_install, there's no problem.
Pylint-odoo is not able to detect properly whitelisted odoo's dependencies if an isort configuration file is present into the directory. Therefore the check fails by complaining that the dateutil dependecy is not declared into the manifest. A fix could have been to declare the dependency into the manifest . Unfortunately, in this case, a warning will be issued by runbot complaining that the python external dependency dateutil should be replaced by it's PyPI package name. Unfortunalely, if we put the Pypi package name into the external dependencies, pylint fails again since it's not able to play with PyPI distribution names.
The workaround is to temporarily disable this check into pylint. I every case, all the pre-commit files will be reset once pylint will be fixed
We can't assign an empty recordset in a computed writable for a required field for
triggering DB fault, as previously this we get an akward error no in current
ORM status:

ERROR: operator does not exist: integer = boolean
LINE 12:                     AND dt.type_id=false;
                                           ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

so let's simply trigger in this case the check of the company consistency, which is
legit and the final expected result.

I have added an extra test for testing the company consistency the other way around.
Because ev.target.value is a string and the range ids are integers,
comparison was always false, so the first range values were always used.
@OCA-git-bot OCA-git-bot mentioned this pull request Oct 16, 2024
17 tasks
@BertVGroenendael BertVGroenendael force-pushed the 18.0-mig-date_range branch 6 times, most recently from 217c696 to 735823f Compare October 17, 2024 08:54
Copy link

@thienvh332 thienvh332 left a comment

Choose a reason for hiding this comment

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

Hi @BertVGroenendael ,
I did a UI test and found the same issue as issue #821. You can pick this commit from v14 to resolve it.

date_range/models/date_range_search_mixin.py Outdated Show resolved Hide resolved
@BertVGroenendael BertVGroenendael force-pushed the 18.0-mig-date_range branch 7 times, most recently from fc004f7 to 2173a57 Compare October 22, 2024 06:51
@BertVGroenendael BertVGroenendael force-pushed the 18.0-mig-date_range branch 5 times, most recently from e333f48 to 3e9ec2f Compare October 24, 2024 06:25
index=1,
required=True,
ondelete="restrict",
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]",

nitpicking: redundant with check_company=True

check_company=True,
)
company_id = fields.Many2one(
comodel_name="res.company", string="Company", index=1, default=_default_company
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
comodel_name="res.company", string="Company", index=1, default=_default_company
comodel_name="res.company", string="Company", index=True, default=_default_company

type_id = fields.Many2one(
comodel_name="date.range.type",
string="Type",
index=1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
index=1,
index=True,

Comment on lines +64 to +72
"(%(date_start)s > %(date_end)s)"
)
% {
"name": this.name,
"date_start": this.date_start,
"date_end": this.date_end,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"(%(date_start)s > %(date_end)s)"
)
% {
"name": this.name,
"date_start": this.date_start,
"date_end": this.date_end,
}
"(%(date_start)s > %(date_end)s)",
name=this.name,
date_start=this.date_start,
date_end=this.date_end,
)

Comment on lines +103 to +106
self.env._("%(thisname)s overlaps %(dtname)s")
% {"thisname": this.name, "dtname": dt.name}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.env._("%(thisname)s overlaps %(dtname)s")
% {"thisname": this.name, "dtname": dt.name}
self.env._(
"%(thisname)s overlaps %(dtname)s"
thisname=this.name
dtname=dt.name,
)

@BertVGroenendael BertVGroenendael force-pushed the 18.0-mig-date_range branch 3 times, most recently from 2d71e63 to c4835a0 Compare November 4, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.