Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4272 Widoki

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
Awatar
Odrzuć

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.

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lis 24
1605
5
lip 24
92863
1
gru 23
3031
1
maj 22
3613
0
sty 20
2860