Hello All,
I want to get the value of a wizard in pivot value using context.
Here is a code.
PY of wizard :
class DataWizard(models.TransientModel):
_name = 'data.wizard'
_description = 'Data Wizard'
"""Define new fields"""
first_date = fields.Date("First Date", default=date.today())
name = fields.Char("Name")
def action_done(self):
ctx = self.env.context.copy()
ctx.update({'wizard_id': self.id})
return {
'name': 'Pivot Own Reports',
'type': 'ir.actions.act_window',
'res_model': 'get.wizard.data',
'view_type': 'form',
'view_mode': 'pivot',
'view_id': self.env.ref('my_own_pivot.action_get_wizard_data_pivot').id,
'target': 'main',
'context': ctx,
}
XML OF WIZARD:
<record id="view_data_wizard" model="ir.ui.view">
<field name="name">data.wizard.form</field>
<field name="model">data.wizard</field>
<field name="arch" type="xml">
<form string="Data Wizard">
<sheet>
<group>
<field name="first_date"/>
<field name="name"/>
</group>
</sheet>
<footer>
<button name="action_done" type="object" string="Done" class="oe_highlight"/>
or
<button name="cancel" string="Cancel" special="cancel" class="oe_link"/>
</footer>
</form>
</field>
</record>
<record id="action_data_wizard" model="ir.actions.act_window">
<field name="name">data Wizard</field>
<field name="res_model">data.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="view_data_wizard"/>
</record>
</odoo>
PY of Pivot view :
class GetWizardData(models.Model):
_name = 'get.wizard.data'
_description = 'Get Wizard Data'
_auto = False
"""Define new fields"""
product_id = fields.Many2one('product.product', string='Product')
@api.model_cr
def init(self):
"""I need Context of Wizard HERE"""
tools.drop_view_if_exists(self._cr, 'get_wizard_data')
self._cr.execute("""
CREATE or replace VIEW get_wizard_data AS (
SELECT
acc_invoice.id as id,
acc_invoice.product_id as product_id
FROM account_invoice_line acc_invoice
)
""")
Please Help me out.
Thanks in Advance.
Riddhi