Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5062 มุมมอง

Using Odoo 13 Community Version.


I want to copy the name from a selection field not the value with api onchange method.


The selection field ist "vorgang_auswahl":

    vorgang_auswahl = fields.Selection([

        ('gewinde', 'Gewinde schneiden'),

        ('senkung', 'Senken'),

        ('kantung', 'Kanten'),

        ('mikro', 'Mikroecken entfernen'),

        ('schweissen', 'Schweissen'),

        ('schleifen', 'Schleifen')],

        string="Operations", default="gewinde")



The onchange method so far:

    @api.onchange('vorgang_auswahl')

    def _onchange_vorgang_auswahl(self):

        self.name = self.vorgang_auswahl


At the moment i get the value for example "mikro", but i want "Mikroecken entfernen".

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Use the following code:

self.name = dict(self._fields["vorgang_auswahl"]._description_selection(self.env)).get("vorgang_auswahl")

This code does not only apply the real value, but also takes into account translation of that value.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 24
2706
5
ธ.ค. 22
5401
How to show field if selected แก้ไขแล้ว
1
มี.ค. 21
4071
1
ก.ย. 23
3801
2
ก.พ. 23
4007