Skip to content

[IMP] controllers#497

Open
cammarosano wants to merge 18 commits intoalphafrom
alpha-request_type-rcdl
Open

[IMP] controllers#497
cammarosano wants to merge 18 commits intoalphafrom
alpha-request_type-rcdl

Conversation

@cammarosano
Copy link
Collaborator

@cammarosano cammarosano commented Dec 3, 2025

This PR adds some missing features related to controllers.

  • request now evaluates to Request class
  • request.env now evaluates to Environment | None
  • subscript on request's env is now supported. E.g. request.env["res.partner"] evaluates to the model

Next steps:
In a Controller, self.env still does not work, as env is a property (which simply returns request.env), and properties are not resolved to their return types.
Support for resolving property types is introduced by #511, which should then:

  • enable self.env in a Controller class
  • enable request.env before 15.3, in which request is an instance of WebRequest, which in turn has env as a property.

@github-actions
Copy link

github-actions bot commented Dec 3, 2025

⚠️ A 'println!(' statement was found in the commit. Please ensure debug statements are removed before merging.

@cammarosano cammarosano force-pushed the alpha-request_type-rcdl branch 2 times, most recently from 1229e40 to c9ba24d Compare December 3, 2025 14:40
@cammarosano cammarosano self-assigned this Dec 3, 2025
@cammarosano cammarosano added enhancement New feature or request tests labels Dec 3, 2025
@cammarosano cammarosano force-pushed the alpha-request_type-rcdl branch 3 times, most recently from 8794251 to 80b805c Compare December 12, 2025 11:01
@cammarosano cammarosano changed the title request.env [IMP] controllers Dec 12, 2025
@cammarosano cammarosano requested a review from fda-odoo December 12, 2025 11:25
@cammarosano
Copy link
Collaborator Author

cammarosano commented Jan 13, 2026

I've just realized that the 2nd commit in this PR handles the same issue as @mmahrouss 's PR: #488
Dropping it. For the record: 80b805c.

CachedModel is not required to define Odoo models, so we should not
fail to detect models if CachedModel is not found in the Odoo source code.

Treat `Model` and `TransientModel` similarly.
only exit if `BaseModel` does not exist.
While validating search domain, for relational
fields, i.e. "m2ofield.normalfield", we should
check all the symbols m2ofield on the model, not
just one, so we set true on get member symbol
We are trying to do that by checking _register = False.
The check was failing because we handled only one evaluation.
However, in latest versions we also have a type hint, which is its own evaluation.
For that, we implement here a smarter search that only looks are evaluations with values.
In that case, we should be more generic in catching cases.
Consider using this as the check, instead of checking symbol trees
mmahrouss and others added 6 commits January 27, 2026 13:22
Check if class model is in a module, otherwise do not mark it as a model
This is to avoid crashing later due to the class not being in a model.
The crash to avoid is in `core.model.Model.get_symbols`
The base model's search method should have an evaluation of
EvaluationSymbolPtr::SELF.

This used to be the case, but it got lost in a refactor ([1]).

[1]: ca26c3e
Before we were checking if inverse_name arg
points to a M2O field, but it can also be a
Many2oneReference

Fixed false positives for OLS03022
@cammarosano cammarosano force-pushed the alpha-request_type-rcdl branch from 80b805c to 783a486 Compare January 27, 2026 13:53
__init_subclass__ and __class_getitem__ have a special behavior
where they are implicitly classmethods without the decorator
This is added here to avoid, for example, wrong diagnostics
Fix arg index to account for is on instance if it is true
@cammarosano
Copy link
Collaborator Author

cammarosano commented Jan 27, 2026

This PR must be adapted to odoo/odoo#240683, that moves request (and Request) from http.py to requestlib.py
Edit: done.

@cammarosano cammarosano marked this pull request as draft January 27, 2026 16:30
@cammarosano cammarosano force-pushed the alpha-request_type-rcdl branch from 783a486 to 752b720 Compare January 28, 2026 17:33
- add evaluation for odoo.http.request:
  - up to 15.2: WebRequest class
  - since 15.3: Request class
- add env variable to Request class (15.3+ only, as it already exists as
property before that)
- add evaluation to (Request/WebRequest).env: Environment | None

This allows for better type evaluation in controllers, which use
odoo.http.request extensively.
@cammarosano cammarosano force-pushed the alpha-request_type-rcdl branch from 752b720 to 0d7490c Compare January 28, 2026 17:35
@cammarosano cammarosano marked this pull request as ready for review January 29, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants