Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
11350 Visualizações

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
Cancelar
Melhor resposta

Hi Zakaria, please pass context as,

context = "{'default_name': display_name}" 

hope it should work.

Avatar
Cancelar
Autor Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
mar. 25
1611
0
nov. 22
1676
2
mar. 22
6293
0
jun. 24
2183
2
nov. 23
2995