Recently, there is a need in the company, that is, when the business people click on a list of orders to open a new window action, and then take some of the values in this record, so that the effect in web development is very simple, perhaps minutes of things. But in the client this development is really not easy, especially openerp this has a lot of constraints in the framework.
So how does it work?
This place my idea is divided into two main steps: 1. Open a new window (Form view) 2. Bring the values into the new window. In the first step, I create a wizard in the view as usual, then assign a value to the name and ID, and then create a wizard file (the name and name are the same), and do an import *in _init.py. PY, when these are ready to start thinking about how the wizard program can be opened a new window, the General Wizard file will have such a program in the click of the wizard button to do an initial pop-up control and after the operation, But the demand here is to open a new form page directly after clicking, so there is no need to write both Init and write confirm, directly in the init to write our actions and results can be.
, so this place we write:
Actions inside the _do_confirm function we can return to empty, mainly the following action, it takes a little thought, in this function we need both to take the current record value, there is a need to open a new window, at the same time to pass these values over, 1.1 points, Start by looping the value we want to assign to the corresponding variable, and open a new window in a way similar to the following.
But there is a problem so that the open window is a tree-like view that does not meet the requirements because the last parameter of the first line of code in the red box the reference (ref) view of the action I am using is the tree, In the corresponding view file, write a new action to refer to the Form view, OK, so you can open a new window, the first step is completed.
The most important step is to pass the value over, what to do?
First put the previous value into the context of the result dictionary, and then return as a return value, it should be noted here: Return the value back after the fact is in the background through, so even if we use a similar
result[' context ' = {' Key1 ': value1, ' key2 ': value2, ' Key3 ': value3, ' Key4 ': value4} (Here the Key1 to key4 corresponding to the new open window page of the section of the label) will not show these values on the open page, think of PHP web development, because there is a conventional mechanism of get and post, so receive value completely no problem, If you do not have to use both methods Ajax and jquery to achieve the correct receive value, and OE inside the client does not do any business processing, so this place more need we want to get the value of their own, at first I think is can use the Create method, at the time of creation to write the value, But failed, because create is a click on the save or commit when the value is passed, it can not be used to receive values, and then we think of rewriting _field_get () is feasible, tried and did not write values, this why I did not delve into, the last thought is the default value of the way, At the beginning of OE we often add default values for some items to reduce the input or selection, by writing the function to get the default value in _default, we can write the default value to the corresponding field of the new page, and finally find the test pass.
This is so much, if there is any doubt, welcome to the following message.
How to achieve a small effect in web development in OE development