<feed xmlns='http://www.w3.org/2005/Atom'>
<title>Odoo/odoo/tools/date_utils.py, branch 14.0</title>
<subtitle>The current checkout of upstream Odoo</subtitle>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/'/>
<entry>
<title>[FIX] core: calling read_group / name_search over xmlrpc</title>
<updated>2020-04-09T09:06:34+00:00</updated>
<author>
<name>Xavier Morel</name>
<email>xmo@odoo.com</email>
</author>
<published>2020-03-17T11:08:38+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=1ecb0641efead9966faafb853c1e03138a49f111'/>
<id>1ecb0641efead9966faafb853c1e03138a49f111</id>
<content type='text'>
Also non-browser jsonrpc (as it goes through a similar process): for
internal performance reasons, name_search and read_group have been
converted to a *lazy* name_get, so the "display name" is not
unnecessarily computed.

However this is an issue for the RPC endpoints (/xmlrpc and /jsonrpc)
as they have no support for `lazy` and thus tend to blow up and / or
do the wrong thing when trying to output a lazy:

* xmlrpc has no way to handle lazy at all and straight blows up
* jsonrpc falls back to `json_default` so they try to stringify the
  lazy, which might have worked except

*Problematically* both endpoints delegate the actual work to
`dispatch_rpc` which handles dispatching between various services and
ultimately creates a *new* cursor before calling model
methods (`object` service and `execute`/`execute_kw`).

This means by the time the result is serialized to be output, the
lazy's cursor has long been closed, and thus any access to an
unevaluated `lazy` errors out when trying to fetch the underlying
item.

This also means we can't just add a hook to serialize the lazy
in the xmlrpc marshaller, though we do have to do that. We *also* (for
both xmlrpc and jsonrpc) have to force evluation of lazy values before
our cursor is closed, meaning it has to be done right after the method
is invoked, iterating the entire response.

Related to task 2170343

closes odoo/odoo#49286

X-original-commit: e2b5a359c1d5eccbe725c1c3169b4130d7bca49b
Signed-off-by: Xavier Morel (xmo) &lt;xmo@odoo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also non-browser jsonrpc (as it goes through a similar process): for
internal performance reasons, name_search and read_group have been
converted to a *lazy* name_get, so the "display name" is not
unnecessarily computed.

However this is an issue for the RPC endpoints (/xmlrpc and /jsonrpc)
as they have no support for `lazy` and thus tend to blow up and / or
do the wrong thing when trying to output a lazy:

* xmlrpc has no way to handle lazy at all and straight blows up
* jsonrpc falls back to `json_default` so they try to stringify the
  lazy, which might have worked except

*Problematically* both endpoints delegate the actual work to
`dispatch_rpc` which handles dispatching between various services and
ultimately creates a *new* cursor before calling model
methods (`object` service and `execute`/`execute_kw`).

This means by the time the result is serialized to be output, the
lazy's cursor has long been closed, and thus any access to an
unevaluated `lazy` errors out when trying to fetch the underlying
item.

This also means we can't just add a hook to serialize the lazy
in the xmlrpc marshaller, though we do have to do that. We *also* (for
both xmlrpc and jsonrpc) have to force evluation of lazy values before
our cursor is closed, meaning it has to be done right after the method
is invoked, iterating the entire response.

Related to task 2170343

closes odoo/odoo#49286

X-original-commit: e2b5a359c1d5eccbe725c1c3169b4130d7bca49b
Signed-off-by: Xavier Morel (xmo) &lt;xmo@odoo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] *: fix typos in comments</title>
<updated>2019-08-07T10:28:33+00:00</updated>
<author>
<name>mreficent</name>
<email>miquel.raich@eficent.com</email>
</author>
<published>2019-08-02T11:26:58+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=355a5dfc365c419f3be2e1ccffe0cb38e1140d27'/>
<id>355a5dfc365c419f3be2e1ccffe0cb38e1140d27</id>
<content type='text'>
closes odoo/odoo#35404

Signed-off-by: Martin Trigaux (mat) &lt;mat@odoo.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
closes odoo/odoo#35404

Signed-off-by: Martin Trigaux (mat) &lt;mat@odoo.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] tools: get_timedelta helper</title>
<updated>2019-07-04T08:19:08+00:00</updated>
<author>
<name>jem-odoo</name>
<email>jem@openerp.com</email>
</author>
<published>2019-06-28T12:32:16+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=86f5b6a926d5b0fa5b07ee943f6c84a904c48abd'/>
<id>86f5b6a926d5b0fa5b07ee943f6c84a904c48abd</id>
<content type='text'>
This commit introduces a small helper to return
a timedelta given a quantity and a time unit (day, hour,
month, ...)

Task-2024216

closes odoo/odoo#34576

Signed-off-by: Jérome Maes (jem) &lt;jem@openerp.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit introduces a small helper to return
a timedelta given a quantity and a time unit (day, hour,
month, ...)

Task-2024216

closes odoo/odoo#34576

Signed-off-by: Jérome Maes (jem) &lt;jem@openerp.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] tools: February 28th</title>
<updated>2019-04-03T09:29:57+00:00</updated>
<author>
<name>Nicolas Martinelli</name>
<email>nim@odoo.com</email>
</author>
<published>2019-04-03T08:52:36+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=1e558bc79a40aeee3fc9c4cd1fd30e8b100db112'/>
<id>1e558bc79a40aeee3fc9c4cd1fd30e8b100db112</id>
<content type='text'>
- Set your fiscal year end date to 28th February
- Run the P&amp;L a year before a leap year, e.g. anytime between March 1st
  and December 31st 2019.
- Select 'Last Financial Year'

The dates are set from 2019-03-01 to 2019-02-28.

There are actually 2 bugs. The one solved here is the following
inconsistency:

```
current_date = type(date)(2019, 4, 3)
date_utils.get_fiscal_year(current_date, day=28, month=2)
'date_from': datetime.date(2019, 3, 1), 'date_to': datetime.date(2020, 2, 28)

current_date = type(date)(2020, 2, 28)
date_utils.get_fiscal_year(current_date, day=28, month=2)
{'date_from': datetime.date(2019, 3, 1), 'date_to': datetime.date(2020, 2, 29)}
```

Both should return `'date_to': datetime.date(2020, 2, 29)`. This implies
that the period is recognized as `custom`, which is affected by the bug
solved in PR https://github.com/odoo/enterprise/pull/4006

opw-1949628

closes odoo/odoo#32366

Signed-off-by: Nicolas Martinelli (nim) &lt;nim@odoo.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Set your fiscal year end date to 28th February
- Run the P&amp;L a year before a leap year, e.g. anytime between March 1st
  and December 31st 2019.
- Select 'Last Financial Year'

The dates are set from 2019-03-01 to 2019-02-28.

There are actually 2 bugs. The one solved here is the following
inconsistency:

```
current_date = type(date)(2019, 4, 3)
date_utils.get_fiscal_year(current_date, day=28, month=2)
'date_from': datetime.date(2019, 3, 1), 'date_to': datetime.date(2020, 2, 28)

current_date = type(date)(2020, 2, 28)
date_utils.get_fiscal_year(current_date, day=28, month=2)
{'date_from': datetime.date(2019, 3, 1), 'date_to': datetime.date(2020, 2, 29)}
```

Both should return `'date_to': datetime.date(2020, 2, 29)`. This implies
that the period is recognized as `custom`, which is affected by the bug
solved in PR https://github.com/odoo/enterprise/pull/4006

opw-1949628

closes odoo/odoo#32366

Signed-off-by: Nicolas Martinelli (nim) &lt;nim@odoo.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] tools/date_utils: Fix get_fiscal_year with leap years</title>
<updated>2019-01-03T08:30:31+00:00</updated>
<author>
<name>Laurent Smet</name>
<email>las@odoo.com</email>
</author>
<published>2018-12-11T10:27:34+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=67d3d30cf2992e3193ec6d20025da5ad2261871a'/>
<id>67d3d30cf2992e3193ec6d20025da5ad2261871a</id>
<content type='text'>
Suppose calling get_fiscal_year(date, day=29, month=2) with date(year=2017, month=2, day=28)

The computation steps are:
date_from = date(year=2017, month=2, day=28) - 1 year = date(year=2016, month=2, day=28)
date_from = date_from + 1 day = date(year=2016, month=2, day=29)

It's incorrect because the value of date_from must be date(year=2016, month=3, day=1)

closes odoo/odoo#29416</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Suppose calling get_fiscal_year(date, day=29, month=2) with date(year=2017, month=2, day=28)

The computation steps are:
date_from = date(year=2017, month=2, day=28) - 1 year = date(year=2016, month=2, day=28)
date_from = date_from + 1 day = date(year=2016, month=2, day=29)

It's incorrect because the value of date_from must be date(year=2016, month=3, day=1)

closes odoo/odoo#29416</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] orm: add support to fill temporal holes (read_group)</title>
<updated>2018-08-10T15:21:17+00:00</updated>
<author>
<name>Francois Volral</name>
<email>fvo@odoo.com</email>
</author>
<published>2018-07-09T12:46:45+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=4a40db209706a5adae879a2b4349f873b336ccb9'/>
<id>4a40db209706a5adae879a2b4349f873b336ccb9</id>
<content type='text'>
This commit add an extra parameter 'fill_temporal' to read_group which allows
the orm to add missing groups for date intervals. This is useful for charts.

Suppose that we are in a use case where data are grouped by a date fields
(typically months but it could be another interval) and displayed in a Bar Chart
or a Line Char.
Let's says a request has to group records by month for August, September
and ...December.  If we don't changed anything, we would get a Bar Chart
looking like this :
                                        ___
                              ___      |   |
                             |   |     |   |
                             |   | ___ |   |
                             |   ||   ||   |
                             |___||___||___|
                              Aug  Sep  D
December follows directly after September, it can be unintuitive for the
user, so we change that. We add some fake records for each missing months
between the earliest and the lastest date of the result
                                             ___
                         ___                |   |
                        |   |               |   |
                        |   | ___           |   |
                        |   ||   |          |   |
                        |___||___| ___  ___ |___|
                         Aug  Sep  Oct  Nov  Dec

This commit is part of task #1835644
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit add an extra parameter 'fill_temporal' to read_group which allows
the orm to add missing groups for date intervals. This is useful for charts.

Suppose that we are in a use case where data are grouped by a date fields
(typically months but it could be another interval) and displayed in a Bar Chart
or a Line Char.
Let's says a request has to group records by month for August, September
and ...December.  If we don't changed anything, we would get a Bar Chart
looking like this :
                                        ___
                              ___      |   |
                             |   |     |   |
                             |   | ___ |   |
                             |   ||   ||   |
                             |___||___||___|
                              Aug  Sep  D
December follows directly after September, it can be unintuitive for the
user, so we change that. We add some fake records for each missing months
between the earliest and the lastest date of the result
                                             ___
                         ___                |   |
                        |   |               |   |
                        |   | ___           |   |
                        |   ||   |          |   |
                        |___||___| ___  ___ |___|
                         Aug  Sep  Oct  Nov  Dec

This commit is part of task #1835644
</pre>
</div>
</content>
</entry>
<entry>
<title>[REF] *: use native date/datetime for Date/Datetime fields</title>
<updated>2018-08-06T12:37:19+00:00</updated>
<author>
<name>Raphael Collet</name>
<email>rco@odoo.com</email>
</author>
<published>2018-08-06T12:37:19+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=960360afe478a8f7b9c456721b5591154952a37d'/>
<id>960360afe478a8f7b9c456721b5591154952a37d</id>
<content type='text'>
From this commit onwards, Date fields will return datetime.date objects and Datetime fields will return datetime.datetime objects, this implies a number of things that are clearly explained both in the ORM API for master.

This commit also introduces a number of helper functions for dates and datetimes that are exposed in tools.date_utils and fields.Date[time], explained in the documentation as well.

Task-ID: 47189</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
From this commit onwards, Date fields will return datetime.date objects and Datetime fields will return datetime.datetime objects, this implies a number of things that are clearly explained both in the ORM API for master.

This commit also introduces a number of helper functions for dates and datetimes that are exposed in tools.date_utils and fields.Date[time], explained in the documentation as well.

Task-ID: 47189</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] account: add account.fiscalyear model</title>
<updated>2018-05-30T16:28:13+00:00</updated>
<author>
<name>Laurent Smet</name>
<email>las@openerp.com</email>
</author>
<published>2018-05-30T13:20:45+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=dfde326e7532e8ddbe34a3ddf698f6a556e3cfa5'/>
<id>dfde326e7532e8ddbe34a3ddf698f6a556e3cfa5</id>
<content type='text'>
In order to improve the fiscal year management, we allow the user to define custom fiscal years
    using the account.fiscalyear model.

Was task: https://www.odoo.com/web#id=39878&amp;view_type=form&amp;model=project.task&amp;menu_id=
Was PR #20936
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In order to improve the fiscal year management, we allow the user to define custom fiscal years
    using the account.fiscalyear model.

Was task: https://www.odoo.com/web#id=39878&amp;view_type=form&amp;model=project.task&amp;menu_id=
Was PR #20936
</pre>
</div>
</content>
</entry>
</feed>
