跳至内容
菜单
此问题已终结
1 回复
880 查看

Question:

I'm developing a custom Odoo 17 website module to add a video block snippet, allowing users to play videos hosted on the server. I'm encountering the following error upon installation or usage of the snippet in Odoo:

plaintextCopy codeValueError: View 'website_video_block' in website 1 not found

This results in an RPC error that prevents the snippet from being displayed. Below is the specific traceback:

plaintextCopy codeTraceback (most recent call last):
  File "<944>", line 1419, in template_944
  ...
ValueError: View 'website_video_block' in website 1 not found

Context:

  1. Module Purpose: The module adds a custom snippet to the website editor with a video player to embed server-hosted videos.
  2. XML Code (Snippet Definition):
    • The snippet definition file includes a <template id="website_video_block" name="Video Block"> to define the block.
    • This template is then referenced in another template using <t t-call="website_video_block"/> within the website.snippets template.

Main Code Snippet:

xmlCopy code<odoo>
    <template id="website_video_block" name="Video Block">
        <div class="o_video_block">
            <video controls="controls">
                <source src="/path_to_videos/default_video.mp4" type="video/mp4"/>
                Your browser does not support the video tag.
            </video>
        </div>
    </template>

    <template id="add_video_block_snippet" inherit_id="website.snippets" name="Add Video Block to Snippets">
        <xpath expr="//div[@id='snippet_structure']/div" position="inside">
            <t t-call="website_video_block"/>
        </xpath>
    </template>
</odoo>

Error Cause Hypothesis: It appears that Odoo fails to locate or load the website_video_block view, resulting in an RPC error. I've checked for ID naming conflicts, updated the module, and cleared the cache, but the issue persists.

Could there be an issue with the template registration or the inheritance in the XML structure? Any guidance on resolving this would be greatly appreciated.

形象
丢弃
最佳答案

Hi,

Call the template with your moule name.Modify the code as follows:

<odoo>

    <template id="website_video_block" name="Video Block">

        <div class="o_video_block">

            <video controls="controls">

                <source src="/path_to_videos/default_video.mp4" type="video/mp4"/>

                Your browser does not support the video tag.

            </video>

        </div>

    </template>


    <template id="add_video_block_snippet" inherit_id="website.snippets" name="Add Video Block to Snippets">

        <xpath expr="//div[@id='snippet_structure']/div" position="inside">

            <t t-call="your_module_name.website_video_block"/> <!-- Replace with your actual module name -->

        </xpath>

    </template>

</odoo>


Hope it helps

形象
丢弃
相关帖文 回复 查看 活动
4
5月 25
273
2
8月 24
1416
2
5月 25
264
1
2月 25
793
1
2月 25
533