Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Add a field from model to a popup window?

By
Remya
on 9/24/13, 2:37 AM 1,516 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?

0
nishad
On 9/24/13, 10:52 AM

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.

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

Remya
on 9/25/13, 2:27 AM

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.

nishad
on 9/25/13, 2:53 AM

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

Remya
on 9/25/13, 6:27 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 9/24/13, 2:37 AM
Seen: 1516 times
Last updated: 3/16/15, 8:10 AM