Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Not returning list view

Subscriure's

Get notified when there's activity on this post

This question has been flagged
returnsodooodoo12
4 Respostes
4722 Vistes
Avatar
Grf


I have this model

class RawMaterialReport(models.Model):
    _name = 'raw.material.report'
    _description = 'Raw Material Report'

    product_id = fields.Many2one(
        'product.product', string='Product',
        required=False,
    )

    @api.multi
    def open_raw_materials(self):
        mrp_productions = self._context.get('active_ids')
        mrp_production = 
        self.env['mrp.production'].browse(mrp_productions)
        raw_products = 
        mrp_production.mapped('move_raw_ids.product_id')
        for p in raw_products:
            self.create({'product_id': p.id})

        view_id = self.env.ref('trk.raw_material_report_tree').id
        view = {
            'name': _('Details'),
            'view_type': 'form',
            'view_mode': 'tree, form',
            'res_model': 'raw.material.report',
            'views': [(view_id, 'form')],
            'type': 'ir.actions.act_window',
            # 'res_id': self.id,
        }
        return view

    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>

    <record id="raw_material_report_tree" model="ir.ui.view">
        <field name="name">raw.material.report.tree</field>
        <field name="model">raw.material.report</field>
        <field name="priority">2</field>
        <field name="arch" type="xml">
            <tree string="Sales Orders" >
                <field name="product_id" />
            </tree>
        </field>
    </record>



     <record id="action_raw_material_report" 
            model="ir.actions.act_window">
            <field name="name">zzzzz</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">raw.material.report</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,kanban,form</field>
        </record>


        <record id="action_server_learn_skill" 
            model="ir.actions.server">
            <field name="name">test</field>
            <field name="type">ir.actions.server</field>
            <field name="model_id" ref="model_raw_material_report" />
            <field name="binding_model_id" 
            ref="mrp.model_mrp_production" />
            <field name="state">code</field>
            <field name="code">model.open_raw_materials()</field>
        </record>

        <menuitem id="menu_sale_order1"
            name="test"
            action="action_raw_material_report"
            parent="sale.sale_order_menu"
            sequence="2" />
    </data>
</openerp>

When I go to action and run my method everything goes good until that point where I try to return a view it just not redirecting me to my tree view. Nothing happens. But raw.material.report Records got created and I can check them if I go to my menu, it opens list view with them. So there is some kind of a problem with my return, can someone help on this? I actually tried to return an action like this

action = self.env.ref('trk.action_raw_material_report').read()[0]
return action

but get the same, it just not redirecting me to my tree view.


0
Avatar
Descartar
Avatar
Thayif kabir
Best Answer

Hi,

 Try this one

 return {
        'name': _('Details'),
        'view_type': 'form',
        'view_mode': 'tree, form',
        'res_model': 'raw.material.report',
        'views': [(view_id_tree[0].id, 'tree'),(False,'form')],
        'type': 'ir.actions.act_window',
        # 'res_id': self.id,
        'target': 'current',
    } 
Issue occurs because you may be passing wrong id in views [(view_id,'form')] instead of [(view_id,'tree')]
0
Avatar
Descartar
Avatar
Grf
Autor Best Answer


The problem was that in action_server_learn_skill

I needed

<field name="code">action = model.open_raw_materials()</field>

instead of

<field name="code">model.open_raw_materials()</field>

because the method is not returning anything to action.


0
Avatar
Descartar
Avatar
Dhaval Desai
Best Answer

 Hello Grf.​

 Please try this:

 @api.multi
 def your_function_name(self):
    tree_view_id = self.env.ref('trk.raw_material_report_tree').id
    return {
        'name': _('Details'),
        'type': 'ir.actions.act_window',
        'res_model': 'raw.material.report',
        'view_type':'form',
        'view_mode': 'tree',
        'view_id': tree_view_id,
        'res_id': False,
        'context': False,
        'target':'new'
    }

 You can refer below link:

 \https://www.odoo.com/forum/help-1/question/how-to-return-a-tree-view-from-a-python-function-119786           

 Make sure it will helpful.


 Thank you.

0
Avatar
Descartar
Grf
Autor

same result, nothng happens

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
psycopg2.ProgrammingError: no existe la relación «_unknown» Please HELP!!!!
odoo odoo12
Avatar
Avatar
2
de nov. 25
258
Reverse Transfer - how to stop returning more than was delivered - Odoo.sh v16
returns odoo
Avatar
Avatar
1
de des. 24
3685
How to track One2many field in Odoo12? Solved
odoo odoo12
Avatar
Avatar
Avatar
Avatar
3
de nov. 23
18458
Error: Couldn't load module web Solved
odoo odoo12
Avatar
Avatar
Avatar
3
de nov. 24
26551
How I get the current ID of a record ? Solved
odoo odoo12
Avatar
Avatar
1
d’abr. 23
6936
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now