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

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

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

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 19
4884
2
lut 23
4440
7
cze 24
25573
2
mar 21
9349
0
wrz 20
2650