Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1960 Представления

Hello everyone, I have code to check whether the user is in certain group or not. If the user not in this particular group, i want to add css class for certain element in mrp bom print pdf. But what happened is the css class always added even though the user is in the group. The condition that i applied in my code is not working. Is there anybody know why my code doesn't work?


@api.model    

def _get_report_values(self, docids, data=None):        
        res = super(ReportBomStructure, self)._get_report_values(docids, data)        

​docs = res['docs']                

​new_docs = []                

​for document in docs:                        

​​document['is_inventory_cost'] = self.env.user.user_has_groups('__export__.res_groups_85_c36ec13a')     

       ​new_docs.append(document)                    

​res['docs'] = new_docs                

​return res


template id="report_mrp_bom_inherited_andini" inherit_id="mrp.report_mrp_bom">

xpath expr="//*[hasclass('o_mrp_bom_cost')]" position="attributes">                

​ t-if="data['is_inventory_cost'] != True">                     

​attribute name="class" add="mrp_cost_hide" separator=" "/>    

​/t>            

​/xpath>



Аватар
Отменить
Автор Лучший ответ

Thank you for your answer @Cybrosys Techno Solutions Pvt.Ltd.

But it still doesn't work in the xpath attributes. So I decided use another way to make this work. 

Аватар
Отменить
Лучший ответ

Hi,

Please replace python function as follows :


@api.model    

def _get_report_values(self, docids, data=None):        

        res = super(ReportBomStructure, self)._get_report_values(docids, data)     

        docs = res['docs']           

        new_docs = []                

        for document in docs:

             if   self.env.user.user_has_groups('__export__.res_groups_85_c36ec13a'):

                   document['is_inventory_cost'] = True 

                   new_docs.append(document)                    


         res['docs'] = new_docs                

          return res


Hope it helps,

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
апр. 20
3389
1
авг. 19
5982
1
окт. 16
6137
3
мая 16
3653
1
февр. 25
2199