تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
5029 أدوات العرض

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أغسطس 24
2684
5
ديسمبر 22
5380
1
مارس 21
4053
1
سبتمبر 23
3764
2
فبراير 23
3973