Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
11716 Переглядів

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?

Аватар
Відмінити
Найкраща відповідь

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>

Аватар
Відмінити
Автор Найкраща відповідь

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.

Related Posts Відповіді Переглядів Дія
0
квіт. 24
1787
4
лист. 23
5835
0
жовт. 23
1617
0
груд. 22
2505
2
груд. 23
19184