I have one character field ("subject").As Subject changes button string should also change (subject wise).
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
override fields_view_get function and from here you can access arch. here you will get all fields as in html elements and you can change the strings of button after your conditions.
description:
:param view_id: id of the view or None:param view_type: type of the view to return if view_id is None ('form', 'tree', ...)
:param toolbar: true to include contextual actions
:param submenu: deprecated
:return: dictionary describing the composition of the requested view (including inherited views and extensions)
:raise AttributeError: * if the inherited view has unknown position to work with other than 'before', 'after', 'inside', 'replace' * if some tag other than 'position' is found in parent view
:raise Invalid ArchitectureError: if there is view type other than form, tree, calendar, search etc defined on the structure
If you are loading the View, then you can use fields_view_get to change the string of Buttons.
But I feel in your case, you wanted a Button string to be changed based change of values, if that is the case, then no you cannot change the sting of button dynamically, (because it can be done before loading the view)
However I could suggest you alternate way:
Add as many buttons you need, which has same name property but with different string, use attrs to control displaying of a button. Further instead of character, I would suggest to use a selection field (which reduces error of typing & easy to control buttons)
Assuming that accordingly have a look at the below Example:
<button name='BUTTON_ACTION' string='English' attrs='{'invisible':[('SUBJECT_FIELD','!=','English')]}' .../>
<button name='BUTTON_ACTION' string='Physics' attrs='{'invisible':[('SUBJECT_FIELD','!=','Physics')]}' .../>
<button name='BUTTON_ACTION' string='Maths' attrs='{'invisible':[('SUBJECT_FIELD','!=','Maths')]}' .../>
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Sep 23
|
496 | ||
|
0
Sep 23
|
450 | ||
|
2
Feb 23
|
9251 | ||
|
6
Oct 23
|
19262 | ||
|
3
Mar 24
|
7684 |