This question has been flagged

Hello,

I would like to set up two user groups for the Purchases module where the groups have access to different suppliers. One group will deal with all suppliers in Asia, while the other will deal with suppliers in Europe.

Is it possible to set up Record Rules to limit access based on the supplier address? If not, how would one go about setting up rules on a per-supplier basis?

Thanks, Lawrence

Avatar
Discard
Best Answer

hi, u may inherit res.country & res.users add in a new field maybe called it as "is_asia", so that each country will have identification belongs to which continent. Then u can inherit purchase order object's search function to add in continent filter.

class purchase_order(osv.osv):
    _inherit = "purchase.order"

    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
        is_asia = self.pool.get('res.users').browse(cr, uid, uid).is_asia
        partner_ids = self.pool.get('res.partners').search(cr, uid, [('is_asia','=',is_asia)])
        args += [('partner_id','in',partner_ids)]
        return super(purchase_order, self).search(cr, uid, args, offset, limit, order, context, count)
purchase_order()

hope it works

Avatar
Discard
Best Answer

Hello

You can use rules in groups to limit your record which will be country specific.

Lets consider an example

1.create new group for supplier deal with country 'India'

following rule will be

object:purchase_order

Domain filter:

['|',('partner_id.country_id.name','=','india')]

2.create new group for supplier deal with country 'USA'

following rule will be

object:purchase_order

Domain filter:

['|',('partner_id.country_id.name','=','USA')]

Avatar
Discard