콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
24596 화면

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
6923
2
9월 21
13385
1
8월 21
8802
1
7월 21
4716
1
12월 23
30144