[Python] I can't see the custom button i created in the header of the list in my module in...

Discussão em 'Python' iniciado por Stack, Maio 6, 2025.

  1. Stack

    Stack Membro Participativo

    I've created a module in odoo18 and in that I created a xml called product_views. It has a list in it. I added a button in the header of the list but I can't see it.

    Here is my xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <odoo>
    <record id="view_product_list" model="ir.ui.view">
    <field name='name'>"electronic.product.list"</field>
    <field name='model'>product.product</field>
    <field name="priority" eval="99"/>
    <field name="arch" type="xml">
    <list>
    <header>
    <button name="import_action"
    string="import"
    type='object'/>
    </header>
    <field name="name" string="product name" />
    <field name="volume" string="quantity" />
    <field name="x_link" string="quantity" />
    </list>
    </field>
    </record>
    <record id="action_electronic_products" model="ir.actions.act_window">
    <field name="name">Electronic Products</field>
    <field name="res_model">product.product</field>
    <field name="view_mode">list</field>
    <field name="view_id" ref="view_product_list"/>
    </record>
    <menuitem
    id="menu_electronic_product_root"
    name="Electronic Products"
    action="action_electronic_products"
    sequence="10"
    groups="base.group_user"/>


    This is my model:

    from odoo import models, fields, api

    class ProductProduct(models.Model):

    _inherit = 'product.product' # Correct inheritance
    x_link = fields.Char(
    string='Product Link',
    help='URL of the product',
    default='',
    tracking=True # Shows changes in chatter
    )
    def import_action(self):
    return {
    'name': 'Import Products',
    'type': 'ir.actions.act_window',
    'res_model': 'product.import.wizard',
    'view_mode': 'form',
    'target': 'new',
    'context': {'default_product_id': self.id},
    }


    Can you help me please?

    Continue reading...

Compartilhe esta Página