İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
24118 Görünümler

I added a filed company(It's a char field), when creating a payment ,I want to set default value. When creating new payment, the value wasn't displayed in the form view . 
I  have problem on condition if self.payment_type == 'outbound', it is not entering in if condition.                     Any help please? What's wrong in my code ?
class AccountPayment(models.Model):

     _inherit = "account.payment"    


    def get_company(self):
        if self.payment_type == 'outbound':
            my_company = self.env.user.company_id.name
            return my_company
        else:
            return None

    company = fields.Char(string='Company Name', default=get_company)

Thanks.

Avatar
Vazgeç

No issue with code ,

try printing payment_type before if condition and check its outbound or not .

Üretici

I got always a 'False' value in payment_type . @Kiran Mohan

En İyi Yanıt

Try this

def get_company(self):
        if self._context['default_payment_type'] == 'outbound':
            return self.env.user.company_id.name
        else: return None

Regards


Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Ağu 24
6374
2
Eyl 21
12802
1
Ağu 21
8346
1
Tem 21
4354
1
Ara 23
29113