Hello everyone,
I want to pass the display_name showed in the form of 'account.move' to all its journal entries in 'account.move.line'.
I want this name to be printed as a default value in all items of 'account.move.line'. I tried to pass this variable through the context method and here is my codes:
The '.xml' file:
<record id="view_move_form_inherited" model="ir.ui.view">
<field name="name">account.move.inherited</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<field name="line_ids" widget="one2many_list" context="{'line_ids': line_ids, 'journal_id': journal_id, 'name': display_name}">
<tree editable="bottom" string="Journal Items">
<field name="account_id" domain="[('company_id', '=', parent.company_id), ('deprecated', '=', False)]"/>
<field name="name"/>
<field name="debit" sum="Total Debit"/>
<field name="credit" sum="Total Credit"/>
</tree>
</field>
</field>
</record>
Then in the .py file, I set the name default value as:
class accounting_move_line_inherit(models.Model):
_inherit = 'account.move.line'
name = fields.Char('name')
_defaults = {
'name': lambda self, cr, uid, context: context.get('name', False),
}
However, whenever I add an item inside a journal entry nothing is showing inside the name field
I will appreciate any help?
Thank you