Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
4922 Weergaven

Hello

I have a problem with the initialization of a new field I have added to an existing model. I want this field to be unique and not null, but when I load my module those constraints can't be created due to the existing records in that table (the warning tells me to update the table contents and load the constraint manually). In order to avoid this, I'm trying to initialize the field using a sequence I load in a xml file (through "data" in __openerp__.py) with the following _defaults attribute

_defaults = {              
    'code_prefix' : lambda self,cr,uid,context=None: self.pool.get('ir.sequence').get(cr, uid, 'ags.test'),
}

But since the model is initialized before any data file is loaded, when the lambda function is executed in the initialization of the field for an existent record the sequence is not loaded yet.

Is there any way to bring forward the data load aside from creating an "initialization module" and adding a dependency to make it load before my module? How can I have the sequence available by the time the field is initialized?

Thanks in advance, Pablo

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
feb. 19
12055
3
dec. 23
6865
0
mrt. 15
3997
1
mrt. 15
7264
1
mrt. 15
6278