This question has been flagged
1 Reply
5635 Views

i have a model amount.amount()

class amount_amount()

    _name = "amount.amount"

_columns = {

                'name' : fields.float("Amount");

                }

    def action_amount()

         {

        }

amount_amount()

in xml

<button string="Select Amount" type="object" class="oe_highlight" name="action_amount"/>

My requirement is: when i click the above button, i want to select the needed fields from my model. How can i achieve this?

Avatar
Discard
Best Answer

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

  1. "workflow" is used if you want to call workflow. In your case this is not apt one.

  2. "object" is used if you want to call a method which is written in .py file. Here you can select necessary fields within the function but its a sort of static( you wont get a view to select fields). So you need to decide which fields to be selected in your function (python code)

     def action_amount()        # Need to apply some conditions to select fields,
     {
       if   case 1:
             return (amt1,amt2)
       else
             return (amt1 , amt3)
    }
    
  3. "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" and design your wizard with whatever field you need to select based on your functional requirement.

         <button name="%(action_amount)d" class="oe_highlight" string="Select Amount" type="action">
    

    Design your view and put it in a folder namely 'wizard' within your addons folder.

Avatar
Discard
Author

if i select these fields in a popup, can i edit it?

Yes, you can ... it simply act like normal view . You may refer to "Sale order" , there you can add items through a pop up window, what ever value you entered or selected on the last pop up will save it in to the database.

Author

Can you share the code? Or where it starts from?