Hi can anyone answer me please
I use self.field_manager.set_values to modify a value of a field that i have created in openerp but what i want to know is:
Can we set different values of a field in openerp in the same time??!!
Please i need help.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi can anyone answer me please
I use self.field_manager.set_values to modify a value of a field that i have created in openerp but what i want to know is:
Can we set different values of a field in openerp in the same time??!!
Please i need help.
I think you should reconsider your modelisation of data. You could define a new model representing the data that is on your json like for instance :
class day(orm.Model):
_name = 'horraire.day'
_columns = {
'day': fields.integer(...),
'hours': fields.integer(...),
'nature': fields.selection(...),
'horraire_id': fields.many2one('other.object.you.use', ...)
}
Now where you initially have your loop method you would do something like this, instead of your field horraire_data, you would have:
'horraire_data': fields.one2many('horraire.day', 'horraire_id', ...)
And before and in your for loop, you would do :
horraire_day_obj = self.pool.get('horraire.day')
for :
... do your treatment ...
horraire_day_obj.create(cr, uid, {
'day': 1,
'hours': 10,
'nature': 'T',
'horraire_id': ids[0] # your object_id
}, context)
In this way your field 'horraire_data' will automatically link to all records 'horraire.day' attached to it.
Thanks a lot for your answer but i want to know if it is possible to apply the
self.field_manager.set_values on a one2many field???
what is the type of your field 'horraire_data' ? char ? same question for your variable x, you put a string inside it ? if you do x = something inside your for loop, it will override the last value at each iteration. You should consider declaring x as a list, replace x = something by x.append(something) inside your for loop and then if 'horraire_data is a string, you can save your values by doing 'horraire_data': ','.join(x)
No, set_values cannot create many records, if your field is of type char (type json does not exist for a OpenERP field). The only way is to create a one2many field as I explained in my answer, otherwise you have to convert your json into a string separated by commas or formatted in a way which you will be able to read afterwards. PS: Please remove the original message if you reply by e-mail, because it pollutes the thread.
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 9 15
|
9043 | ||
|
2
thg 8 15
|
5410 | ||
|
0
thg 8 15
|
3184 | ||
|
1
thg 3 15
|
4176 | ||
|
0
thg 3 15
|
278 |
What do you want to achieve, can you explain what you are doing ? Because it's not logical to set different values to a same field. Maybe you need to have a relational field of type one2many which can link to several records. But again, if you explain more what you are trying to do maybe we can better help finding a solution.
"horraire_data":self.x,
});" je ne vais enregistrer que le dernier résultat de la boucle for.
Abdelwahèd Rihène ingénieur Génie Informatique
Ecole Nationale des Ingénieurs de Tunis
Tél: +216 21 22 49 98
Never a Failure Always A Lesson !!
Be the change you want to see in the world
De : Emanuel Cino <ecino@compassion.ch>
À : Abdelwahed <abdelwahed_rihene@yahoo.fr>
Envoyé le : Mercredi 11 mars 2015 11h44
Objet : Re: How to set different values of a field?
Emanuel Cino
Sent by Odoo S.A. using Odoo about Forum Post How to set different values of a field?
{"days":[{"day":"1","hours":"11","nature":"T"},{"day":"2","hours":"21","nature":"T"},{"day":"3","hours":"31","nature":"T"},{"day":"4","hours":"41","nature":"T"}]}
{"days":[{"day":"1","hours":"12","nature":"T"},{"day":"2","hours":"22","nature":"T"},{"day":"3","hours":"32","nature":"T"},{"day":"4","hours":"42","nature":"T"}]}
{"days":[{"day":"1","hours":"13","nature":"T"},{"day":"2","hours":"23","nature":"T"},{"day":"3","hours":"33","nature":"T"},{"day":"4","hours":"43","nature":"T"}]}
{"days":[{"day":"1","hours":"14","nature":"T"},{"day":"2","hours":"24","nature":"T"},{"day":"3","hours":"34","nature":"T"},{"day":"4","hours":"44","nature":"T"}]}
"horraire_data":self.jsonjsmmme,
Abdelwahèd Rihène ingénieur Génie Informatique
Ecole Nationale des Ingénieurs de Tunis
Tél: +216 21 22 49 98
Never a Failure Always A Lesson !!
Be the change you want to see in the world
De : Emanuel Cino <ecino@compassion.ch>
À : Abdelwahed <abdelwahed_rihene@yahoo.fr>
Envoyé le : Mercredi 11 mars 2015 11h44
Objet : Re: How to set different values of a field?
Emanuel Cino
Sent by Odoo S.A. using Odoo about Forum Post How to set different values of a field?