Skip to Content
Menu
This question has been flagged

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

Avatar
Discard
Best Answer

Hi Zakaria, please pass context as,

context = "{'default_name': display_name}" 

hope it should work.

Avatar
Discard
Author Best Answer

Hi Raaj,

It works!

Also, I had to replace also the notebook page so that the new context values will be taking into account.

Thank you for your help :)

Avatar
Discard
Related Posts Replies Views Activity
0
Dec 24
34
0
Nov 22
879
2
Mar 22
4355
0
Jun 24
470
2
Nov 23
1292