Skip to Content
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
Opusti
Best Answer

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
Opusti
Avtor

You are exactly right!! Thanks!!

Best Answer

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
Opusti
Avtor

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.

Best Answer

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

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

Avatar
Opusti
Avtor

Thank You I adopted this too. Nice weekend.

Related Posts Odgovori Prikazi Aktivnost
1
feb. 24
1773
0
jul. 16
3568
0
maj 15
6527
2
jun. 24
3226
0
maj 24
1286