- Kanban colors and tag colors are now the same
- Tag color 0 (default) is now back to be the invisible kanban one
- Same colorpicker for kanban and tags
- Define correct number of colors (12 not 13)
- Color 0 should be a neutral one (gray)
- ...
Before this rev., onchange specs where only computed up to level
2 (i.e. for fields inside x2many fields). So basically, if there
were a one2many list inside a one2many (e.g. which opens in a
form view), the fields of that inner one2many list weren't added
to the specs, and it could lead to unexpected responses from the
server (like erasing the changes made on the inner one2many
records).
Closes#19600
The o_row class mechanism is supposed to be used to put another
element next to a field, like a button for example. However,
in the case of phone and email field, the o_text_overflow hack
gets in the way.
The problem that o_text_overflow is trying to solve is when you
have a long email, the table used to display the form view fields
tends to use very long cells (td) so it can display the whole email
address. This behavior completely breaks the form view, even though
the email address is clearly set to wrap in css. The o_text_overflow
class is a hack that forces the table to think that the email is
small, then defaulting to the width 50% css rules. If the email is
too long, it is correctly wrapped inside the cell, without breaking
the form view layout.
However, when we need to add a button next to those fields, this
hack gets in the way of the o_row class css rules, completely
wrecking it. We looked for a fix with qsm-odoo for hours but were
unable to find one that did not require a complete rewrite of the
form view css rules. In the end, we decided to remove the hack from
the phone field and keep it on the email field, as we think it is
less common to have a very long phone number than to have a very
long email.
Before this commit, a field handled with a widget url was given its value (href) as its text, fully displaying the url.
Moreover, the display was odd and did not match that of buttons
After this commit, if the field contains a text attribute, we use is as the text of the link.
The link also correctly displays and looks like a button (in a form view)
Of course, a test for this new field widget feature is implemented
closes#19587
Before this commit, the web client did not properly destroy field
widgets when updating a one2many after an onchange. This is rarely an
issue, because in general, there are no other field widgets besides the
row currently in edition. However, if we specify explicitely a widget,
or if we use a custom widget, it may be a problem.
Go to General Settings, click on 'Change Document Template', and
in the opened dialog, click on a template.
Before this rev., it automatically closed the dialog, which was
not really convenient.
This rev. introduces a new field widget (image_selection) for
this use case, and ensures that the dialog doesn't close when
a template is selected.
Test written by @mba-odoo
In this commit, we make sure that if an onchange in a x2many modifies
another line, then the new data is properly shown. This is quite
tricky, because the field x2many ignores the full extent of the changes.
Also, we obviously want to preserve the editing state (focused field,
...)
So, what we actually do is to rerender the full x2many (minus the new
line) to make sure that we preserve the correct row order.
Note: thanks to MGE for the test and some preliminary work.
Since the rev. https://github.com/odoo/odoo/commit/2728fe1ec1ac7e99819d0f30f29a1814b00c82a4 the onchange create
command (0) send the virtual id as second argument. This argument is sent
back from the server and can then be used by the client.
As the client knows the virtual id, it can easily reuse the datapoint created
for this record and thus avoid creating a new one.
Creating a new datapoint can potentially lead to problems if the record has
for example specialData, that won't be kept.
The FieldDomain allows to open a list in a dialog to display the
records matching the current domain. In this dialog, clicking on
a record should do nothing (this was the behavior before the new
views).
Before this rev., it actually tried to open the record and it
produced a crash.
The `upgrade_boolean` widget should display an `Enterprise` label next to it.
There is however an issue when a `label` is specified for this field. In this case,
the `Enterprise` label should be placed next to the field label (and not the field
itself).
The easiest solution would have been to instantiate the field widget with its label,
but this can't work because the field widget is instantiated before its label.
We thus re-render the widget after its label creation.
The server postproccess the view to add attributes on many2one fields, i.e.
`can_create` and `can_write`, according to access rights.
These attributes are parsed by the client as string but should also be parsed by
the many2one when evaluating them.
The mock server has also been adapted to set these attributes.
* crm, project
Add a new feature which allows to put a progressbar in the kanban
columns. The progressbar shows with the same color the amount of
records whose value of a given field are the same in the column.
It also indicate the sum of another given field or simply the total
number of records. It also allows to subgroup the column content.
To define a progressbar, add this as a direct child of the kanban
arch:
<progressbar field="<name of the field to use for subgroups>"
colors="{<one possible value for the above field>: <success, warning or danger>, ...}"
sum="<name of the field to sum or nothing to use total number of records>"/>
Also:
- Properly update record model data's parentID when moving a record
- ...
When selecting a partner in the reconciliation widget, using the SelectCreateDialog
(Search More), the partner wasn't correctly displayed.
This was due to a difference between the change format of the many2one ; when using
the dialog, only the `id` is sent (while the `id` and `display_name` are sent when
using the many2one dropdown).
These two behaviours are now standardized and both now send `id` and `display_name`.
It has the advantage of sparing some `name_get`s called by the model because the
`display_name` was missing.
This change implies some refactoring where the SelectCreateDialog was used.
The server response to an `onchange` on a one2many is a list of
commands. In case of one2many update (command 1), the server
returns all fields (and not only the modified ones).
When saving the record, this is the client responsability to
specify which fields really changed.
Before this commit, all fields were sent at `write` and not only
the changed ones. This was causing issues when the user couldn't
write on the field ; an error was triggered even though the user
didn't change anything.
To fix this, we only tag as changed (in the datapoint `_changes`
attribute) the fields that have a different value after the onchange.
- datepicker doesn't default to current date by default
- date string in the input is now selected when clicking the field
- adapted the existing tests to the new changes
When a x2m field is modified, the 'save' rpc doesn't send 'False' as second
argument of the special command that manipulate the set of records.
From now on, the virtual id of the record is sent to the server as second
argument. This commit fixes the tests making the assumption that 'False'
was sent.
In an embedded editable list view with the widget `handle`, resequencing a
record and try to edit it afterwards won't work. The selected record isn't the
correct one, as if the resequencing had no impact.
To make this work, the list datapoint needs to be ordered by the field with the
widget `handle` ; if it isn't, resequencing the records won't change the x2many
data order but the list view expects the same order.
Before this commit, we did not really handle gracefully editing a
one2many with many records. The main issue is that if the user was not
on the last page, creating a new record added it to the last page, which
is confusing and actually a bad idea for records with required fields.
This fix requires a way to track the current changes (because we do not
display the current state of the form view: the new record is displayed
in the first page, but is actually added at the end of the dataset).
Note that this probably does not solve all issues with pagination. This
is a quite delicate problem. We will add tests and fixes as needed.
When an onchange modifies an x2many field, the line on which the user
works remains in editable mode and the cursor is returned to the same
position.
The second argument of create command is a reference used to reactivate
the edited line.
The problem occurred on form views with an x2many field with a
default value containing CREATE commands, i.e. when opening such
a form view in create mode, the x2many field is pre-filled with
some (non-existing yet) subrecords.
If the user then edited those subrecords, and then clicked on
'Save' to create the main record, an 'UPDATE' command was sent
alongside the 'CREATE' one for the x2many, and the id of the
'UPDATE' command was a virtual id (as the subrecord didn't exist
yet), and it crashed.
This could happen in MRP:
- Enable lots in Iventory
- Choose a product which is a component of another (through mrp bom)
- Set this product as tracked by lot
- Set this product inventory quantity to 0
- Create a new manufacturing order for the product for which it is a
component
- Click on "Check Availability"
- click on Produce: the many2many already contains a subrecord
- edit the lot field of that subrecord
- click on 'Record Production'
Before this rev., when the value of a field with widget='domain'
was false, the search_count RPC made to display the number of
records matching the domain crashed, and the widget displayed that
the domain was invalid. This rev. adds a fallback on [] when the
domain is false.
In grouped list view, when a pager is clicked inside a group, a
'load' event is triggered to reload the data with the new offset.
The event is handled by the list's controller.
However, when the list is in the modal, the event must be stop
propagated by the controller of the modal, so that it doesn't go
up to the controller of the view displayed behind the modal. It
happens for example by reproducing the following steps:
- go to Lunch
- add a line
- search more products
- group by vendor in the modal
- unfold a group
- click on the pager (the group must contain more than 80 records)
Before this rev., it crashed because the controller of the form
view tried to handle the event.
Before this commit, a list containing a handle widget would only display
the handles associated with non-zero integer values. This is due to the
fact that unset fields are hidden in Odoo, while a field is by default
considered 'defined' if its value is truthy.
We override the isSet method for the handle widget to always return
true. This tells the handle widget that the associated integer value is
always defined, thereby ensuring that the handle will always be shown.
The field 'display_name' is automatically added to the list of
fields to fetch when fetching a record. Before this rev., its
value was also sent alongside the fields in the view for onchange
RPCs. It shouldn't: only the fields in the view should be sent.
It produced a weird bug in the res.partner form view: open a
contact (company), add a sub-contact, save -> the display_name of
the contact was then '' (and 'Contacts' was displayed in the
breadcrumbs instead of the display_name of the opened contact).
This is because 'display_name' was sent to the onchange, which
returned '' as value (because of another bug python side). So as
it's value changed, when saving, the new display_name was sent to
the server (even if this field was actually readonly).
Before this rev., we also always fetched 'display_name' when
fetching list of records (read or search_read). This wasn't a bug
per se, but it might be a computed field, and it isn't necessary,
so we stop fetching it in that case if it isn't in the view (as
it was done in saas-15, before the new views).
Before this commit, it could happen that a x2many field was considered
invalid, which prevent triggering onchanges, even though each of its
required fields are properly set. Here is such a scenario:
We have a one2many field something_ids in a form view, with an inline
tree view, which contains a field X. The field X is required on the
model, but marked required="0" in the inline view.
In that case, we incorrectly evaluated the required modifiers: since the
attrs did not contain the required attribute, we fell back on the
field_get value, which is true in this case. But this is not correct,
the fieldviewget already computed the actual modifiers and took into
account the fact that it was overridden. We need to only look at the
modifiers.
The reference widget is also meant to be used on a char field, not only on a
reference field.
The rev. https://github.com/odoo/odoo/commit/a4e30a1b43d0b9acd76508d9e6c466cd1dbdffab removed
the use of `field_utils.format.many2one` and replaced it by `_formatValue` to
support this use case.
The replacement wasn't complete as some occurences was remaining (in reset),
which led to traceback when the widget was reset (impossible to create an
External Identifier anymore).
Also, the reference `_formatValue` wasn't correct as it was displaying the
record `display_name` and not the reference field value ; this only makes sense
for the External Identifier as its display name is the reference field value but
it doesn't make any sense for other reference field.
Last but not least, this commit implements the `onchange` and `default_get` for
the reference field.