Skip to Content
Menu
This question has been flagged
1 Reply
635 Views

is_vendor_group = fields.Boolean(compute='_compute_is_vendor_group',readonly=True)


def _compute_is_vendor_group(self):

current_user=self.env.user

print('current_user',current_user.name,"current_user",current_user.user_has_groups('fmcg_custom_module.group_order_vendor'))

for rec in self:

if not current_user.user_has_groups('fmcg_custom_module.group_order_vendor'):

rec.is_vendor_group=True

else:

rec.is_vendor_group=False

IN TREE VIEW​

<field name="vender_name" invisible="is_vendor_group == True"  />
      <field name="vender_name" invisible="is_vendor_group"  />        ---> Value is invisible but, column(label) name show.

i want column_invisible  (column name & value)     
<field name="vender_name" column_invisible="is_vendor_group == True"  />
      <field name="vender_name" column_invisible="is_vendor_group"  />  --> use this getting error

      
UncaughtPromiseError > OwlError

Uncaught Promise > An error occured in the owl lifecycle (see this Error's "cause" property)

OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)

    Error: An error occured in the owl lifecycle (see this Error's "cause" property)

        at handleError (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:916:101)

        at App.handleError (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1559:29)

        at Fiber._render (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:941:19)

        at Fiber.render (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:939:6)

        at ComponentNode.initiateRender (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1009:47)


Caused by: EvalError: Can not evaluate python expression: (bool(is_vendor_group))

    Error: Name 'is_vendor_group' is not defined

    EvalError: Can not evaluate python expression: (bool(is_vendor_group))

    Error: Name 'is_vendor_group' is not defined

        at evaluateExpr (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:3071:54)

        at evaluateBooleanExpr (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:3074:8)

        at ListController.evalViewModifier (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9696:35)

        at ListRenderer.evalColumnInvisible (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9844:56)

        at http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9745:9

        at Array.filter (<anonymous>)

        at ListRenderer.getActiveColumns (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9743:47)

        at ListRenderer.setup (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9737:456)

        at new ComponentNode (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1004:202)

        at http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1557:6


UncaughtPromiseError > OwlError

Uncaught Promise > An error occured in the owl lifecycle (see this Error's "cause" property)

OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)

    Error: An error occured in the owl lifecycle (see this Error's "cause" property)

        at handleError (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:916:101)

        at App.handleError (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1559:29)

        at Fiber._render (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:941:19)

        at Fiber.render (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:939:6)

        at ComponentNode.initiateRender (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1009:47)


Caused by: EvalError: Can not evaluate python expression: (bool(is_vendor_group == True))

    Error: Name 'is_vendor_group' is not defined

    EvalError: Can not evaluate python expression: (bool(is_vendor_group == True))

    Error: Name 'is_vendor_group' is not defined

        at evaluateExpr (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:3071:54)

        at evaluateBooleanExpr (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:3074:8)

        at ListController.evalViewModifier (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9696:35)

        at ListRenderer.evalColumnInvisible (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9844:56)

        at http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9745:9

        at Array.filter (<anonymous>)

        at ListRenderer.getActiveColumns (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9743:47)

        at ListRenderer.setup (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:9737:456)

        at new ComponentNode (http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1004:202)

        at http://localhost:8069/web/assets/bd2863e/web.assets_web.min.js:1557:6

Please Give Solution
        

Avatar
Discard

I have similar error in my xml,
while i check the odoo default uses in base modules, all the codes suggest me to use context value, try to add the field value in context and use context.get in column_invisible, may be this will help you

Best Answer

Use the below approach to hide both the column (header) and values dynamically and ensure is_vendor_group is Passed in Context
<field name="vender_name" column_invisible="context.get('is_vendor_group', False)"/>

Regards,
Milu
Accurates

Avatar
Discard
Related Posts Replies Views Activity
1
Feb 25
37
1
Feb 25
522
1
Jan 25
513
2
Dec 24
725
0
Dec 24
429