Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
24120 Weergaven

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
Annuleer

No issue with code ,

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

Auteur

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

Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
aug. 24
6376
2
sep. 21
12806
1
aug. 21
8349
1
jul. 21
4356
1
dec. 23
29118