Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

Hi! 


I'm trying to show sale order payment term in picking form as a read-only field.

My code:


class stock_picking(models.Model):
    _inherit = 'stock.picking'

    payment_term_id = fields.Many2one(
        'sale.order','Payment Terms',
        related='sale_id.payment_term_id',
        readonly=True
    )

Compilation & Installation OK. BUT when trying to open delivery form I get an error:

Odoo Server Error
Traceback (most recent call last):
  File "C:\Odoo 13.0\server\odoo\api.py", line 753, in get
    value = self._data[field][record._ids[0]]
KeyError: 25


What is wrong? Any help will be greatly appreciated!!
Happy weekend for everyone.
Regards,

Antti
Avatar
Zrušit
Nejlepší odpověď

Hi Antti Kukko ,

    Error is because you are given model name 'sale.order' , Change Model name to 'account.payment.term'

 payment_term_id = fields.Many2one('account.payment.term',

 string='Payment Terms',related='sale_id.payment_term_id',readonly=True,)

:)

Avatar
Zrušit
Autor

You are exactly right!! Thanks!!

Nejlepší odpověď

Hello,

I think you have not defined field correctly.

try this:


payment_term_id = fields.Many2one(
        'payment.term', string='Payment Terms',
        related='sale_id.payment_term_id',
        readonly=True
    )
Avatar
Zrušit
Autor

This was a crucial advice!! Thank You very much!! I wrote the following and now it works!! Thank You!!

payment_term_id = fields.Many2one(

comodel_name='account.payment.term',

string='Payment Terms',

related='sale_id.payment_term_id',

readonly=True

)

in odoo 13, payment.term is the model name.

Alright your problem solved.

Nejlepší odpověď

class stock_picking(models.Model):  Class name will be like

class StockPicking(models.Model) and run I am sure it will work.

Avatar
Zrušit
Autor

Thank You I adopted this too. Nice weekend.

Related Posts Odpovědi Zobrazení Aktivita
1
úno 24
1765
0
čvc 16
3561
0
kvě 15
6522
2
čvn 24
3221
0
kvě 24
1281