Hello,
When I update data with an override "write" function, I do a post request for an external application with the id of changed record (cf: the code bellow). Then the app get the values in postgres but the values hasn't change at this time.
@api.multi
def write(self, values):
for record in self:
res = super(my_class_xxxx, self).write(values)
data = {"id": record.id}
requests.post("https://us-central1-xxxxxxxx.com", data=data)
return res
I think the record is update in Odoo but the value of the database change when the write function is returned.
What can I do for call the endpoint when the data has changed in postgres?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
hmm you are right is not committed yet DB. it's committed when request return result
I think you need to explicitly commit the cursor to stored data forcefully in DB like
@api.multi
def write(self, values):
for record in self:
res = super(my_class_xxxx, self).write(values)
data = {"id": record.id}
record.env.cr.commit()
requests.post("https://us-central1-xxxxxxxx.com", data=data)
return res
Hi Theo:
You may want to consider using an Automated Action (Settings > Technical > Automation) to invoke the api on the On Creation trigger condition of the model.
Thank you both for your answers, the method of Ravi Gadhia works perfectly so I haven't tried your's Paresh Wagh but I think it can works too :)
it will not work because odoo commits the cursor/transaction when the response despatched.
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
18
أغسطس 18
|
20022 | ||
|
2
مارس 25
|
483 | ||
|
6
ديسمبر 23
|
45099 | ||
|
1
أبريل 25
|
826 | ||
|
0
فبراير 25
|
594 |