Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4185 Lượt xem

I'm having many2one which has relation "res.currency". I need to set default currency value in Indian currency by default and set this field must not change by user. How must I do this?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

currency_id = fields.Many2one('res.currency',default=lambda self: self.env['res.currency'].search([('name', '=', 'INR')]).id,readonly=True)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can get the currency using xml_id rather name 

def _default_country_id(self):
    return self.env.ref('base.INR').id

currency_id = fields.Many2one('res.currency',string='Currency',default=_default_country_id,readonly=True)


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
2408
1
thg 7 25
909
1
thg 8 25
1151
0
thg 5 25
1344
2
thg 4 25
3566