I have bank statement form view like this :
<record id="view_account_bank_statement_form" model="ir.ui.view">
<field name="name">account.bank.statement.formfield>
<field name="model">account.bank.statementfield>
<field name="arch" type="xml">
<form string="Account Bank Statement">
<header>
header>
<sheet>
<div class="oe_title">
<h1>
<field name="name"/>
h1>
div>
<group>
<field name="date"/>
<field name="journal_id" context = "{'parent_journal_id':journal_id}"/>
<field name="balance_start" context = "{'balance_start':balance_start}"/>
<field name="balance_end"/>
<field name="balance_end_real"/>
group>
<notebook>
<page string="Statement Line" name="line_ids">
<field name="line_ids">
<tree string="Bank Statement Lines" editable="bottom" context="{'o2m_active_model': 'account.bank.statement',
'journal_id': journal_id}">
<field name="date"/>
<field name="state"/>
<field name="payment_ref"/>
<field name="ref" widget="handle"/>
<field name="partner_id"/>
<field name="amount"/>
<field name="suitable_journal_ids"/>
<field name="currency_id"/>
<field name="journal_id"/>
tree>
field>
page>
notebook>
sheet>
form>
field>record>
But when I tried to get the context with this code:
context = self.env.context
parent_journal_id = context.get('parent_journal_id',False)
journal_id = context.get('journal_id',False)
Both of them return none, what did I do wrong? I had experience with openerp7, they pass context on the function. But Im not familiar with odoo 16, can someone help me please?
When passing context to fields, it primarily affects views and not Python methods. If you need to pass static context, it's better to pass it through actions. However, without a clear understanding of your specific use case, I am unable to provide further guidance. Thank you.