Skip to Content
Menu
This question has been flagged
2 Replies
2398 Views

I am creating a journal item in line_ids but it is creating it in invoice_line_ids too. How can I make sure to it only create a line in journal item. below is the code I am using:

for rec in records:

    vals = {

        'account_id': 36,

        'name': 'With Holding Tax',

        'price_unit': 5.88,

        'quantity': 1,

    }

    rec.with_context({'check_move_validity': False}).write({

        'line_ids': [(0, 0, vals)]

    })





Avatar
Discard
Best Answer

Hi,


If you want to add values in line_ids without affecting invoice_line_ids you have to create an account move that is a journal entry with move_type as an 'entry'.


for rec in self:

    vals = {

        'account_id': 36,

        'name': 'Withholding Tax',

        'price_unit': 5.88,

        'quantity': 1,

  }

    rec.with_context({'move_type': 'entry'}).write({

        'line_ids': [(0, 0, vals)]

  })


Regards

Avatar
Discard

in odoo 18 I tried to add a new line in journal items as credit
the line added but the line is shown also in invoice lines
how to prevent this to happen ?

Author Best Answer

Thank you so much it have worked.Moreover i also have tried something which also have yield result by adding display_type field in dictionary.

for rec in records:

    vals = {

        'account_id': 48,

        'name': 'With Holding Tax',

        'debit':37.5,

        'display_type':'tax',

    }

    rec.with_context({'check_move_validity': False}).write({

        'line_ids': [(0, 0, vals)]

    })

Avatar
Discard