How to implement a small effect in web development in OE development, oeweb

Source: Internet
Author: User
Tags php web development

How to implement a small effect in web development in OE development, oeweb

Recently, the company has a requirement that when a business employee clicks a certain item in the order list, he wants to open a new window action and then take some values in this record with him, such an effect is very simple in web development, and may be a matter of minutes. However, it is not easy to develop the client, especially in the framework with many restrictions such as OpenERP.

So how to implement it?

In this place, my idea is mainly divided into two steps: 1. open a new window (Form view) 2. Bring the value into the new window. In step 1, I create a wizard in the view according to daily operations, assign values to the name and id, and create a wizard file (with the same name and name ), at the same time in _ init. in py, make an import*. Py, after all these are done, start to figure out how to write the wizard program to open a new window, in a general wizard file, there will be such a program that will perform initialization control and subsequent operations when you click the wizard button, however, the requirement here is to open a new Form page directly after clicking it, so there is no need to write both init and confirm, and write the action and result in init directly.

So here we write:

The _ do_confirm function in actions can return NULL values, mainly for the following actions. You need to get the value of the current record in this function, you need to open a new window and pass these values over at. First, we need to loop out the values to assign values to the corresponding variables, open a new window in a similar way.

However, there is a problem. In this way, a tree view does not meet the requirements, this is because the reference (ref) view of the action used by the last parameter of the first line of code in the red box is tree, write a new action in the corresponding view File to reference the Form view. OK, so that you can open a new window. The first step is complete.

The most important step is to pass the value over. What should I do?
Put the previously obtained value in the context of the result dictionary, and then return the value as the return value. Note that after the value is returned, it is actually passed in the background, so even if we use a similar
Result ['context'] = {'key1': value1, 'key2': value2, 'key3': value3, 'key4 ': value4} (here, key1 to key4 correspond to some labels on the newly opened window page) does not display these values on the opened page. Think about PHP web development, because there is a conventional mechanism such as GET and POST, there is no problem with the receiving value. If you do not need these two methods, you must use Ajax and jQuery to implement the correct receiving value, in addition, the client in OE does not process any business, so we need to find a way to obtain the value by ourselves. What I first thought was whether the create method could be used, write the value during creation, but it fails because create transfers the value when you click Save or submit. It cannot be used to receive the value, then we thought about whether it was feasible to rewrite _ field_get (). I tried it and didn't write the value. Why didn't I go into details? The last thought was to use the default value, at the beginning of OE, we usually add default values for some items, To reduce the input or selection operations. By writing the function in _ default to get the default value, you can write the default value to the corresponding field on the new page, and finally find that the test is successful.

If you have any questions, please leave a message below.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.