Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
4267 Weergaven

I will do an abstract class with some childs, ex: "animal -> extended by dog and extended by cat".

the problem becomes when I want to list all the "animals" in the example.


example code:


class Animal(models.AbstractModel):
_name = "test.animal"

name = fields.Char("Name")
vel = fields.Float("Velocity")


class Dog(models.Model):
_name = "test.dog"
_inherit = ["test.animal"]


class Cat(models.Model):
_name = "test.cat"
_inherit = ["test.animal"]

Thank you
Avatar
Annuleer

I have a superclasse “Animal” whose is abstract and some subclasses “dog, cat, horse...” whose extends animal.

 

The exemple code is:

 

class Animal(models.AbstractModel):
    _name = "test.animal"

    name = fields.Char("Name")
    vel = fields.Float("Velocity")


class Dog(models.Model):
    _name = "test.dog"
    _inherit = ["test.animal"]


class Cat(models.Model):
    _name = "test.cat"
    _inherit = ["test.animal"]

 

I want to do a view that shows all the “animals”, including “cats, dogs,...”

 

 

De: Ermin Trevisan <trevi@twanda.com>
Enviado el: miércoles, 23 de octubre de 2019 17:23
Para: Joan Aldabó <joan.aldabo@midgard.cat>
Asunto: Re: view for generic class

 

Please be more specific. What is your problem?

Sent by Odoo S.A. using Odoo.

Beste antwoord

Hi,

you can't create one view to show more models.

When you extend an original model, Odoo create another one. Famework can't show records from more models in the some view. 

If you want something like this you can create an unique class Animal and define a field that set if this animal is a cat, a dog or another one. You can create different menu and action to show list filtered for every animal, yet and you can have a view that show all animals wihout filter.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
nov. 24
1599
5
jul. 24
92858
1
dec. 23
3028
1
mei 22
3611
0
jan. 20
2859