Please help on this issue, thanks in advance!
A) What I am looking for:
enable feature "Pricelists" defined by Odoo itself in automation code at INSTALL time so that the field "Pricelist" can be seen on tab 'Sales & Purchase' of page of any customer after the installation.
B) What I saw:
after installation of a customized module,
1) I saw "Pricelists" is ENABLED on page "Settings -> Sales -> Pricing"
2) I did NOT see the field "pricelist" on the page "Sales -> Customers -> My Company(I created) -> Sales & Purchase"
C) What I expect:
I can see the field "pricelist" on the page "Sales -> Customers -> My Company(I created) -> Sales & Purchase" as well after AUTOMATED installation at B)-2).
Comparing with manual action: If I enable the checkbox of "Pricelists" on page "Settings -> Sales -> Pricing" MANUALLY, I can see the field "pricelist" afterwards.
D) What I did (reproducing steps):
1) create a new customized module 'Module_A';
2) in 'Module_A', create a new model which inherites 'res.config.settings' to set 'product.group_product_pricelist' with 'True' in 'ir.config_parameter';
- create a xml file and write code below
<function model="res.config.settings" name="config_flsp_global_features_for_install" />
- define method "config_flsp_global_features_for_install" in the model to set the value when to install 'Module_A'
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
@api.model
def config_flsp_global_features_for_install(self):
# update ir.config_parameter to set the value globally
self.env['ir.config_parameter'].sudo().set_param('product.group_product_pricelist', True)
# update the field value in res.config.settings
self.group_product_pricelist = True
E) My analysis:
- I am sure the code in D)-2) was run as "Pricelists" was ENABLED on page "Settings -> Sales -> Pricing";
- I also tried method get_values() and set_values() in model 'res.config.settings', but it did not work;
- I think the value has been set in database, even in the model field 'group_product_pricelist' at running time because I set it in code, but the problem is that the view of customer(res.partner) does not refer its updated value and the field "Pricelist" is missing;
- definition of the field "Pricelist" on customer's view in addons\product\views\res_partner_views.xml
<field name="property_product_pricelist" groups="product.group_product_pricelist" attrs="{'invisible': [('is_company','=',False),('parent_id','!=',False)]}"/>
- in my manual test, the value set is initialized on client view, so in addition to the value update in model and in database, there must be some actions done at the same time to refresh customer(res.partner)'s view with the new value, which I do not know.
Will this help? https://www.youtube.com/watch?v=mCwg-X3NfjQ