Odoo Help


How display field form inherit class

on 7/26/13, 10:35 AM 2,949 views


i have this code

class sprzedaz(osv.osv):

    _defaults = {
                'data': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S') 

    _columns= {
            'produkt_id': fields.many2one('produkt.rodzaj', 'Produkt', required=True),
            'ilosc': fields.integer('Ilość', size=12, required=True),
            'miejsce_id': fields.many2one('miejsce', 'Miejsce', required=True),
            'data': fields.datetime('Data', required=True),
            #'razem': fields.char('Razem', required=True),
           # 'razem': fields.function(suma, 'Razem', type="float"),
            #zrobic funkcje wyliczajaca sume zakupu

    def suma(self, cr, uid, ids,args,name, context=None):

        razem = 0
        return razem


class sprzedaz_inh(osv.osv):

    _name = "sprzedaz.inh"

    def suma(self, cr, uid, ids,args,name, context=None):
        print ids
        for id in ids:
            r= self.browse(cr,uid,id)
            c= self.pool.get('sprzedaz').browse(cr,uid,id).produkt_id.cena
            print c.cena
            pom = r.ilosc * c
        return razem
    _columns= {
            #'razem': fields.char('Razem', required=True),
            'razem': fields.function(suma, 'Razem', type="float"),
            #zrobic funkcje wyliczajaca sume zakupu


and xml

<record model="ir.actions.act_window" id="action_sprzedaz_form">
    <field name="res_model">sprzedaz</field>

<record model="ir.ui.view" id="sprzedaz_form">
<field name="name">sprzedaz</field>
<field name="model">sprzedaz</field>
<field name="type">tree</field>
<field name="arch" type="xml">
    <tree string="Sprzedaz">
        <field name="produkt_id"/>
        <field name="ilosc"/>
        <field name="miejsce_id"/>
        <field name="data"/>
        <field name="razem"/>


<menuitem name="Sprzedaz" id="menu_action_sprzedaz_form" 

How can i display field razem form class sprzedaz_inh?

I have this error:

View error

Can't find field 'razem' in the following view parts composing the view of object model 'sprzedaz':
 * sprzedaz

Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model

Anyone can help me?


Grover Menacho

--Grover Menacho--
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Odoo Developer

Grover Menacho
On 7/26/13, 10:58 AM

Actually I don't understand why are you creating two classes when you only need one. Anyways it's because you are giving sprzedaz_inh a name. So you have to delete that name if you want to extend the other class. just leave the inherit.

That's because if you are giving a _name to the inherited class then you are creating another class with the same attributes, but it's another class.

Also the last line must be: sprzedaz_inh()

I hope this can help you.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 7/26/13, 10:35 AM
Seen: 2949 times
Last updated: 3/16/15, 8:10 AM