<feed xmlns='http://www.w3.org/2005/Atom'>
<title>Odoo/odoo/addons/test_new_api/tests/test_onchange.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: computed editable one2many field with a domain</title>
<updated>2021-05-19T11:41:11+00:00</updated>
<author>
<name>Raphael Collet</name>
<email>rco@odoo.com</email>
</author>
<published>2021-05-12T14:02:33+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=1c39814bd729cc08882f1545c7d88b0592e63f9a'/>
<id>1c39814bd729cc08882f1545c7d88b0592e63f9a</id>
<content type='text'>
Manually adding a line should not trigger the computation of the field,
just like modifying the line fields that occur in the field's domain.
In other words, the dependencies of the field should be limited to the
ones declared on field or its compute method.

closes odoo/odoo#71027

X-original-commit: 9000a50582db827ff12acdecf8ef91749122452d
Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Manually adding a line should not trigger the computation of the field,
just like modifying the line fields that occur in the field's domain.
In other words, the dependencies of the field should be limited to the
ones declared on field or its compute method.

closes odoo/odoo#71027

X-original-commit: 9000a50582db827ff12acdecf8ef91749122452d
Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] core: compute editable field with a default should not recompute</title>
<updated>2021-01-13T08:12:53+00:00</updated>
<author>
<name>Raphael Collet</name>
<email>rco@odoo.com</email>
</author>
<published>2021-01-11T15:49:38+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=2ccc735253405b03927e2b08eab57427e65e4050'/>
<id>2ccc735253405b03927e2b08eab57427e65e4050</id>
<content type='text'>
Consider a model with a field F and a computed editable field G that
depends on F.  Assume we open a form view, and both F and G have a
default value.  The first onchange should return F and G with their
respective default values.  In other words, the field G should not be
recomputed even if its dependency F was assigned a default value.

The use-case that showed the issue is batch payments.  When adding a new
payment in the one2many field of a batch, the new payment should use the
batch's payment method by default.  The default value for the payment's
method is assigned by context on the one2many field in the view.  Before
this patch, the new payment's method was given by the computation of the
field, and its default value was ignored.

Side note: another test was fixed, but that's because the test was not
consistent with the way Odoo 14.0 manages defaults and onchanges.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Consider a model with a field F and a computed editable field G that
depends on F.  Assume we open a form view, and both F and G have a
default value.  The first onchange should return F and G with their
respective default values.  In other words, the field G should not be
recomputed even if its dependency F was assigned a default value.

The use-case that showed the issue is batch payments.  When adding a new
payment in the one2many field of a batch, the new payment should use the
batch's payment method by default.  The default value for the payment's
method is assigned by context on the one2many field in the view.  Before
this patch, the new payment's method was given by the computation of the
field, and its default value was ignored.

Side note: another test was fixed, but that's because the test was not
consistent with the way Odoo 14.0 manages defaults and onchanges.</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] core: avoid duplicate onchanges</title>
<updated>2021-01-04T09:59:50+00:00</updated>
<author>
<name>svs-odoo</name>
<email>svs@odoo.com</email>
</author>
<published>2020-12-28T15:45:41+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=cf2b0a505c117a50a91fa022bc1d6bf1eb6d9f77'/>
<id>cf2b0a505c117a50a91fa022bc1d6bf1eb6d9f77</id>
<content type='text'>
When performing the onchange for the first time on a new record, if a
field has a default value, it could be two times in the `todo` field
list to compute.

closes odoo/odoo#63983

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When performing the onchange for the first time on a new record, if a
field has a default value, it could be two times in the `todo` field
list to compute.

closes odoo/odoo#63983

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] core: first onchange should always compute fields</title>
<updated>2020-12-21T12:12:53+00:00</updated>
<author>
<name>Raphael Collet</name>
<email>rco@odoo.com</email>
</author>
<published>2020-12-21T08:45:51+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=45422d56bce413b8577f1784e10dd22ede93c751'/>
<id>45422d56bce413b8577f1784e10dd22ede93c751</id>
<content type='text'>
When a form view is opened, the first call to `onchange` should always
compute fields, even if their dependencies have no default value.  Make
sure it is the case for main records, and for records inside one2many
fields.  The latter case was actually not working as expected.

closes odoo/odoo#63627

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When a form view is opened, the first call to `onchange` should always
compute fields, even if their dependencies have no default value.  Make
sure it is the case for main records, and for records inside one2many
fields.  The latter case was actually not working as expected.

closes odoo/odoo#63627

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] core: invalidation of computed editable field in one2many</title>
<updated>2020-12-02T11:45:17+00:00</updated>
<author>
<name>Laurent Smet</name>
<email>las@odoo.com</email>
</author>
<published>2020-11-20T08:00:31+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=5279a08a005bacee4ecd76cc189d8ce65c8e600c'/>
<id>5279a08a005bacee4ecd76cc189d8ce65c8e600c</id>
<content type='text'>
This fixes the issue introduced by revision fd50ba9fb838067fab0b920470cf79b9c94d785c

The way computed fields are invalidated depends on the order of the dict
passed as a parameter to method onchange().  This causes some unexpected
behavior when dealing with computed editable fields: the user loses the
value in that field because of the onchange.

Explanation: during the onchange, the modified field is cached by

    record._update_cache(changed_values, validate=True)

If the field is a one2many, 'value' contains an update command for each
modified line.  Because of 'validate=True', the assignment triggers
field computations on the lines, which are already handled by another
call to onchange().  In case anything on the parent model modifies some
line, the whole one2many values are returned to the user, and
accidentally recomputed fields show up in the interface.

closes odoo/odoo#62060

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes the issue introduced by revision fd50ba9fb838067fab0b920470cf79b9c94d785c

The way computed fields are invalidated depends on the order of the dict
passed as a parameter to method onchange().  This causes some unexpected
behavior when dealing with computed editable fields: the user loses the
value in that field because of the onchange.

Explanation: during the onchange, the modified field is cached by

    record._update_cache(changed_values, validate=True)

If the field is a one2many, 'value' contains an update command for each
modified line.  Because of 'validate=True', the assignment triggers
field computations on the lines, which are already handled by another
call to onchange().  In case anything on the parent model modifies some
line, the whole one2many values are returned to the user, and
accidentally recomputed fields show up in the interface.

closes odoo/odoo#62060

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] core: first onchange on new one2many line</title>
<updated>2020-08-20T13:39:04+00:00</updated>
<author>
<name>Raphael Collet</name>
<email>rco@odoo.com</email>
</author>
<published>2019-10-28T14:59:27+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=3e91fa1dbf9056f1557ff7a747ba3407e851b18e'/>
<id>3e91fa1dbf9056f1557ff7a747ba3407e851b18e</id>
<content type='text'>
Consider models `M` and `L`, with a one2many field `M.l_ids` with
inverse `L.m_id`.  Consider also a computed field `L.foo` that depends
on `L.m_id`.

The field `L.foo` is not computed correctly by `onchange` on a new line
in the form view of `M`: its value is forced to `False` because it has
no default, and is not recomputed by `onchange` since the field `L.m_id`
is never triggered an `onchange`.

Modify the method `onchange` to not force fields without a default to
`False`, and return all fields.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Consider models `M` and `L`, with a one2many field `M.l_ids` with
inverse `L.m_id`.  Consider also a computed field `L.foo` that depends
on `L.m_id`.

The field `L.foo` is not computed correctly by `onchange` on a new line
in the form view of `M`: its value is forced to `False` because it has
no default, and is not recomputed by `onchange` since the field `L.m_id`
is never triggered an `onchange`.

Modify the method `onchange` to not force fields without a default to
`False`, and return all fields.</pre>
</div>
</content>
</entry>
<entry>
<title>[REM] *: remove various unused import shims</title>
<updated>2020-04-01T12:45:40+00:00</updated>
<author>
<name>Adrian Torres</name>
<email>adt@odoo.com</email>
</author>
<published>2020-02-04T11:57:37+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=5952928b42de348c91cc61c9615fbb49e9df4146'/>
<id>5952928b42de348c91cc61c9615fbb49e9df4146</id>
<content type='text'>
Before this commit, a lot of leftover import shims existed in the
codebase for py2-py3 compatibility, these are no longer needed since
Odoo 13.0+ doesn't support Python 2 anymore and is (finally) in EOL.

With this commit, these shims are dropped, making the code cleaner,
easier to read and with one less dependency.

Queue -&gt; queue -&gt; py2-py3 compatibility
xmlrpclib -&gt; xmlrpc.client -&gt; py2-py3 compatibility
ConfigParser -&gt; configparser -&gt; py2-py3 compatibility
itertools.izip_longest -&gt; itertools.zip_longest -&gt; py2-py3 compatibility
urllib -&gt; urllib.request -&gt; py2-py3 compatibility
__builtins__ -&gt; builtins -&gt; py2-py3 compatibility
_winreg -&gt; winreg -&gt; py2-py3 compatibility

mock -&gt; unittest.mock -&gt; merged into CPython

The debian/fedora packages and requirements.txt have been updated accordingly

closes odoo/odoo#44601

Related: odoo/enterprise#8141
Signed-off-by: Xavier Morel (xmo) &lt;xmo@odoo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before this commit, a lot of leftover import shims existed in the
codebase for py2-py3 compatibility, these are no longer needed since
Odoo 13.0+ doesn't support Python 2 anymore and is (finally) in EOL.

With this commit, these shims are dropped, making the code cleaner,
easier to read and with one less dependency.

Queue -&gt; queue -&gt; py2-py3 compatibility
xmlrpclib -&gt; xmlrpc.client -&gt; py2-py3 compatibility
ConfigParser -&gt; configparser -&gt; py2-py3 compatibility
itertools.izip_longest -&gt; itertools.zip_longest -&gt; py2-py3 compatibility
urllib -&gt; urllib.request -&gt; py2-py3 compatibility
__builtins__ -&gt; builtins -&gt; py2-py3 compatibility
_winreg -&gt; winreg -&gt; py2-py3 compatibility

mock -&gt; unittest.mock -&gt; merged into CPython

The debian/fedora packages and requirements.txt have been updated accordingly

closes odoo/odoo#44601

Related: odoo/enterprise#8141
Signed-off-by: Xavier Morel (xmo) &lt;xmo@odoo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[FIX] core: computed fields can be copied if editable</title>
<updated>2020-03-25T17:36:02+00:00</updated>
<author>
<name>Thibault Delavallée</name>
<email>tde@odoo.com</email>
</author>
<published>2020-03-03T15:50:53+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=a1654e59b9a0f07dc659b790171bae2500bd1adc'/>
<id>a1654e59b9a0f07dc659b790171bae2500bd1adc</id>
<content type='text'>
Purpose of this commit is to let computed stored editable fields being
copied if their field class allows it.

Indeed the value of those fields is computed based on some triggers but
can also be updated manually by users.  When copying a record, it makes
sense to consider that this value is what the user expects and allow its
copy, if the original field allows it.  Either it was computed, and
copied value will be correct without having to call computation again
(well, provided all dependencies have been copied, too), or it was
updated and the copied value will be the one the user entered.

Without this fix, an edited field is not copied, and will be recomputed,
which may look like an inconsistent value.

Task ID 2209163

closes odoo/odoo#48383

X-original-commit: 4b274d3b4101fbae154a572cdf40d23838899773
Signed-off-by: Olivier Dony (odo) &lt;odo@openerp.com&gt;
Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
Co-authored-by: Raphael Collet &lt;rco@odoo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Purpose of this commit is to let computed stored editable fields being
copied if their field class allows it.

Indeed the value of those fields is computed based on some triggers but
can also be updated manually by users.  When copying a record, it makes
sense to consider that this value is what the user expects and allow its
copy, if the original field allows it.  Either it was computed, and
copied value will be correct without having to call computation again
(well, provided all dependencies have been copied, too), or it was
updated and the copied value will be the one the user entered.

Without this fix, an edited field is not copied, and will be recomputed,
which may look like an inconsistent value.

Task ID 2209163

closes odoo/odoo#48383

X-original-commit: 4b274d3b4101fbae154a572cdf40d23838899773
Signed-off-by: Olivier Dony (odo) &lt;odo@openerp.com&gt;
Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
Co-authored-by: Raphael Collet &lt;rco@odoo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] core: do not recompute stored field on new record</title>
<updated>2020-03-23T09:04:59+00:00</updated>
<author>
<name>Raphael Collet</name>
<email>rco@odoo.com</email>
</author>
<published>2020-03-10T16:33:05+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=fd50ba9fb838067fab0b920470cf79b9c94d785c'/>
<id>fd50ba9fb838067fab0b920470cf79b9c94d785c</id>
<content type='text'>
The use case is a cache miss of a stored field with compute on a new
record with origin.  The field should be computed only when explicitly
triggered, i.e., when a dependency has been modified.  Otherwise it
should be fetched from the origin record.

closes odoo/odoo#47353

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The use case is a cache miss of a stored field with compute on a new
record with origin.  The field should be computed only when explicitly
triggered, i.e., when a dependency has been modified.  Otherwise it
should be fetched from the origin record.

closes odoo/odoo#47353

Signed-off-by: Raphael Collet (rco) &lt;rco@openerp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[IMP] base/test_*: Adapt tests to work with/without demo data</title>
<updated>2019-11-05T12:08:02+00:00</updated>
<author>
<name>Yannick Tivisse</name>
<email>yti@odoo.com</email>
</author>
<published>2019-11-04T15:22:50+00:00</published>
<link rel='alternate' type='text/html' href='http://erp.ceuconsult.com:9000/Odoo/commit/?id=4aa5ba35afa949098d532189beb4c680dcada2fa'/>
<id>4aa5ba35afa949098d532189beb4c680dcada2fa</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
