A `default_get` for a x2many field can return a new list of commands for one of
its x2many field, like
[[0, 0, {
'groups_id': [[6, 0, [1, 2, 3]]],
}]]
where [1, 2, 3] is a list of existing ids.
This use case was not correctly handled by the BasicModel because
`_makeDefaultRecord` was not recursive.
Closes#22401
When words are too long this may break out of a kanban tile and getting
everywhere.
This is not wanted and the content should be:
- hidden if overflown or
- long words should be wrapped or
- too long content should be ellipsed
The ellipsis is probably the best but this would affect the current
behavior (we would have to specify a max-height which unexpectedly
may be bothersome to currently existing data).
So breaking long words has been choosen in this change.
opw-806278
closes#22435
Let's assume an action with a 'group_by' specified in its context.
Unless another groupby is specified in the search view, the action
groupby must be used. For list views, it was only working for the
first rendering of the view. As soon as it was reloaded, the action
groupby was lost.
For instance, go to Project, click on a project in the dashboard
[the action has 'group_by': 'stage_id' in its context], switch to
list view [the list is correctly grouped by 'stage_id'], reload by
clicking on the view switcher -> the view isn't grouped anymore.
It was actually working by chance on other views because they have
specific handling of the groupby (e.g. the kanban view allows the
attribute 'default_group_by' on its arch), but by default, the
action groupby must always be used at each load/reload if there is
no other groupby specified.
This rev. restores the behavior of saas-15, before the new views.
In 60d9f6fe the ir.default replaced uses of ir.values.
But the [ir.default].set user_id has opposite meaning to
[ir.values].set_default for_all_users.
This was not taken into account when adapting javascript in 791152a87
and this commit fixes that.
opw-805871
closes#22437
With attribute 'on_create="quick_create"' on the arch's root node,
kanban views open the quick create widget in the first column when
the user clicks on 'Create' (in the control panel), if the view
is grouped and if there is at least one column. However, this
column may be folded.
Before this rev., the quick create was inserted into the folded
column, which didn't look amazing. This rev. first toggles the
column before inserting the quick create.
Before this commit, when having a kanban within a dashboard and clicking on an action button,
the action was not triggered, instead, the board form view triggered 'save' on the board model
leading to a server side traceback
After this commit, the action button triggers the demanded one and only this one.
OPW 805707
closes#22191closes#22371
Before this rev., it crashed when the user used the quick create
to create several records (very quickly, or on a slow network),
e.g. on crm.lead (there must be a date field on the kanban record
to reproduce the crash).
The crash occurred when the 'read' RPCs for the created records
return misordered. For instance:
1) 'name_create' record 1 (called and returned)
2) call 'read' for record 1
3) 'name_create' record 2 (called and returned)
4) call 'read' for record 2
5) 'read' for record 2 returns
6) 'read' for record 1 returns
At step 5, the kanban column was updated with the new state, but
this state already contained record 1, which wasn't fetched yet.
This rev. ensures that the created records are added to the state
once they are fetched and ready to be displayed, not before.
Introduce back part of `formatBinary` that was reverted with 7813a8e7.
When an image is unset, the value was `false` which would end up with a
bin_size of `NaN Bytes` which would end up displaying an error image
with source `data:image/png;base64,NaN Bytes`.
This commit get back a previous behavior so the bin_size when the
attachment does not exist is an empty string (so: '').
opw-805542
closes#22348
When creating a record with many default values, it could happen that
the number of ids returned by the default get (or onchange) exceeds the
limit for the form view.
For example, we can see the issue in the expenses list view. We can
increase the limit in the pager, to a value higher than 40. Then,
clicking on select all, then on 'Submit to manager' in the action menu
will result in a traceback.
The Submit to manager action will trigger a new action with a context key
'active_ids' with a large number of ids. After that, the web client
will execute the server actions, which will return a new action with a
context key 'default_expense_line_ids' with a bunch of ids. Then, it
will attempt to create a form view. This will call the
makeDefaultRecord method in the basic model. This method will generate
the commands for the one2many, for all ids, but will only load the 40
first sub records. After, it will attempt to apply the onchanges, with
some code that assumes that all operations of type 'ADD' correspond to a
local datapoint.
In this commit, we fix the code to properly work with operations of type
ADD with a res_id, but with no id. In that case, we simply generate a
command 'LINK_TO', since the value has not been changed.
opw 804370
When fetching x2manys in a x2many, the basic model did not properly sort
the internal data structure before fetching the data. This is usually
not an issue, except when we have an order which is different from the
order of the res_ids. In that case, it can cause crash in some
conditions, because the results from the fetchx2manybatched were applied
to the wrong datapoint.
To reproduce this issue, some specific conditions needs to be met. I
think that it is easier to refer to the test, instead of trying to
explain that.
In this commit, we properly sort the data at the correct place. Note
that this probably solves a bunch of other related issues, caused by the
fact that the internal structure was corrupted.
Cleaning dead code from these commits that have been reverted:
41fe7f9d1113d026b226b136b4477aaaf9f1f638#diff-54fd886cc58f994ad518ee72df4d3edeR50
2a5488619da22cfd901963dd141e722b195e82ab#diff-f96b339a9374f74489f1f98755e9787bL9253
41fe7f9d1113d026b226b136b4477aaaf9f1f638#diff-86d6d41b5bb7499bf055258d05549d59R3111
With these final changes, we hope to stop the many issues that have occured with
binary fields, from these commits:
255e8ca3d97813a8e71441fe7f9d112a5488619d
What remains is the format of binary fields in list views without widgets,
which shows the bin_size instead of the base64 string representation...
... Rest assured, the computation is in JS, so there are no 'bin_size'
shenaningans!
Revision on 41fe7f9d11
This commit intended to reduce the network load when reading records with
binary fields. This was made possible by enforcing the contextual key
`bin_size` to be set for records with binary fields.
However, it is causing some issues (see #22222, #22231) which are:
- write with bin_size:true generates a traceback
- read/search_read with bin_size:true breaks some images
on some views (e.g. base.view_partner_form)
Since the problems outweight the gain of these changes, we revert them.
Field widgets now have a key 'context' that let them
extend the context of the dataPoint (e.g. list).
In particular, widgets on binary fields enforce the contextual
item {bin_size: True}, so that the server gives the size of the
binary field as its value, instead of its content.
This change on binary fields reduces network load when accessing
a view with binary fields.
Revert partially 255e8ca3d9
Removed widget 'download_link', as it was a sub-version of widget 'binary':
it did the exact same thing (representation of binary fields by means of a download link)
in a much better-looking way (download icon + filename as text of the download link,
instead of just a download link with text "Download").
Also, the values of binary fields might be already a human-readable binsize (e.g. 2.52 MBs),
instead of its plain textual string representation in base64:
The contextual parameter 'bin_size', when set to true, does not download the data of binary fields.
As a consequence, the server provides the sizes of the binary, instead of their value.
- In some languages the kanban images are not displayed because of a bug in human_size method in JS.
This method translates the Unit Size for data and strip with the string with a comma as separator.
When the translatation contains spaces after the commas (like in the French translation), there is extra spaces in the final result.
This then cause an issue with the method is_bin_size that expects a unique space between the value and its unit.
Resulting in a bug in the method 'kanban_image'.
opw #804973#804970#804648
For kanban views with attribute 'on_create="quick_create' set on
their root node, clicking on 'Create' in the control panel should
open the quick create widget in the first column if the view is
grouped and if there is at least one column displayed.
It was working as expected, except when there were no record yet.
This was because the kanban controller used the 'state.count'
attribute of the state (which indicates the total number of records
in the group), whereas it should have used 'state.data.length'
(which is the number of columns).
Before this rev., when quick creating a record in a grouped kanban
view, the quick create widget wasn't automatically re-opened, which
didn't allow the user to quickly create several records in a row
(without clicking each time on the '+').
This desired behavior had been broken by rev. 1d34e26, which aimed
to properly reload the kanban column when a record was created
(e.g. column counter, progress bar...).
When we have a form view with a one2many with an onchange, and with
lines which contains a x2many, and more lines that the limit (so more
than one page), and the read is not in the same order as what is
displayed because we have a widget=handle, then we might have a problem
when we delete one of the lines, if the onchanges tries to change the
x2many.
This is due to the fact that the order of the basicmodel datapoint is
not preserved by the various operations going around. I think that we
may still have a few other issues of this type, but it is actually quite
difficult to establish.
In any case, this situation is now properly handled.
opw 804530
Binary fields were simply shown simply by their textual representation in list views,
e.g. the base64 string.
There was no formatter for binary fields, therefore it has been implemented so that
it displays its estimated size.
Binary fields in list views had a download link in v10.0.
We provide this feature back by means of a widget called 'download_link'.
It is also possible to define an option to set the field name having the filename as its value.
Example:
<tree>
<field name="fname"/>
<field name="datas" widget="download_link" options="{'filename': 'fname'}"/>
</tree>
with the following record: {fname: 'document.txt', datas: 'Cg=='},
we get a file named "document.txt" by clicking on the download link.
Closes#21996
For actions executed in dialogs (target='new'), a DebugManager
is instantiated and appended to the dialog's header (div with
classname 'modal-header').
However, in the full composer dialog (in a chatter, click on
'Send message', and then click on the expand icon), there are
more than one element matching the selector '.modal-header',
because it also occurs in the html generated by summernote.
In this case, the widget's $el is cloned and appended to each
element of the JQuery nodeset matching the given selector, but
widget.$el only refers to one of those. So when it isn't the one
appended in the real dialog's header, the debug manager remains
empty as the widget isn't able to populate it correctly.
This bug appeared with rev. 5f1ef09, as before it, the debug
manager was appended to the dialog before its content.
Issue: create 60 lines in ordered x2many with the same value (0) for the order
field and make a change ; the displayed records will be switched.
The problem appears because the sorting function is not stable and the
records with the same values can change place (hence change page), which is
quite disturbing for the user.
Two attempts of dealing with sorting (and resequencing) in tabbed (multi-pages)
x2many editable lists (see odoo/odoo@c2563db and odoo/odoo@983c7ae) have been
previously done, using a static attribute (`keepChangesUnsorted`) on the
datapoint.
This solution sadly only covers both cases separately, not if they are combined.
Morever, onchanges were not correctly managed in neither of these two cases.
A new approach is used here, by "freezing" and "unfreezing" the datapoint when
needed, which is more flexible.
Some modifications have been introduced:
- when ordering a x2many, all records are now considered (and not only the
records on the current page) ; an additional read is thus done on the sorted
field for all records in the x2many relation
- `setSort` is now asynchronous as a `read` might be needed
In many cases, we allow class and style attributes in the arch of a
view. However, it did not work in a list view, and there is not really
a good reason for that (only cost is a few runtime checks).
So, with this commit, we allow those attributes in list views (and
x2manys obviously).
However, note that there is a subtle (maybe slightly confusing)
behavior: when a list renderer is in 'readonly' mode, it does not
actually instantiate any field widgets. In that case, it optimizes the
rendering by putting only the formatted value inside a cell:
<td>some value</td>
So, in that case, the only valid target for the attributes is the td:
<td class="hello">some value</td>
But when we are in edit mode, we actually have a field widget inside a
td:
<td><input>some value</input></td>
And in that case, the natural home for the attributes is the field
widget. This is quite important, because this is the way attributes are
done in the form view, and we do not want different behaviour.
<td><input class="hello">some value</input></td>
Adapt commit b92aaf1 for framework changes in saas-16.
That commit made Many2ManyTagsEmail widget display name_get gotten
dynamically. This allow to have 'show_email' context key working and
having the email displayed.
This commit use the new views (as of saas-16) to do the same change.
opw-801558
fixes#21812fixes#21523closes#21969
In v10, a `Float` field with `widget="monetary"` option uses the decimal
precision of the field. In v11, however, it uses the decimal precision
of the currency. However, in many cases `widget="monetary"` is used in
the sole purpose of displaying the currency symbol. The precision of the
field sould be kept.
This commit introduces the support of the decimal precision of the field
for this specific use case thanks to the `field_digits` option:
```
<field name="pouet" widget="monetary" options="{'field_digits': True}" />
```
If such an option is used, the field precision will prevail over the
currency precision.
Related to #21686
opw-800279
When there are too many labels to display on the x-axis, they overlap
and it simply becomes unreadable. By slightly rotating them, this can be
avoided in most cases.
Back-port of this commit 388e258ce8
opw:802925
[FIX] web: Fix column_invisible issue
This commit fixes an issue with the column_invisible attribute.
When we choose product variant for BOM for any particular product,
at that time from the BOM Lines column "Apply on Variants" is hidden,
but when we unset product variant from BOM Form,
at that time the column 'Variants" set to visible. but in this case, it is set to hidden always.
PR 21693, OPW 779555