Which odoo base method called for each creation , deletion, drag&drop action odoo9? - drag-and-drop

Which odoo base method called for each creation , deletion, drag&drop action? I know field_view_get called once refresh page.
Basically, I need method which is called on treeview table action. including all (CRUD, Drag and drop)

when creating record
#api.model
def create(self, vals)
....
when updating or edit record
#api.multi
def write(self)
....
when delete or unlink record
#api.multi
def unlink(self)
....
name get for many2one field name
#api.multi
def name_get(self)
....

Related

Dynamically generated form in PyQt

Let's say I've the following class:
class Person(object):
def __init__(self, attributes):
# Attributes is just a dictionary (string -> value)
self.attributes = attributes
def set_attribute(self, attribute, value):
self.attributes[attribute] = value
# Some other code which may cause the value of other attributes to change,
# or other attributes to be added or deleted too
Now I'd like to create a PyQt dialog with a simple form, but which is dynamically generated (to account for the variable number of attributes). I did this by creating a QFormLayout in a QDialog and adding a row for every attribute the Person object has:
self.formLayout = QtWidgets.QFormLayout()
for attribute in self.person.attributes.keys():
label = QtWidgets.QLabel(self)
label.setText(attribute)
lineEdit = QtWidgets.QLineEdit(self)
lineEdit.textEdited['QString'].connect(self.onAttributeChanged)
# or use a checkbox instead of a line edit if the attribute is a boolean,
# combo box if it's an enum or similar, etc.
self.formLayout.addRow(label, lineEdit)
Where onAttributeChanged() calls self.person.set_attribute with the appropriate attribute and the new value inputted by the user.
Now that takes care of updating the model with the user's input values, but the problem I'm facing is how to update the view when set_attribute modifies the person's other attributes (since set_attribute may add or delete other attributes, or change the other attributes' names or values). So far, I've considered to following:
Rebuild the entire form whenever information changes. There's probably something better than this.
Use the Qt signal/slot model, like I did by connecting lineEdit to onAttributeChanged. From what I understand, this means using pyqtSignal to create signals in my Person class representing the attribute names, plus emitting the appropriate signals whenever the names are modified. However, I'd like to keep my Person class intact, and free from any Qt .emit() calls. (Not to say this still doesn't handle the case of attributes being added/removed.)
Ditch the form altogether and use a table view with a QStandardItemModel instead. Not ideal since I really wanted a form and not a table (for the sake of better usability).
Is there some elegant way of handling this kind of dynamic form in PyQt?

Hyperlink button to open a file

I have a Table (Table1) with a list of PDF files, and its Form (Form Table1).
In "Table1" I have a hyperlink field (PDF) and I want a button in "Form Table1" to open that hyperlink. I tried to select this button, go to Event>On Click>Code Builder and type
Private Sub Command1_Click()
Application.FollowHyperlink PDF, , True
End Sub
What is the correct method I should be using to achieve this?
An easy way would be referencing the pdf file's location by referring to the HyperlinkAddress using some VBA. Put this code on a button or whatever event you please:
Private Function Get_Link()
Me![mybutton].HyperlinkAddress = _
Nz(DLookup("[filename]", "[my_files_table]","[my_files_table].[id]=" & Me![id]), "")
End Function
To update the hyperlink you can refer to the Hyperlink's ID or primary key in a form by firing an event like: OnCurrent: Get_Link()
This would retrieve the current ID on your form and use that to get the hyperlink you want.
Reference: Bytes.com

Access Form Go To Record

In Access, I have a main form with a listbox. The listbox is used to navigate to different records on the main form. The main form also has a button with the following code to open a dialog form on which I add a new record.
Private Sub New_Btn_Click()
DoCmd.OpenForm "New Issue", , , , acFormAdd, acDialog
Requery
Me.ID_Box.SetFocus
End Sub
After I close the dialog form, I want the listbox to update and to select the new record that added on the "New Issue" form AND I want the main form to navigate to the new record.
I cannot figure out how to make either of these actions occur. Please help me find the best method for these steps.
Assuming the listbox has a rowsource, you can requery the ListBox to show the new record like this:
ListBox1.Requery
Then to move the 'main' form to the latest record (assuming the ID/PK is an autonumber field, which is how the form recordsource is sorted):
DoCmd.GoToRecord , "MainFormNameHere",acLast
If you don't have an ordered recordset, you can use
Me.Recordset.FindFirst "PrimaryKeyField = " & NewRecordPK
Where NewRecordPK is a variable with the new records primary key stored.
You could call this from the dialog if you like. Just make sure you save the record first using something like Docmd.Save Then,
Forms!frmMainForm.Form.Recordset.FindFirst "PrimaryKeyField = " & Me.PrimaryKeyField

Need to fire an event after entering text in a text_field

I have a need so as to enter some text in a text field and then tabout of the text field so that the value in the text field gets validated by a service. I tried to click some other elements in the page but that apparently did not trigger an event to call the service. Is there a workaround in this case? Thank you!
class MyPage
include PageObject
text_field(:txtinput, :id => 'textV1')
span(:for,:id => 'For' )
def enter_my_info(data)
self.txtinput = data
self.for_element.click # click someother element in the page
end
end
That type of behaviour often is often triggered by an 'onblur' event. You can manually trigger this use the page object element's fire_event method.
def enter_my_info(data)
self.txtinput = data
self.txtinput_element.fire_event('onblur')
end
If that does not work, you could try mimicking the user behaviour and input a tab character. You can send special keys via the send_keys method.
def enter_my_info(data)
self.txtinput = data
self.txtinput_element.send_keys(:tab)
end
Have you tried sending the tab key on the element
http://watirwebdriver.com/sending-special-keys/
I've ended up just clicking parent:
t = b.text_field(class: 'uploadFileTitle', tracknum: index.to_s)
t.set(track.name)
t.parent.click // loses focus here

How to move current record from a form to another form in access?

I would like to move the current record meaning all the field for the current person in that form to another form which is one table to another table via forms. Using one command button. How can I do that?
I am thinking to use add & delete action to put in one button as it look like another way of moving too. But I have no ideas how to put only one record which is from the current person in that form. something like "current session"
In access.
Basic step ..
Assume that you have Datagrid control named dgvMember in Form1 and dgvNonMember in Form2
You can create button named btnMoved that have click event like this ..
Private Sub btnMoved_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoved.Click
//retrieve currentrow info from dgvMember -- all column as datagrid.row
//put the retrieved row to dgvNonMember -- directly to table/datasource
//it's now safe to delete selected row in dgvMember
End Sub