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

I need to upgrade a module and when I change 'get_object_reference' shortcut to '_xmlid_lookup'  I have an error.


Everytime i give it 2 positional arguments it says I have entered 3 and when I enter only one of them it says I have not entered enough elements. How can I solve this? Thanks!!

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

Hello Ricky Low,

Please have a look following difference between get_object_reference and _xmlid_lookup method.

@api.model
def get_object_reference
(self, module, xml_id):
"""Returns (model, res_id) corresponding to a given module and xml_id (cached) or raise ValueError if not found"""

above mothod take 2 arguments(module and xml_id ) and return tuple (model, res_id)

# NEW V8 API
@api.model
@tools.ormcache
('xmlid')
def _xmlid_lookup(self, xmlid):
"""Low level xmlid lookup
Return (id, res_model, res_id) or raise ValueError if not found
"""

above mothod take only 1 arguments(xml_id ) and return tuple (id, model, res_id)



So As per latest code you have to pass only one argument which is xml_id to _xmlid_lookup method

_xmlid_lookup(xml)


Please have a look following example

action_id = self.env['ir.model.data']._xmlid_lookup('base_setup.action_general_configuration')[2]


Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015
    


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 23
2483
1
thg 2 23
2252
1
thg 2 23
2433
2
thg 11 22
6254
1
thg 8 22
1787