Skip to Content
Menu
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
Discard
Author

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

Best Answer

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
Discard
Related Posts Replies Views Activity
1
Apr 19
3754
2
Feb 23
1875
7
Jun 24
21663
2
Mar 21
7556
0
Sep 20
1333