Create journal entry using code – odoo

   #Posting journal entries
    def action_done(self):
        for rec in self:
            debit = credit = rec.currency_id.compute(rec.paid_amount, rec.currency_id)           
            if rec.state == 'draft':
                raise UserError(_("Only a Submitted payment can be posted. Trying to post a payment in state %s.") % rec.state)

            sequence_code = 'hr.advance.sequence'
   = self.env['ir.sequence'].with_context(ir_sequence_date=rec.payment_date).next_by_code(sequence_code)
            move = {
                'name': '/',
                'date': rec.payment_date,

                'line_ids': [(0, 0, {
                        'name': or '/',
                        'debit': debit,
                    }), (0, 0, {
                        'name': or '/',
                        'credit': credit,
            move_id = self.env['account.move'].create(move)
            return rec.write({'state': 'paid', 'move_id':})

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s