This question has been flagged

I tried (for several days) to pass the context from my js view to my xml field.

The JavaScript function has a default create button, i have button in my js code:

odoo.define('invoice.action_button', function (require) {
"use strict";
var core = require('web.core');
var ListController = require('web.ListController');
var rpc = require('web.rpc');
var session = require('web.session');
var _t = core._t;
ListController.include({

    dispatch_to_new_action: function() {
        this.do_action({
            context: {'default_gender': 'Male'},
        });
        console.log('hello')
    },

   renderButtons: function($node) {
        this._super.apply(this, arguments);
            var btnsDiv =  this.$buttons;
            if (this.$buttons) {
                var createBtn = this.$buttons.find('.o_list_button_add')
            }

and I want that by clicking on my button, I open a form with a field context={default_gender='gender'} already filled. Here is my xml

<field name="arch" type="xml">
            <form string="Student">
                <header>
                    <button name="button_done" string="Done" class="oe_highlight" type="object"/>
                    <button name="button_reset" string="Reset to Draft" states="done,cancel"
                            class="oe_highlight" type="object"/>
                    <button name="button_cancel" string="Cancel" type="object"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,done"/>
                </header>
                <sheet>
                    <field name="photo" widget="image" class="oe_left oe_avatar" />
                    <div class="oe_title">
                        <h3>
                            <field name="name"/>
                        </h3>
                    </div>
                    <group>
                        <group>
                            <field name="age"/>
                            <field name="gender"/>
                        </group>
                        <group>
                            <field name="student_dob"/>
                            <field name="student_blood_group"/>
                            <field name="nationality"/>
                        </group>
                    </group>
                </sheet>


python code for feild:

    gender = fields.Selection(
    [('male', 'Male'), ('female', 'Female'), ('others', 'Others')],
    string='Gender')
Avatar
Discard