Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

Hi!

I'm facing a little issue, let me explain:

I've created an Abstract Model as follows in this example:

class AlarmSettings(models.AbstractModel):
    _name = "alarm.settings"
    field1 = fields.Integer('Int1', default=10)
    field2 = fields.Integer('Int2, default=20)

And on the other hand, I've created a new model, and this one inherits my abstract model, and the base one:

class ProductAlarm(models.Model):
    _name = "product.alarm"
    _inherit = ["product.alarm", "alarm.settings"]


The problem is, in product.alarm, now I have the current fields on product.alarm and the new ones from alarm.settings. But for "field1" and "field2", the default values are zero instead of 10 and 20 as declared on my abstract model.

What am I doing wrong? Thanks

Avatar
Zrušit
Autor

EDIT: The issue comes from created records on product.alarm; i mean, when i click on Create, default values are loaded correctly, but previous records show zero value on field1 and field2

Nejlepší odpověď

Hi,

If you have some already created records and then you add the default values on a field, its normal because default attribute only works on new created record.

You may do it with an SQL script or or do it with a CRON.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
dub 19
4722
2
úno 23
3887
7
čvn 24
24980
2
bře 21
8994
0
zář 20
2388