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
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Jun 24
|
1126 | ||
|
1
Apr 23
|
1114 | ||
|
1
Mar 23
|
1884 | ||
|
0
Dec 22
|
1608 | ||
INSTALLING ODOO 10C ERROR
Solved
|
|
1
Oct 21
|
3435 |