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


Error:

raise ParseError(msg) from None # Restart with "--log-handler odoo.tools.convert:DEBUG" for complete traceback odoo.tools.convert.ParseError: while parsing /opt/odoo17/odoo/addons/gb_hr_payroll_community/views/res_config_settings_views.xml:11 Since 17.0, the "attrs" and "states" attributes are no longer used. View: res.config.settings.view.form.inherit.hr.payroll in gb_hr_payroll_community/views/res_config_settings_views.xml View error context: {'name': 'invalid view'}


Avatar
Discard
Best Answer

Hi,

In odoo 17 there is technical changes on usage of attrs and states.

 You can directly add condition for readonly, invisible,required in respected attribute.

For example in 16 one button was defined as : 




For the same button when it comes to odoo 17, its modified in to:



Similarly you will see several code samples,

 by comparing odoo 16 and 17 codes and you can modify based on your requirement


Refer this script also for easily converting: 

https://github.com/pierrelocus/odoo-attrs-replace

Hope this will help you

Thanks

Avatar
Discard
Author

How will be this one then:

<h2 attrs="{'invisible': ['|', '|', ('module_l10n_fr_hr_payroll', '=', True), ('module_l10n_be_hr_payroll', '=', True), ('module_l10n_in_hr_payroll', '=', True)]}">Payroll</h2>

Update the attrs as this:
invisible="module_l10n_fr_hr_payroll or module_l10n_be_hr_payroll or module_l10n_in_hr_payroll"

Author

Can you help me to find it.
1) attrs="{'invisible': ['|', ('attachment_number', '&lt;=', 0), ('sheet_id', '!=', False)]}"
2) attrs="{'invisible': [('attachment_number', '&gt;=', 1)]}"
3) attrs="{'invisible': [('same_currency', '=', True), ('product_has_cost', '=', False)]}"

Best Answer

Hi,

1/ answer to prev question

 

2/ seems like attrs are also not in use anymore in v17, you need to separate them into separate parameters in the object definition, so for example it will be

xml code:
< field name="name"
invisible="state not in ['done', 'cancel']"
readonly="state in ['ready', 'waiting']"/>


hope it helps

Cheers!

Avatar
Discard
Best Answer

Yes, since 17.0 attrs is removed..If you check the XML you can see that it's replaced by something like this:
 invisible="state != 'to remove'"

Avatar
Discard
Author

Hi Ananth,
I can't see anything after the sentence "something like this:" that you just sent.

Author

Hi Ananth,
Now i was able to view it.

Then, how can i correct this one:
<h2 attrs="{'invisible': ['|', '|', ('module_l10n_fr_hr_payroll', '=', True), ('module_l10n_be_hr_payroll', '=', True), ('module_l10n_in_hr_payroll', '=', True)]}">Payroll</h2>