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

hi all,

I want to search string like using postgresql substr and position, how i can do this in odoo

a  = fields.Char(default='ABCD-XYZ-MNOP')

if i want to search XYZ (it can be anything else like 'Smith' or 'John' etc.), search between 2 '-' characters, the '-' characters are here for the formatting which will used by default. how i can do it with  onchange function using a compute field.

here is screenshot what i did in Oracle using simple SQL:


regards

아바타
취소
작성자 베스트 답변

ok, got help from @SDBot (thanks to him) on stackoverflow as below, its working fine.

class UserInfo(models.Model):
    _name = 'tests.userinfo'
    _description = "Test User Information"
    userid = fields.Many2one('res.partner', string='Select User')
    cnic = fields.Char(string='CNIC', store=True)
    cnic_ess = fields.Char(compute='_compute_cnic', store=True)
    @api.onchange('cnic')
    def _compute_cnic(self):
        for rec in self:
            split_str = (rec.cnic or '').split('-')
            rec.cnic_ess = split_str[1] if len(split_str) > 1 else ''
아바타
취소
관련 게시물 답글 화면 활동
4
3월 25
8799
4
3월 25
9579
0
7월 22
1478
2
2월 21
6541
4
10월 20
9309