Setting active a page(tab) in a notebook of form view - odoo

I'm developing a module for openerp v7.
I've defined a workflow and in my view defined a form with a notebook which contain as tabs as status defined in workflow.
In every tab i've a button which triggers the change of status of the workflow. All of this works like a charm!
The problem I am facing is that when the button triggers the workflow status change, the status changes but the tab marked as active is not changed, as far i know this is the expected behaviour, but i would like to change the active tab when the status of workflow changes and i didn't find any way to do it.
INFO: According to the DOCS there is a way of doing this with the fields:
default_focus: set to 1 to put the focus (cursor position) on this field when the form is first opened. There can only be one field within a view having this attribute set to 1 (new as of 5.2)
But no way with pages...
Any help would be very appreciated.

I think that making a tab to be active is not the expected behavior with a workflow. Normally, buttons are putted in the header next to the statusbar, and each button have the "states" attribute to define those status they must appear in (according with the "state" field of the model).
If you want to show/hide some information (say field, group, page, etc) according to the workflow status, you can use the "attrs" parameter with the "invisible" option restricted to a domain over a "state" field value.

If you want to use JavaScript, you can use this to focus a tab page:
$('.oe_notebook #ui-id-3').click()
Where ui-id-3 is the 1 based index of the tab page. Here it would be the third page. Works in v8, can't tell for other versions. Hope it helps anyway :)

Related

Radio buttons used in a rad grid in batch edit mode

I am trying to find any information about using a radio button in a rad grid in batch edit mode. I have created a template column, then added the radio button control, but it doesn't work in batch edit mode (nothing saves back to the DB). Is it even possible? I can't find anything on the Telerik site so I am suspecting its not supported. Thanks.
The Radio list is not supported in the batch editing mode. Such integration simply has not been implemented. The closest available option at this time is using a dropdown list: http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx. Generally speaking, the standard way of editing boolean fields is through a checkbox column and not a radio button list - check the Discontinued checkboxes column.
What the grid does is that it loops through the controls with JS code when cells are opened and closed and determines control types and the proper API to use (e.g., $get().control.get_value() for dropdownlists, or $get().value for standard inputs). You can try implementing similar logic in the batch editing events.
You can try to use a RadRadioButtonList with the two items declared in its markup and its client-side API (see the get_selectedIndex() and set_selectedIndex() method: https://docs.telerik.com/devtools/aspnet-ajax/controls/radiobuttonlist/client-side-programming/radiobuttonlist-object) together with the following approach of working with templates: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/working-with-templates.
The idea is to have the radio button list in the edit template of the column and to select the correct item in it according to the newly opened cell value on the client, then fetch the selected item from the button list and put it in the grid data source.
You can find one example that you can try using as base in the following thread: https://www.telerik.com/forums/radiobuttonlist-in-gridtemplatecolumn.
Showing a radio button list in the item template is also something that is not supported, as the editing would basically happen in the "display" mode of the cell, and not in the edit mode of the cell. You could try using the server ItemDataBound event and FindControl() (see here: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-template-column) may let you set initial values based on the data source for the radio button lists without data binding them. Then, perhaps a hidden field or hidden checkbox can be used for the actual data binding (see the template article above). You could also try using the batch editing manager changeCellValue() method on the client-side events of the radio button list, in a fashion similar to this article: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/how-to/editing-checkboxes.
Another approach you can consider is to use the client-side events of the radio button list and immediately upon change to call a service that will update the database. This may simplify the template handling logic (you could do this in a read-only column) but it goes against the purpose of batch editing to invoke one request with a lot of data, and you would also need to secure the service.
Another online resource to check is
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/how-to/editing-checkboxes

Oracle Forms Tab Detail

I am using Oracle Forms. I want to know how to determine which tab the user is on at run time.
For example: I have created four tabs in my canvas A,B,C,D. At run time, how do I get to know which tab is currently being accessed by the user?
With
Get_Item_Property(:system.cursor_Item, ITEM_CANVAS)
you can get the canvas name of the item. This will return the name of the tab control page. If you use the following command with this name:
GET_CANVAS_PROPERTY(canvas_name,TOPMOST_TAB_PAGE);
you will get the name of the tab that is activated at this moment

How do I add a global button (for all entities) on the CRM 2013 Command Bar

I want to create a global button for all the entities.
I tried the following:
Created a sample solution with entity Application Ribbon
Opened the Application Ribbon Entity in Ribbon Workbench
Under Command Bar -> Home . Placed a button besides New Record
However after publish I am not able to view the button.
How do I resolve this?
The answer is from Mithilesh Kumar, and can be found on this page:
https://community.dynamics.com/crm/f/117/t/155542
You need to find the Group where you want to show the Button.
If you want to show on the Home Page for all Entity, find the Group as below and place the Button in this Group.
If you want to show in the Forms of all Entity, you need to place in the Group in the Form Area, shown below
Hope that clarifies
Modifying the XML you need to rely on the {!EntityLogicalName} keyword inside the location.
You can find a tutorial here:
http://blog.webfortis.com/adding-global-ribbon-buttons-for-all-entities-in-dynamics-crm

Setting up recycle bin functionality in Archer GRC

When deleting records within the platform, this action is not reversible via the front end. Is there a way to allow users to remove a record from their view without actually deleting the record?
You can simulate recycle bin functionality within Archer GRC by adding a record permission field that grants read access to "Everyone". If read access is no longer required then an editor of the record can go in and change "Everyone" to a group called "Recycle Bin."
Please note that if there are other record permission fields in the application, users or groups may still have access if they are selected in those fields. Perhaps You can set up a dropdown status field for the user to select "Recycle Bin" and use this condition for automatic record permissions to revoke permission to the record depending on the requirements or workflow of the application.
Solution shared by Igritte might be somewhat confusing for end users.
End user will see greyed out "Delete" button in the top toolbar, but he has to select "Recycle Bin" in the form. This solution was not accepted by my business owner at some point.
As a work around for "Soft delete", I wrote a custom object overriding "Delete" button functionality.
1. User doesn't have delete access to the record, so JavaScript code will make "Delete" button look like active and available.
2. Once the button is clicked, custom object will populate value in the
hidden value list and simulate the click on the "Save" button.
Update: Note that Custom object needs to hide the value list first once the page is loaded. Here you will need to use a JavaScript and do the following: [a] locate the value list DOM object and [b] set display attribute to none. I used jQuery library to do both. This way your value list is not displayed, but you still can use it to control data driven events.
3. With hidden value populated and submitted, record permission will hide this record from the end user.
Note that custom object hides one value list on the layout as well.
If for some reason JavaScript doesn't load properly, user simply will not be able to click on the grayed out "Delete" button.
Update: Hidden value list can be populated by custom object using JavaScript code as well. You need to identify the form tag "input" in HTML code of the page and set attribute "value" to the desired state. I used jQuery library to do this as well.
I have this solution in production working fine with IE11, FF and Chrome.
I can't share the code, but with WC3Schools JavaScript guides and 4 hours you can write and test it yourself with very little JavaScript skills.
Sometimes you have to use custom objects when you want to get a user-friendly solution of not available functionality.
Good luck!

Findrecord always go to first record before the good one

I got a problem with a form showing the follow ups of a proposal.
I made a form where you can navigate to the next follow up and the previous one.
The problem is that when I use the navigation buttons, it adds a follow up to the current proposal.
I realized that the follow up created is always the same one (the id is 83) and actually it's one made for another proposal. So every time I navigate, it updates this particular follow up and change the proposalId for the current.
here's the code for one of the navigation button:
Private Sub btnShowPrevious_Click()
Save
FindRecord "ID", txtParentID
End Sub
Because the wrong id is always the same (83), in the current form event I added an alert and found out that before to show me the good follow up, it always go to the 83 for a millisecond.
here are the steps to get this weird behavior
create new follow up and save
create his child and save
close the form
open parent or child follow up
use the navigation button
then it goes to the 83 before to show the good one.
If i press again any navigation buttons, it won't happen.
And if I don't close the form after saving and use the buttons, it works.
it's like if there's a default follow up id while he's looking for the follow up I request.
I don't know if it's clear.
I set the fetch defaults, the filter on load and allow filters properties to "No".
Also, when I open the form in view mode from the design mode, the default record is the 83.
so why when I do a findrecord it goes to the default record before to go to the good one?
EDIT
Finally, it's always the first record
Why it shows the first record when I do the findrecord before to find the good one.
Does anyone have an idea why this is happening
Thank you.
I got it...
I tested it in another project and while I was writing Findrecord I noticed some parameters were missing.
I checked and it was a method I made ( I don't remember why I made my own method for this)
There was a Me.Filter = "".. that was reloading the form to the first record.
Thank you