Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

fnct_search in functional fields

By
Ajeng Shilvie
on 12/29/14, 4:54 AM 428 views

I am trying to implement a custom method on a field to get user groups id using the following code. However there's nothing happend.

class wtc_approval_line(osv.osv):
    _name="wtc.approval.line"

    def _get_groups(self, cr, uid, ids, field_name, args, context=None):
        x = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']
        #is self.group_id in x ?
        return self.group_id in x
    
    def _cek_groups(self, cr, uid, obj, name, args, context=None):
        res = []
        x = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']
        ids = obj.search(cr,uid,[]) # ids of visits
        for v in self.browse(cr, uid, ids): # foreach visit
            if all(v.group_id == y[0] for y in x) :
                res.append(v.id)          
        return [('id','in',res)]

_columns={

                 ----

                 'abc':fields.function(_get_groups, string="ABC", type="boolean", fnct_search=_cek_groups)

                 }

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

xml code shown below :

        <record model="ir.actions.act_window" id="approval_portal_action">
            <field name="name">Portal Approval Matrix Biaya</field>
            <field name="res_model">wtc.approval.line</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree</field>
            <field name="domain">[('sts','=','1'),('abc','=',True)]</field>
        </record>

any idea ?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/29/14, 4:54 AM
Seen: 428 times
Last updated: 3/16/15, 8:10 AM