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.

1

Add tab in a form view

By
José
on 12/9/14, 2:28 PM 1,424 views

Hello, I am developed a new module in Odoo 8, in which I have a Python class that not inherits from any other class. The code of the class is:

class products_prices(models.Model):
    _name = 'product.pricelist.products_prices'

    product_tmpl_id = fields.Many2one('product.template')
    precio = fields.Float(digits=(8,2), String="Precio")
    product_pricelist_item_id = fields.Many2one('product.pricelist.item')

I need to add a view of the class in the form view "product.pricelist.item.form". I want to put it in a new tab on the popup, but the new view is of model "product.pricelist.products_prices" and this model does not have the fields of product.pricelist.item so I get an error when I am installing the module... How can I do?

1
Devang Pipaliya
On 12/10/14, 6:37 AM

HI jose,

try this:

  • create a one2many of the class 'product.pricelist.products_prices' with this field product_pricelist_item_id, in the class "product.pricelist.item" ,
  • in the form view "product.pricelist.item.form", add the above one2many under <notebook><page>...</page></notebook>

Hope, this works for you.

Can you please tell what exact error you are getting before implementing this?

Try this:

<notebook>
    <page>
        <field name="products_prices_ids" string="Producto" >
            <tree string="Precios">
                <field name="..." />
                ...................
                <field name="..." />
            </tree>
        </field>
        </page>
</notebook>

1
José
On 12/10/14, 7:43 AM

Thank you, that works.

But how can I specify the columns to show? I want to show a tree, and for example I want to show only the two first fields.

This works correctly: (products_prices_ids is the one2many relationship field)

<notebook>
         <page>
                  <tree string="Precios">
                    <field name="products_prices_ids" string="Producto" />         
                  </tree>
        </page>
  </notebook>

But if I do this

<notebook>
         <page>
                  <tree string="Precios">
                    <field name="products_prices_ids.product_tmpl_id" string="Producto" />         
                  </tree>
        </page>
  </notebook>

I get an error "field products_prices_ids.product_tmpl_id does not exist".

If you just wanted to display one column then also you have to followe the codding style for xml I have provided in my previous answer.

Devang Pipaliya
on 7/30/15, 5:17 AM

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

3 follower(s)

Stats

Asked: 12/9/14, 2:28 PM
Seen: 1424 times
Last updated: 6/23/16, 7:13 AM