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

how to pass context from XML to JavaScript?

By
Nathan Thornton
on 3/11/14, 3:07 PM 1,973 views

I have been trying (for days) to pass the context from my XML view to my own JavaScript function as I need the active_id.

The JavaScript function gets data from an external source and populates the table with it, but I need to get the current active_id... Please help!!! This has been driving me insane, all I need is the active_id and nothing else. If there is a way to get this from a pre-existent variable within JavaScript, please let me know what it is.

If I need to use Python, I can, but I do not know how to actually populate my table (it can't be a field) from Python as the documentation does not actually say where returned values go...

Here's an example of my code:

<record id="my_module.example_form" model="ir.ui.view">
        <field name="name">my_module.example_form</field>
        <field name="model">res.partner</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Example Form" version="7.0">
             <script type="text/javascript">
                 $('#My_Table').ready(function() {
                     buildAccountsTable(context);
                 });
             </script>
                <table id="My_Table">
                 ...
                </table>
           </form>
         </field>
</record>

Hi did you succeed? I need help along the same lines

Billiard R Made
on 12/6/14, 1:42 PM

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

4 follower(s)

Stats

Asked: 3/11/14, 3:07 PM
Seen: 1973 times
Last updated: 4/21/15, 6:14 AM