Search code examples
python-3.xodooodoo-12odoo-13

SDD Payment via Automated Action (Odoo v13)


Unfortunately Odoo has removed the automatic SSD payment from v12 to v13, which is crucial for me. Therefore I try to reproduce the behavior via an automated action and came quite far I guess.

I created an Automated Action that watches all invoices in draft and runs a python code if the invoice is set from draft to not draft. But unfortunately I get an error as soon as I try to post an invoice:

"Database fetch misses ids (('10',)) and has extra ids ((10,)), may be caused by a type incoherence in a previous request"

As far as I know this is related to type transformation, but as I am new to python & odoo, I am not sure how to transform the odoo datatypes correctly. Does anyone have a hint?

Here's the python code that should be executed:

payment = env['account.payment'].create({
     'payment_method_id' : '6',
     'partner_id': record.partner_id.id,
     'journal_id' :     '10',
     'amount' : record.amount_residual
})

The ids are double checked and link to the correct entries:

  • payment_method_id '6' = my bank account
  • journal_id '10' = SDD Payment

Below please find the current domain applied to the Automated Action. Any hints or help is much appreciated!

Many thanks. Best regards, Christian

Automated Action - Domain


Solution

  • CBfac

    On the many2one field you have to assign the ID.

    Code Correction:

    payment = env['account.payment'].create({
         'payment_method_id' : 6,
         'partner_id': record.partner_id.id,
         'journal_id' : 10,
         'amount' : record.amount_residual
    })