Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

list items on one2many

By
Francisco Castro
on 2/25/14, 7:44 AM 2,832 views

how can I list items on one2many without have to click on add item? I have two classes to build two tables:

class tabela_recintos(osv.osv):

_name = 'tabela.recintos'

_columns = {

'recinto_ids': fields.one2many('tabela.lista','id_wizard','teste')
}

tabela_recintos()

class tabela_lista(osv.osv):

_name = 'tabela.lista'

_columns = {

        'id_wizard':fields.many2one('tabela.recintos','id_wizard'),
       'cod': fields.char('Código', size=20, required='True'),
       'nome': fields.char('Designação', size=60, required='True')
        }

I click on a menu on the left and pop's up a wizard, this wizard ll list the items, but I dont know what can I do more. it only shows a field and the button add item...

my xml is this

<record id="carrega_form" model="ir.ui.view">
    <field name="name">carrega.form</field>
    <field name="model">tabela.recintos</field>
    <field name="arch" type="xml">
        <form string="carrega" version="7.0">

            <group string="carrrega" col="1">

        <field name="recinto_ids"/>

            </group>

            <footer>
               <button name='name' type='object' string='Criar novo Recinto' class="oe_highlight"/>
                ou
                <button string="Cancelar" class="oe_link" special="cancel"/>
            </footer>
        </form>
    </field>
</record>

<record id="gs_carrega_act" model="ir.actions.act_window">
    <field name="name">Carregar os Recintos</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">tabela.recintos</field>
    <field name="view_type">form</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
</record>

<menuitem
    name="Carrega Recinto teste"
    parent="gs_menuLotacoes"
    action="gs_carrega_act"
    id="gs_carrega"
    sequence="0"/>

Not sure what you mean: a one2may holds a list of items, it's not a view on another table's items.

Daniel Reis
on 2/27/14, 2:11 PM

I have done a wizard to list items on this wizard I show a one2many field on it but I cant list the items when the wizard starts. I have to go to the add button and add the items one by one. I just need to list items when I click on the wizard menu

Francisco Castro
on 2/27/14, 2:22 PM
0
Nati
On 6/23/14, 8:30 PM

Did anyone findthe solution? I have the same problem.

0
K Santosh Subba Rao
On 6/23/14, 11:27 PM

you want the list of items to be displayed automatically based on some condition right??

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 8/27/14, 6:38 AM

The method that we have used before is create the instance of tabela.recintos first, then create the related recinto_ids records, then return an action whose res_id is set to the created tabela.recintos.  Sample method returning action with res_id set can be found in action_button_confirm method in sale/sale.py.

Second method I can think of is to use the _default for tabela.recintos.  This can be done if the recinto_ids can be created without any knowledge of the information in tabela.recintos.

A side note, usually for wizards (non persistent data) we would use osv.osv_memory (or orm.TransientModel in 7.0) instead of osv.osv.

0
mywebsitedeal
On 8/27/14, 6:27 AM

Evn i have the same problem .any idea of the solution

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 2/25/14, 7:44 AM
Seen: 2832 times
Last updated: 3/16/15, 8:10 AM