admin管理员组

文章数量:1122832

I’m trying to install a custom Odoo 17 module, but when I attempt to install it, I get the following error,This error occurs when trying to load the XML file for my module. The XML structure appears to be correct, with the root element containing the tag, and all other records (views, actions, menu items) nested inside it.

file_import.xml:

<odoo>
   <data>
      <!-- Form View for File Import -->
      <record id="view_file_import_form" model="ir.ui.view">
         <field name="name">file.import.form</field>
         <field name="model">file.import</field>
         <field name="arch" type="xml">
            <form string="File Import">
               <sheet>
                  <group>
                     <field name="name" />
                     <field name="file_data" filename="name" widget="binary" />
                     <field name="file_type" />
                  </group>
               </sheet>
               <footer>
                  <button string="Import" type="object" name="process_file" class="btn-primary" />
                  <button string="Cancel" special="cancel" class="btn-secondary" />
               </footer>
            </form>
         </field>
      </record>
      <!-- Tree View for File Import -->
      <record id="view_file_import_tree" model="ir.ui.view">
         <field name="name">file.import.tree</field>
         <field name="model">file.import</field>
         <field name="arch" type="xml">
            <tree string="Imported Files">
               <field name="name" />
               <field name="file_type" />
               <field name="import_date" />
               <field name="file_data" widget="binary" />
            </tree>
         </field>
      </record>
      <!-- Action for File Import Form -->
      <record id="action_file_import" model="ir.actions.act_window">
         <field name="name">File Import</field>
         <field name="res_model">file.import</field>
         <field name="view_mode">form</field>
         <field name="view_id" ref="view_file_import_form" />
         <field name="target">new</field>
      </record>
      <!-- Action for Viewing Imported Files -->
      <record id="action_file_import_list" model="ir.actions.act_window">
         <field name="name">Imported Files</field>
         <field name="res_model">file.import</field>
         <field name="view_mode">tree,form</field>
         <field name="view_id" ref="view_file_import_tree" />
         <field name="target">current</field>
      </record>
      <!-- Menu Item for File Import -->
      <menuitem id="menu_file_import" name="File Import" parent="base.menu_administration" action="action_file_import" sequence="10" />
      <!-- Menu Item for Imported Files List -->
      <menuitem id="menu_file_import_list" name="Imported Files" parent="base.menu_administration" action="action_file_import_list" sequence="20" icon="fa fa-file-upload" />
   </data>
</odoo>

model.py

from odoo import models, fields, api


class FileImport(models.Model):
    _name = "file.import"
    _description = "File Import"

    name = fields.Char(string="File Name", required=True)
    file_type = fields.Selection(
        [
            ("csv", "CSV"),
            ("json", "JSON"),
            ("xlsx", "Excel"),
            ("pdf", "PDF"),
        ],
        string="File Type",
        required=True,
    )
    import_date = fields.Datetime(string="Import Date", default=fields.Datetime.now)
    file_data = fields.Binary(string="File Data", required=False)

本文标签: pythonAssertionError Element odoo has extra content dataline 2Stack Overflow