Skip to Content
Menu
This question has been flagged
1 Reply
1445 Views

I created an action button on the form view stock.view_picking_form. The button should open the same tree / form view with the return operations of the active partner on the form view from which I am starting (I know that they are return operations through a custom field populated at the time of the creation of the return record on stock. picking). I would like to know if the value of partner_id is available in that time and how it can be referenced in domain or in search_default context. My code is:


    <record id="act_return_carico_fiduciario" model="ir.actions.act_window">

            <field name="name">Restituzione carico fiduciario</field>

            <field name="res_model">stock.picking</field>

            <field name="view_mode">tree,form</field>

            <field name="domain">[('cf_end_date','!=', False), ('partner_id'), '=', ????????]</field>

           <field name="context">{'search_default_partner_id': ????????}</field>

            <field name="groups_id" eval="[(4, ref('sales_team.group_sale_salesman'))]"/>

    </record>


    <record id="view_picking_form_inherit_carico_fiduciario" model="ir.ui.view">

        <field name="name">stock.picking.view.carico.fiduciario</field>

        <field name="inherit_id" ref="stock.view_picking_form"/>

        <field name="model">stock.picking</field>

        <field name="arch" type="xml">

            <div name="button_box" position="inside">

                <button class="oe_stat_button" name="%(carico_fiduciario.act_return_carico_fiduciario)d" string="Restituzioni" type="action"

                    icon="fa-ticket" help="Restituzioni TdV" attrs="{'invisible': [('enable_car_fid', '!=', True)]}">

                </button>

            </div>
............

Can someone help me? thank you

Avatar
Discard
Best Answer

Hi,

Your button is of the type "action" , it would be easy if it was of type="object".
Because multiple domain conditions can be placed in py file than in xml.
Here in your case you may try with,

<field name="domain">[('cf_end_date','!=', False), ('partner_id', '=', context.get('partner_id', True))]</field>
<field name="context">{'search_default_partner_id': 1}</field>

 Make sure you have given the partner filter in search view.

Hope it helps,

Thanks

Avatar
Discard