Skip to Content
Menu
This question has been flagged
3 Replies
2514 Views

How to set the field account_analytic_id on sale.order with XML-RPC ?

I want to make the link between sale.order and project. I put an ID on the sale order account_analytic_id from the entity account.analytic.account by API but it's not record because the field is on readonly. I can only set this relation on the form view order.

Odoo version EE.


account_analytic_id
Avatar
Discard
Author Best Answer


I can do that if my script was in ODOO python. Here my script is in PHP, I call the external API Odoo with XML-RPC, I can't execute a query SQL.

$result = $this->_getModel()->execute_kw($this->_getDB(), $this->uid, $this->_getPassword(),
'sale.order',
$method,
$parameters
);

EDIT : Ok my bad, the error was the field's name : 

account_analytic_id instead of analytic_account_id
Avatar
Discard
Best Answer

Add force_save="1" to the declaration of the field ie <field name="account_analytic_id" force_save="1"/>

Avatar
Discard

If you assign it directly from a function, you can always bypass the orm

so_id = 4

acc_ana_id = 3

query = """update sale_order set account_analytic_id = %s where id = %s"""

self.env.cr.execute(query, [acc_ana_id, so_id])