Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
9457 มุมมอง

I have a search filter defined below

<filter string="Taller" name="ex_height_taller_1" domain="[('height','&gt;',context.get('test_value', False))]" />


context.get can never get the context value pass into the view.After tracing the problem into pyeval.js, I notice the eval_domains function never take into consideration the custom context passed into the view.


It will only works for context values defined from the following function

instance.web.pyeval.context = function () {

return _.extend({

datetime: datetime,

context_today: context_today,

time: time,

relativedelta: relativedelta,

current_date: py.PY_call(

time.strftime, [py.str.fromJSON('%Y-%m-%d')]),

}, instance.session.user_context);

};


Is there a way to overcome this? I need to define a test_value base on the initial partner choose first for comparison.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Found the solution......

Look for the following code in pyeval.js


instance.web.pyeval.sync_eval_domains_and_contexts = function (source) {

    var contexts = ([instance.session.user_context] || []).concat(source.contexts);

    // see Session.eval_context in Python

    return {

        context: instance.web.pyeval.eval('contexts', contexts),

        domain: instance.web.pyeval.eval('domains', source.domains, source.contexts[0]),

        group_by: instance.web.pyeval.eval('groupbys', source.group_by_seq || [])

    };

};

Pass in the context  source.contexts[0] to the domain for evaluation.
This will be good for creating dynamic search filter using context.

Cheers

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 15
3404
2
พ.ย. 24
2676
6
มี.ค. 18
8210
0
พ.ค. 15
3143
2
มี.ค. 15
7928