简体   繁体   中英

Which function is invoked when the save button is clicked in OpenERP6.1

Which function is invoked when the save button(marked red in the attached screenshot) is clicked in OpenERP6.1?

Thanks in advance!!! OpenERP的

To elaborate a bit on DReispt's answer, your screenshot seems to highlight the save button of an editable One2Many line, within a One2Many field of an existing record form. One2Many lines are treated as sub-records of their parent record, so they are supposed to be saved along with the rest of the record data, atomically (in a single RPC call).

In this sense, the save button highlighted on your screenshot does not directly call any method on the server, it simply saves the changes in a local cache in your browser. The real call to create (if this is a new record) or write (if the record is being updated) will only be done when you click on the main Save button of the parent record form afterwards.

At this point, the value of the line will be passed in the map of values provided to create / write , within a list of One2Many commands. See also the documentation of write for more information about setting the value for One2Many fields.

BTW, investigating RPC calls is quite trivial in OpenERP:

  • On the server-side, you can start the openerp-server process with the --log-level=debug_rpc_answer parameter to get detailed logging of all RPC calls
  • On the web client side, you can simply use your web browser's debugger to watch all RPC calls (in the Network monitoring tab). Most JSON-RPC calls correspond to regular OpenERP ORM method calls , and are easily readable once you're familiar with the OpenERP RPC API.

Note: the above is not specific to OpenERP 6.1, it works just the same in 7.0 (though 6.0 and earlier versions of the web client had different behaviors for one2many fields)

The save button will run an ORM method for that Model. For new records, that's the create() method, for updated records it's the update() method.

These standard methods can be overridden in a Model in order to implement additional features.

Your model is subclass of orm.Model'. There are methods in orm.Model'. There are methods in class BaseModel (BaseModel is inherited by Model) which will be call for the save` record. These methods are

def create(self, cr, user, vals, context=None)

If you want to change any behavior for any model then you have to override this method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM