-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to change modules config settings remotely with erppeek #85
Comments
The |
@esciara This config is a special case.
Because
See what the onchange does: def onchange_sale_price(self, cr, uid, ids, sale_pricelist_setting, context=None):
if sale_pricelist_setting == 'percentage':
return {'value': {'group_product_pricelist': True, 'group_sale_pricelist': True, 'group_pricelist_item': False}}
if sale_pricelist_setting == 'formula':
return {'value': {'group_pricelist_item': True, 'group_sale_pricelist': True, 'group_product_pricelist': False}}
return {'value': {'group_pricelist_item': False, 'group_sale_pricelist': False, 'group_product_pricelist': False}} |
Plus see @dreispt comment, you need to do a create, not a browse as it is a transient model. [...]
Wizard = erppeek_client.model(config_model_name)
config = Wizard.create(values)
config.execute() |
Thanks for the tips! Will apply and share results. |
Thanks for your help! Here is the code I ended up writing, and which works fine: elif self._model_name == 'sale.config.settings':
for row in rows:
config_values = self._extract_data_from_row(row, fieldnames)
config = self._model.create(config_values)
if 'sale_pricelist_setting' in config_values.keys():
value_to_change = config.onchange_sale_price(config_values['sale_pricelist_setting'])
config.write(value_to_change['value'])
config.execute() Is that the way to do it or is there a more elegant way? Anybody could give a bit more insight on For info rows are initially coming from a csv file, so the One last question: are pretty much all configs transient objects and should be treated the same why as above? Some of them are class sale_configuration(osv.TransientModel): class stock_config_settings(osv.osv_memory): [EDIT] Never mind, I just found info in the code about what execute does:
Also found https://www.odoo.com/documentation/9.0/howtos/backend.html#wizards Still curious about eventual differences between |
They are the same thing. |
On last question before I close this issue. I want to be able to test that my config settings have been correctly configured after I did it. But when I do a How do I get to retrieve the configs from my Odoo instance? |
The Settings is just a transient Wizard used to collect selections from the user. |
An other option which might not be simpler than @dreispt one. You could create a new wizard and read it, you have to ensure default_get is called as it is where it populates the wizard values in version 9.0. (in version 8.0 it was also done in company_id onchange) Also ensure if there are no other onchanges to calls as they aren't called by the create. |
@yvaucher I looked at the |
@esciara No the xml file is only the view definition. You will have the values you are looking for in the records. But as transient model is not persistent in database, the value you are looking for are setted on the wizard in the web client when opening the settings. This is done by calling Thus, to check through erppeek the settings on the server you have to call |
Thanks for the explanations @yvaucher :). That should give me what I need for my current tests. Out of curiosity, if you happen to know where the piece of code that handles populating the config views is, I will gladly take that info to look at how Odoo handles the special case like the one you mention on account settings and companies. My goal would be to build a testing code that handles as many options as possible so I can get access to the data I want to test. Cheers! |
@esciara I already gave it to you in my previous comment 😉 https://github.com/OCA/OCB/blob/9.0/openerp/addons/base/res/res_config.py#L509 All config settings inherit from |
😄 @yvaucher understood that part. I was talking about the code that handles all the special cases that are not handled by If the |
@esciara This might be defined in the specific config settings for example: This is an onchange that the view will calls automatically but with erppeek you need to call it manually. And you may cascade the change to the onchange by calling the following methods: |
@yvaucher thanks. You are confirming what I found in the book "Odoo Developement Cookbook" (thanks @dreispt 😉 ) page 104:
So the likely solution is:
Thank you all for your help. I will close this. Don't hesitate to correct if this is wrong. |
Right, errr... struggling a bit on how to find programatically the Still on "Odoo Developement Cookbook", it is mentioned that the Could not find any other way of finding out... Any pointers to how this could be done? |
@esciara Sorry for "private" methods, like onchanges the only way to do it is to do a "public" wrapper (without |
Yep @yvaucher ... And in any case, I saw that sometimes I would need to have a look at how the config view is populated with the data, since my understanding is that it is populated through calls to an XMLRPC method and we saw here that a I will keep this issue open until I find this. |
Hi,
I am trying to use erppeek to change remotely config settings of modules. But I cannot manage to make it work. For the time being I am trying to do it on
base.config.settings
,account.config.settings
,stock.config.settings
andsale.config.settings
(which seem to have a different behavior than the other two, in that it does not create a new record when the config is updated on the user interface, which is what the others do.)I try to do it by creating a new config setting record, then I run the equivalent of the following code.
As a result, on the odoo interface, the change is recorded (here the sale price setting has been changed to allow pricelists) but it has not been taken into account/executed. See screenshot below.


But when I hit "Apply" on the user interface, then the configuration is taken into account, as you can see on the screenshot below.
Any clues about what I am doing wrong?
The text was updated successfully, but these errors were encountered: