Skip to Content
Menu
This question has been flagged
2 Replies
11686 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?

Avatar
Discard
Best Answer

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>

Avatar
Discard
Author Best Answer

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".

Avatar
Discard

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.

Related Posts Replies Views Activity
0
Apr 24
1770
4
Nov 23
5815
0
Oct 23
1548
0
Dec 22
2487
2
Dec 23
19118