name of type=“action” in openerp button

2019-04-11 00:38发布

问题:

I've a problem when I want to make button in type="action", it's really different with type="object". I just want to make button that can connect one module to another. It already exists in openerp for a few buttons of type="action". I just want to understand what is the function of "name" of this button?

I have an example, I found this xml script in backend sale folder:

<button name="%(action_view_sale_advance_payment_inv)d"
 string="Create Invoice"
 type="action"
 states="manual"
 class="oe_highlight"
 groups="base.group_user"/>

when I installed sale module, then I see the xml script in frontend sale.order.form, it's already change into:

<button name="278"
 string="Create Invoice"
 type="action"
 states="manual"
 class="oe_highlight"
 groups="base.group_user"/>

What's happening with the "name"? Can anyone give me a simple button of type="action"?

回答1:

There are three kinds of types for button: object, action & workflow. workflow is the default.

Now let's understand the meaning of these three types:

  1. object is used if you want to call a method which is written in .py file.

  2. action is used if you want to call any action which is written in .xml file. Let say if you want to open a wizard from button click then you can use type="action".

  3. workflow (the default) is used if you want to call workflow.


<button name="%(action_view_sale_advance_payment_inv)d"
 string="Create Invoice"
 type="action">

when Create Invoice button is clicked, you will see a wizard.

<button name="278" string="Create Invoice" type="action">

Here 278 is an ID in postgresql database of action_view_sale_advance_payment_inv action.



标签: openerp