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

[16.0] cms_form: migrate to v16 #130

Merged
merged 69 commits into from
Oct 31, 2023
Merged

[16.0] cms_form: migrate to v16 #130

merged 69 commits into from
Oct 31, 2023

Conversation

simahawk
Copy link
Contributor

@simahawk simahawk commented Jul 12, 2023

Depends on:

Most important changes:

Attributes become fields

All attributes that configure a form are now odoo fields.
Fields that are just for configuration/behavior
(meaning that shouldn't be consider in form rendering)
must have the flag form_tech=True.

Default configuration can be set by overriding fields' defaults.
For instance, to declare the model::

form_model_name = fields.Char(default="res.partner")

or to declare which fields to use::

form_model_fields = Serialized(default=("name", "country_id"))

Same story for widgets.

Fields lookup API change

form_fields() and form_fieldsets() are not available anymore.

You must use form.form_fields_get() and form.form_fieldsets_get.

TODO:

  • deep testing
  • adapt templates to modern bootstrap

**Attributes become fields**

All attributes that configure a form are now odoo fields.
Fields that are just for configuration/behavior
(meaning that shouldn't be consider in form rendering)
must have the flag `form_tech=True`.

Default configuration can be set by overriding fields' defaults.
For instance, to declare the model::

    form_model_name = fields.Char(default="res.partner")

or to declare which fields to use::

    form_model_fields = Serialized(default=("name", "country_id"))

Same story for widgets.

**Fields lookup API change**

`form_fields()` and `form_fieldsets()` are not available anymore.

You must use `form.form_fields_get()` and `form.form_fieldsets_get`.
When the transaction is rolled back due to an pg error
use a new env to be able to inject the status message
otherwise a dead request will be used.
You can now use form_widget={...} field attribute
to provide your own widget for the form.
Centralize lookup for attributes via private api
Allows forms to customize the html name of each widget.
Very handy in case you want to combine multiple forms together.
Transform  inputs to list of dict values
To proxy and ease customization of final html value
Do not load any default for main wizard model.
Only step models need preloaded data.
Hide the whole field block.
Fixes 2 issues:
* ensure field tech name matches
* hide the whole block, not just the input
Handy method to load all steps values at once
and merge them.
Original keys should be popped when transformed
Rework file processing so that files come ready from request data.
It's useless to reload defaults when they are already loaded in form_data
or overridden by specific values passed for form_data at form_init.
The field wrapper should toggle the required class.
@simahawk
Copy link
Contributor Author

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-130-by-simahawk-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 5ecf0fd into OCA:16.0 Oct 31, 2023
5 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at be08868. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants