Hi good day!,
I just want to as on how to assign/send/copy long text field value to another text field in odoo 10 by a xmlrpc webservice.
Thank you very much in advance!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi good day!,
I just want to as on how to assign/send/copy long text field value to another text field in odoo 10 by a xmlrpc webservice.
Thank you very much in advance!
- Firstly, you have to set up the connection to your odoo instance :
``
`
import xmlrpc.client
url = 'http://your-odoo-server'
db = 'your-database-name'
username = 'your-odoo-username'
password = 'your-odoo-password'
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
``
`
- Then, you can fetch the record IDs you want to copy, you can use 'search and read' to get it
``
`
model_name = 'your.odoo.model' # Replace with your actual Odoo model name
record_ids = [1, 2, 3] # Replace with the IDs of the records you want to update
``
`
- finally, you deal with these record IDs and proceed to the update,
``
`
for record_id in record_ids:
record = models.execute_kw(db, uid, password, model_name, 'read', [record_id], {'fields': ['field_to_copy', 'target_field']})
# Check if the source field has a value
if record[0]['field_to_copy']:
source_value = record[0]['field_to_copy']
# Update the target field with the source value
models.execute_kw(db, uid, password, model_name, 'write', [[record_id], {'target_field': source_value}])
``
`
*** Please note that if you are working with long text fields, the API response might not include the complete text in a single call. You may need to adjust your code to handle this situation based on your specific requirements.
*** I hope it can be helpful. Thx
관련 게시물 | 답글 | 화면 | 활동 | |
---|---|---|---|---|
|
2
6월 24
|
1219 | ||
|
1
4월 23
|
1190 | ||
|
1
3월 23
|
1972 | ||
|
0
12월 22
|
1668 | ||
|
1
10월 21
|
3545 |