How to pass res_id: - odoo-12

I have a button in my form view from which a pop up window is open for a particular employee..on this pop up window.. i have a new button for employee salary detail. which brings detail about salary of employee on line level...but when i open pop up window and make some inputs and confirm it..this record is not saving.. i also pass res_id : self.id.
please help me..This is the pop up window which is opening from button

Use active_ids to get the current employee then call the write method to save the edited fields.
employees = self.env['hr.employee'].browse(self.env.context.get('active_ids'))
employees.write({'name': self.name, ..})

Related

tabcontrol page not updated

In my winfom program I have a function that change the tabpage when I hit a key.
On tabcontrol indexchanged I check for some parametre and if they are not correct I change the tabpage to the first tab.
If I click on the page with the mouse the tabpage changed to the first tab with the correct content.
If I click a key and run this code "tcOrdre.SelectedTab = tpOrdre;" it changes the tab back to the first but still showing the content of the selected one.
In SelectedIndexChanged is use this code:
MessageBox.Show("Der skal vælges en ordre først"); // Show a messagebox
tcOrdre.SelectedTab = tpOrdreListe; // change tap to first
If I use the mouse then SelectIndexChanged get called when I run:
tcOrdre.SelectedTab = tpOrdreListe; // change tap to first
the SelectedIndexChanged function is called again and the content is okay.
But if I use the key to change index the SelectedIndexChanged does not get called Again and the content never change. Only the tab in the top change to the first one.
I hope someone can help me.
I found the solution.
All I have to do is call this line.
this.BeginInvoke(new Action(() => tcOrdre.SelectTab(0)));
and not tcOrdre.SelectedTab = tpOrdreListe;
And everything Works fine.

Excel Form VBA Combobox reset

This should be easy but I can't seem to find anything to solve. I have a Form in Excel using VBA. The Excel sheet has four columns populated with data and the Form displays those fields.
The user then selects a value in a combobox, uses a command button to submit the responses and the values from the combobox are written to the Excel sheet.
The user then uses a command button to advance one row down in the spreadsheet and load the four values from a new row. This all works great.
The issue I am trying to solve is that the combobox remains selected to the value in the prior selection. I'd like to reset the combobox so nothing is selected and the user has to make a selection again for the next row.
Below is the code I am using to load the combobox and to set a variable for what the user selected. Can't seem to get the combobox back to it's default state after the user has submitted the form.
Private Sub cbDesAccWanted_Change()
Select Case cbDesAccWanted.Text
Case "Yes"
desacc = "Yes"
Case "No"
desacc = "No"
End Select
cbDesAccWanted.Text = desacc
End Sub
Private Sub cbDesAccWanted_DropButtonClick()
cbDesAccWanted.List = Array("Yes", "No")
End Sub
There are two ways to reset the combobox. Take your pick:
1
cbDesAccWanted.Value = Null
2
cbDesAccWanted.ListIndex = -1
the line
cbDesAccWanted.Text = desacc
is totally unnecessary.
Using cbDesAccWanted_DropButtonClick is not the right place to populate the list of values. This list should be set up when the form is first shown to the user.
(unelss the values it shows chnages in which case change it when the row changes or something, not when the user clicks on it)
So when theuser clicks the down arrow to move to thenext record include the following line
Me.cbDesAccWanted.text = Me.cbDesAccWanted.List(1)
Note (1) access teh 2nd item in the list which is No.
So this reset it to the default value of No.
Ok.

Document based app: which is the key window?

The code for the app is here (the Raiseman folder contains the files for the project):
https://github.com/bignerdranch/cocoa-programming-for-osx-5e/tree/master/Chapter%2011%20-%20Undo/RaiseMan
Each Document(window?) contains an NSTableView and two buttons:
The app uses an ArrayController to manage an array of Employees in the Document class, and the buttons add or remove Employees from the array.
I notice that if I click the Add Employee button and start editing the Employee's name in the NSTableView, and then before hitting Return to end editing, if I click on File>New to create a second Document, then click on Add Employee in the second Document, then edit the Employee's name and hit Return, the Return key is sent to the first Document, which ends the editing of the Employee's name in the first Document, while nothing changes in the second Document. Why is that? I expected the window that contains the button I clicked on to be the key window, and therefore the Return key would be sent to the second window.
If I hit Return again, then editing ends in the second Document.
Looks like a bug to me. The NSTableRowData object is observing NSControlTextDidEndEditingNotification for all objects, including the views in other windows.

How do I set size of colums in a table subform datasheet view in MS Access

I have a subform bugging me. The mainform contains buttons etc. Everytime the user close/open the form, the columns width is reset to whatever the table likes. If i open the table directly, the size is as i want. If i change it in the subform, it is not saved. (See screendump)
I would like "Phase" to stay about 2 cm width. I can enter the subform and edit the "Width" but that is only applied to the other views.
I hope you can help, Emil.
I realize this post is almost 2 years old, but I ran into the same problem and came across this post.
I am running MS Access 2013 on Windows 7 Ultimate. I did not find the solutions offered here to work for me, so, I set out to find something that would work for me before I went to VBA code. (Incidentally, I appreciate the link offered by #Patrick_Honorez in his comment on the original post because that was going to be my fall-back solution.)
Anyway, here is what worked for me and I hope perhaps it will work for others as well:
Open the parent form.
In the subform, right-click the column header
for the column for which you wish to adjust the width.
Select the “Field Width” item from the context menu.
In the “Column Width” dialog that appears in step 3, enter the desired column width in points, or, use the [Best Fit] button. Then click the [OK] button to close the dialog and return to the form.
Right-click the parent form’s border to bring up the parent form’s context menu. Click the “Save” item in the context menu.
Now close the parent form.
The next time the form is loaded, the column widths should be as set it step 4 above--at least they are for my setup.
I see this post is quite old and OP must have figured someway to tackle the issue. I came across same issue today and found solution on this link.
For anybody else having same issue, use following code (I modified the code a little because original code from the above mentioned post saves column width of only text boxes but my form has combo boxes too, column width of which was not getting saved) in close and open events of your subform and then open main form in Form View and then manually select desired widths either by mouse, by entering column width value or using best fit. Save the form and reopen to check results. That's it.
Private Sub Form_Close()
Dim ctrl As Control
For Each ctrl In Me.Controls
If (ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox) Then
SaveSetting "propertiesDBS", Me.Name, ctrl.Name, ctrl.ColumnWidth
End If
Next
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim ctrl As Control
Dim frm As Form
Dim w As Long
For Each ctrl In Me.Controls
If (ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox) Then
w = GetSetting("propertiesDBS", Me.Name, ctrl.Name, 0)
If w <> 0 Then ctrl.ColumnWidth = w
End If
Next
End Sub
I know this is late to the party and most likely going to be the last comment anyone reads, but this can be done quite simply in MS Access 2016 - by someone like myself who has no more than 4 days experience in databasing overall and no experience with writing custom Macro's or VB Script (using only what is native to MS Access).
Here's how I did it.
Scenario - Split Form (Form + Datasheet).
Extra Recommendations:
It pays to be across all properties of every object type in your database, as a change in a field property can cause unpredictable erratic effects, which take ages to figure out why it happened and how to stop it from happening again, whilst delivering your desired outcome.
Me.Requery in your VBA script after every necessary event and also in your main form (generally the 'After Update' event is used most), and be wary that too many Me.Requery's (in unnecessary events) can also be detrimental - so too much of a good thing can be a bad thing.
Bottom Line Up Front - Modify the format of your query that is to be exported/printed.
In 'Design View' of the query you are concerned with, ensure that the fields are in the order you need them outputted in first as this is exactly how the macro will present them for export/print (example could be "Australia" then "Northern Territory" then "Town's In The Northern Half Of The State" then "Darwin" then "Suburbs In The Northern Half Of City").
Switch to 'DataSheet View' in the same query and use the top left folded over triangle looking thingy to highlight the entire data set then right click that same triangle to present an options menu. Select 'Row Height' and type in "15" (default row height in Excel).
Deselect the entire spreadsheet and this time select every column (left click the left most column, hold shift button, scroll over to the right to the far end of the data set and click the last column) and then right click one of the highlighted columns to present another menu. Select 'Field Width' and within that new pop-up menu select 'Best Fit' and then 'OK'.
(Optional - not sure if this helps or hinders but I did it for my purpose) With the columns still selected right click one of the highlighted columns again and select 'Freeze Fields'.
My scenario had buttons with macros configured to run filtered reports so I was able to check this by simply clicking any of those buttons and seeing the report formatting, which it held true to the work I had just done. I exported using another button with a macro that exports to Excel with 'Print Formatting' selected (my main form also had the datasheet view as the only thing that could be printed and was also set in 'Print' formatting.
The Excel spreadsheet opened with all row heights and column widths in a way that I could read every field/record with perfect ease and without extra modification.
This also worked for cascaded combo boxes, with the export only outputting the 'drilled down/filtered' datasheet records, in a format that required no further modifications.
Hope this helps someone, as its saved my hide! :)
Open the Main form in Design. Go to the SubForm. Click on the square at the top left of the SubForm and select 'Properties'. Right-Click the control 'Phase' and click 'Properties'.Click the 'Format' tab and select 'Width'. What do you see there? That should control the widht of control 'Phase' unless you have some overriding coding elsewhere. Input the size you want and see what happens.
Use continuous forms instead. It gives you complete control over how your subform displays.
If you open your subform directly, your property sheet menu should display automatically if the default view is "Datasheet." Click on "All" and change the "Auto Resize" property to "No." This should solve the issue and avoid the need for VBA.
This only works when you open the subform separately. So if you want the changes to be reflected within your main form, you'll have to close it and switch back and forth.
Super annoying by default.
It seems to work as one would expect of you set the view mode to layout view. Drag column widths as needed and save. Go back to form view and it works. It's really dumb it doesn't work the same way in form view our design view.
In Access 365, open main form, right-click sub-form datasheet columns that need width adjustment, use the Field Width to adjust, click on border of main form to select Layout view, and save changes.
Open subform in datasheet view (by double click on subform in the left pannel)
Resize columns as you want by dragging or by right-click the column header for the column for which you wish to adjust the width and select the “Field Width” item from the context menu.
Right-click the subform border to bring up the context menu. Click the “Save” item in the context menu.
Either open the Main Form in Layout View or directly open your Subform in Datasheet View. Right Click on the Field Header, select Field Width, and enter the desired width. Save. Bewm.
My solution (Access 2016) was to create the main & subform, recreate the subform on its own using form wizard and set it up the way I want it, rename the original subform to something else, and finally rename the recreated subform to the original form name. Open the main form and the subform should be laid out the way you want it. You can then delete the original subform you renamed.

Dynamically reload a table in a form programatically

I have a form in Dynamics AX which displays a table of two columns in a grid. I also have a button on the form. I am overriding the clicked method of the button to update the Address field of the table. For example, here's my X++ code:
void clicked()
{
AddressTable addr;
ttsBegin;
select forUpdate addr where addr.addressID == 1;
addr.Address = "new address";
addr.update();
ttsCommit;
super();
// reload table here
}
What I would like to do is to add a code to the clicked function which will reload (re-select) the updated records and show them in the form without a need of reopening the window or refreshing it using F5 (for example).
I went through forums and AX documentation and found a few methods like refresh and reread, but they are FormDataSource class methods and I failed to make it happen inside the clicked handler above.
So, what I really want to accomplish programaticallyis what F5 does behind the scenes when clicked on an open form.
Maybe just addressTable_ds.research(true); will do the job.
See also Refresh Issue on the form when the dialog closes.