Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4266 Zobrazení

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
Zrušit

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.

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
lis 24
1599
5
čvc 24
92858
1
pro 23
3028
1
kvě 22
3611
0
led 20
2859