Skip to Content
Menu
This question has been flagged
1 Odpoveď
5492 Zobrazenia

Hi, I have a button inside an XML view that dispatch a wizard view of another addon, in this way:

```
<record id="view_contact_form" model="ir.ui.view">
    <field name="name">res.partner.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
    <xpath expr="//form//sheet" position="before">
        <header>
            . . . .
            <button name="%(report_generator.action_generate_report)d" string="Privacy Report" type="action" class="oe_highlight"/>
        </header>
      </xpath>
. . . .
```
And this is the action inside the other addon:
```        
<record id="action_generate_report" model="ir.actions.act_window">
<field name="name">Generate Privacy Report</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">cliens.report_generator.privacy_report_model_wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
````
Now I need to pass default data to the wizard, and I need to have a function inside the TransientModel of the addons where the action is.
So I need to call the python method from the first addon passing the res partner record.
Anyone can help me?

Avatar
Zrušiť

Hope these tips will help you in future: https://github.com/sehrishnaz/learnopenerp/wiki

Best Answer

pass values through the context as default_values: value

eg:

return {
'name': _('Shipment Line Items'),
'view_mode': 'form',
'res_model': 'cargo.details',
'view_id': self.env.ref('orderrace_export.cargo_details').id,
'type': 'ir.actions.act_window',
'context': {'default_partner_id': self.partner_id.id, 'default_company_id': self.company_id.id,
'default_name': self.name},
'target': 'new',
}

Avatar
Zrušiť

<field name="context">{'search_default_group_crossevered_budgdet_id': True, 'search_default_filter_not_cancelled':True}</field>

Related Posts Replies Zobrazenia Aktivita
3
okt 23
5825
2
aug 22
3659
6
okt 20
3656
0
júl 19
5462
3
máj 19
3123