Skip to content

[IMP] html_editor, web_unsplash, website: AI Website Builder tweaks#258133

Closed
Dj0ulo wants to merge 4 commits intoodoo:masterfrom
odoo-dev:master-AI-website-builder-baar
Closed

[IMP] html_editor, web_unsplash, website: AI Website Builder tweaks#258133
Dj0ulo wants to merge 4 commits intoodoo:masterfrom
odoo-dev:master-AI-website-builder-baar

Conversation

@Dj0ulo
Copy link
Copy Markdown
Contributor

@Dj0ulo Dj0ulo commented Apr 8, 2026

Few tweaks for the AI Website Builder assistant enterprise PR: odoo/enterprise#106196

[IMP] web_unsplash: take Unsplash request out of the controller

In ai_website, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

Fix

  • Extract _fetch_unsplash_images into ir.attachment to make it
    callable from other models.
  • Make the requests.get call safer by adding a timeout, filtering the
    payload keys and putting the access key in Authorization header.
  • Replace the useless request variable uses with self
  • Add some constant for the Unsplash ICP keys

[IMP] website: make defineMailModels optional in defineWebsiteModels

In some case, we need to use defineWebsiteModels without defining the
mail models at the same time.

For example, in ai_website we call defineAIModels which is
defining the mail model DiscussChannel differently.

Fix
A new parameter (i.e.includeMailModels) is added to be able to prevent
the call to defineMailModels when needed.

[IMP] html_editor, *: make attachment_create usable in models

*: web_unsplash

Before commit
_attachment_create was a private method in the HTML_Editor
controller that can only be called within a controller context as it
uses the request variable.

After commit
Make attachment_create a standalone function that can be imported and
used from a model such as AI tools in ai_website.

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Apr 8, 2026

Pull request status dashboard

@Dj0ulo Dj0ulo marked this pull request as draft April 8, 2026 14:18
@Dj0ulo Dj0ulo force-pushed the master-AI-website-builder-baar branch 2 times, most recently from 1f1478a to 5cf3c86 Compare April 10, 2026 16:35
@Dj0ulo Dj0ulo changed the title [IMP] web_unsplash: move methods to model [IMP] ai_website: add AI Website Builder assistant Apr 10, 2026
@Dj0ulo Dj0ulo force-pushed the master-AI-website-builder-baar branch 2 times, most recently from 40b7751 to a291a42 Compare April 16, 2026 09:18
Dj0ulo added 3 commits April 16, 2026 13:23
In `ai_website`, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

__Fix__
- Extract `_fetch_unsplash_images` into `ir.attachment` to make it
  callable from other models.
- Make the `requests.get` call safer by adding a timeout, filtering the
  payload keys and putting the access key in `Authorization` header.
- Replace the useless `request` variable uses with `self`
- Add some constant for the Unsplash ICP keys
In some case, we need to use `defineWebsiteModels` without defining the
mail models at the same time.

For example, in `ai_website` we call `defineAIModels` which is
defining the mail model `DiscussChannel` differently.

__Fix__
A new parameter (i.e.`includeMailModels`) is added to be able to prevent
the call to `defineMailModels` when needed.
*: web_unsplash

__Before commit__
`_attachment_create` was a private method in the `HTML_Editor`
controller that can only be called within a controller context as it
uses the `request` variable.

__After commit__
Make `attachment_create` a standalone function that can be imported and
used from a model such as AI tools in `ai_website`.
@Dj0ulo Dj0ulo force-pushed the master-AI-website-builder-baar branch from a291a42 to 49529f7 Compare April 16, 2026 11:25
@Dj0ulo Dj0ulo changed the title [IMP] ai_website: add AI Website Builder assistant [IMP] html_editor, web_unsplash, website: AI Website Builder tweaks Apr 16, 2026
@Dj0ulo Dj0ulo marked this pull request as ready for review April 16, 2026 11:27
Copy link
Copy Markdown
Contributor

@dmo-odoo dmo-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the function move in html_editor, thanks!

@C3POdoo C3POdoo requested review from a team, aab-odoo and jpp-odoo and removed request for a team April 16, 2026 15:37
In AI modules, the agent may take a long time to use the tools and
generate content.

We therefore need to increase the typing timeout to make the user
understand that the AI is still working.

This commit makes the typing timeout duration patchable in order to do
that.
@C3POdoo C3POdoo requested a review from a team April 16, 2026 20:23
@beledouxdenis
Copy link
Copy Markdown
Contributor

addons/web_unsplash/models/ir_attachment.py:47
PY006 🔗:
requests.get(
'https://api.unsplash.com/search/photos/',
params=payload,
headers=headers,
timeout=10,
)

This one is safe: hard-coded URL set, timeout set.

addons/html_editor/controllers/main.py:124
PY006 🔗: requests.head(url, timeout=10)

This one is not ideal: the URL can be arbitrarily set by a portal users, through the route
@route(['/web_editor/attachment/add_url', '/html_editor/attachment/add_url']
which means an SSRF attack is possible.

Indeed, it was already there before.

We had a discussion to let the PR go through, and a change will be done / is planned to do something about that requests.head with an arbitrary URL.

robodoo override=co/security

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Apr 17, 2026

@beledouxdenis you are not allowed to override 'co/security'.

@beledouxdenis
Copy link
Copy Markdown
Contributor

robodoo override=ci/security

@pkyriakou
Copy link
Copy Markdown
Contributor

@robodoo r+

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Apr 17, 2026

@Dj0ulo @pkyriakou because this PR has multiple commits, I need to know how to merge it:

  • merge to merge directly, using the PR as merge commit message
  • rebase-merge to rebase and merge, using the PR as merge commit message
  • rebase-ff to rebase and fast-forward

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Apr 17, 2026

@Dj0ulo @pkyriakou unable to stage: missing merge method

@pkyriakou
Copy link
Copy Markdown
Contributor

@robodoo rebase-ff

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Apr 17, 2026

Merge method set to rebase and fast-forward.

@pkyriakou
Copy link
Copy Markdown
Contributor

@robodoo retry

robodoo pushed a commit that referenced this pull request Apr 18, 2026
In `ai_website`, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

__Fix__
- Extract `_fetch_unsplash_images` into `ir.attachment` to make it
  callable from other models.
- Make the `requests.get` call safer by adding a timeout, filtering the
  payload keys and putting the access key in `Authorization` header.
- Replace the useless `request` variable uses with `self`
- Add some constant for the Unsplash ICP keys

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In some case, we need to use `defineWebsiteModels` without defining the
mail models at the same time.

For example, in `ai_website` we call `defineAIModels` which is
defining the mail model `DiscussChannel` differently.

__Fix__
A new parameter (i.e.`includeMailModels`) is added to be able to prevent
the call to `defineMailModels` when needed.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
*: web_unsplash

__Before commit__
`_attachment_create` was a private method in the `HTML_Editor`
controller that can only be called within a controller context as it
uses the `request` variable.

__After commit__
Make `attachment_create` a standalone function that can be imported and
used from a model such as AI tools in `ai_website`.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In AI modules, the agent may take a long time to use the tools and
generate content.

We therefore need to increase the typing timeout to make the user
understand that the AI is still working.

This commit makes the typing timeout duration patchable in order to do
that.

closes #258133

Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In `ai_website`, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

__Fix__
- Extract `_fetch_unsplash_images` into `ir.attachment` to make it
  callable from other models.
- Make the `requests.get` call safer by adding a timeout, filtering the
  payload keys and putting the access key in `Authorization` header.
- Replace the useless `request` variable uses with `self`
- Add some constant for the Unsplash ICP keys

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In some case, we need to use `defineWebsiteModels` without defining the
mail models at the same time.

For example, in `ai_website` we call `defineAIModels` which is
defining the mail model `DiscussChannel` differently.

__Fix__
A new parameter (i.e.`includeMailModels`) is added to be able to prevent
the call to `defineMailModels` when needed.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
*: web_unsplash

__Before commit__
`_attachment_create` was a private method in the `HTML_Editor`
controller that can only be called within a controller context as it
uses the `request` variable.

__After commit__
Make `attachment_create` a standalone function that can be imported and
used from a model such as AI tools in `ai_website`.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In AI modules, the agent may take a long time to use the tools and
generate content.

We therefore need to increase the typing timeout to make the user
understand that the AI is still working.

This commit makes the typing timeout duration patchable in order to do
that.

closes #258133

Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In `ai_website`, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

__Fix__
- Extract `_fetch_unsplash_images` into `ir.attachment` to make it
  callable from other models.
- Make the `requests.get` call safer by adding a timeout, filtering the
  payload keys and putting the access key in `Authorization` header.
- Replace the useless `request` variable uses with `self`
- Add some constant for the Unsplash ICP keys

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In some case, we need to use `defineWebsiteModels` without defining the
mail models at the same time.

For example, in `ai_website` we call `defineAIModels` which is
defining the mail model `DiscussChannel` differently.

__Fix__
A new parameter (i.e.`includeMailModels`) is added to be able to prevent
the call to `defineMailModels` when needed.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
*: web_unsplash

__Before commit__
`_attachment_create` was a private method in the `HTML_Editor`
controller that can only be called within a controller context as it
uses the `request` variable.

__After commit__
Make `attachment_create` a standalone function that can be imported and
used from a model such as AI tools in `ai_website`.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In AI modules, the agent may take a long time to use the tools and
generate content.

We therefore need to increase the typing timeout to make the user
understand that the AI is still working.

This commit makes the typing timeout duration patchable in order to do
that.

closes #258133

Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In `ai_website`, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

__Fix__
- Extract `_fetch_unsplash_images` into `ir.attachment` to make it
  callable from other models.
- Make the `requests.get` call safer by adding a timeout, filtering the
  payload keys and putting the access key in `Authorization` header.
- Replace the useless `request` variable uses with `self`
- Add some constant for the Unsplash ICP keys

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In some case, we need to use `defineWebsiteModels` without defining the
mail models at the same time.

For example, in `ai_website` we call `defineAIModels` which is
defining the mail model `DiscussChannel` differently.

__Fix__
A new parameter (i.e.`includeMailModels`) is added to be able to prevent
the call to `defineMailModels` when needed.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
*: web_unsplash

__Before commit__
`_attachment_create` was a private method in the `HTML_Editor`
controller that can only be called within a controller context as it
uses the `request` variable.

__After commit__
Make `attachment_create` a standalone function that can be imported and
used from a model such as AI tools in `ai_website`.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In AI modules, the agent may take a long time to use the tools and
generate content.

We therefore need to increase the typing timeout to make the user
understand that the AI is still working.

This commit makes the typing timeout duration patchable in order to do
that.

closes #258133

Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In `ai_website`, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

__Fix__
- Extract `_fetch_unsplash_images` into `ir.attachment` to make it
  callable from other models.
- Make the `requests.get` call safer by adding a timeout, filtering the
  payload keys and putting the access key in `Authorization` header.
- Replace the useless `request` variable uses with `self`
- Add some constant for the Unsplash ICP keys

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In some case, we need to use `defineWebsiteModels` without defining the
mail models at the same time.

For example, in `ai_website` we call `defineAIModels` which is
defining the mail model `DiscussChannel` differently.

__Fix__
A new parameter (i.e.`includeMailModels`) is added to be able to prevent
the call to `defineMailModels` when needed.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
*: web_unsplash

__Before commit__
`_attachment_create` was a private method in the `HTML_Editor`
controller that can only be called within a controller context as it
uses the `request` variable.

__After commit__
Make `attachment_create` a standalone function that can be imported and
used from a model such as AI tools in `ai_website`.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 18, 2026
In AI modules, the agent may take a long time to use the tools and
generate content.

We therefore need to increase the typing timeout to make the user
understand that the AI is still working.

This commit makes the typing timeout duration patchable in order to do
that.

closes #258133

Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Apr 18, 2026

@Dj0ulo @pkyriakou linked pull request(s) odoo/enterprise#106196 not ready. Linked PRs are not staged until all of them are ready.

robodoo pushed a commit that referenced this pull request Apr 19, 2026
In `ai_website`, we need to make an Unsplash request from inside an
agent tool. However we can't call a controller method from a model.

__Fix__
- Extract `_fetch_unsplash_images` into `ir.attachment` to make it
  callable from other models.
- Make the `requests.get` call safer by adding a timeout, filtering the
  payload keys and putting the access key in `Authorization` header.
- Replace the useless `request` variable uses with `self`
- Add some constant for the Unsplash ICP keys

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 19, 2026
In some case, we need to use `defineWebsiteModels` without defining the
mail models at the same time.

For example, in `ai_website` we call `defineAIModels` which is
defining the mail model `DiscussChannel` differently.

__Fix__
A new parameter (i.e.`includeMailModels`) is added to be able to prevent
the call to `defineMailModels` when needed.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 19, 2026
*: web_unsplash

__Before commit__
`_attachment_create` was a private method in the `HTML_Editor`
controller that can only be called within a controller context as it
uses the `request` variable.

__After commit__
Make `attachment_create` a standalone function that can be imported and
used from a model such as AI tools in `ai_website`.

Part-of: #258133
Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 19, 2026
In AI modules, the agent may take a long time to use the tools and
generate content.

We therefore need to increase the typing timeout to make the user
understand that the AI is still working.

This commit makes the typing timeout duration patchable in order to do
that.

closes #258133

Related: odoo/enterprise#106196
Signed-off-by: Panagiotis Kyriakou (paky) <paky@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants