コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
24207 ビュー

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.

アバター
破棄

No issue with code ,

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

著作者

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

最善の回答

Try this

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

Regards


アバター
破棄
関連投稿 返信 ビュー 活動
2
8月 24
6484
2
9月 21
12891
1
8月 21
8419
1
7月 21
4417
1
12月 23
29368