Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Two uers u1, u2 are create products in to openerp. The user1 created two products p11, p12 and user2 created two products p21,p22. The customers come to openerp website and make sales orders. Let us take two sales orders, SO1,SO2. SO1 has sale order line p11, and SO2 has sale order line p22. When the u1 loged into system, u1 should see the sales order SO1 but not SO2 (because SO1 contains the product p11 created by u1). When the u2 loged into system, u2 should see the sales order SO2 but not SO1 (because SO2 contains the product p22 created by u2).
To filter the sales orders, i am using the concept user groups. I have written a two domains in rules of "sales manager" group. 1. object="sale.order.line" domain= [('product_id.create_uid','=',user.id)] 2. object='sale.order' domain=[('order_line.product_id.create_uid','=',user.id)] . But it's not working. Can any one help me please?.
I think you have added qoutes in the user.id, This domain should be like.
1. object="sale.order.line" domain= [('product_id.create_uid','=',user.id)]
2. object='sale.order' domain=[('order_line.product_id.create_uid','=',user.id)] .
Hope you can see the differance.
This could be the only reason of "it's not working".
Hi, your requirement is bit tricky...
As per your criteria, try this syntax
2. object='sale.order' domain=[('order_line.product_id.create_uid','=',user.id)] . [since it is one2many, you cannot browse the field directly right] However, Not sure whether the above syntax will work, but if it works then in this case you will be checking with First Order_lines' product and user...
And coming to your requirement, Let me add an another scenario....
Customer creates order [SO3] ... and SO3 has two order lines say p11 (user1), p22(user2).
Now in this case, how should your domain work?
If am not wrong, SO3 should be shown to both users,
however user1 will see SO3 with one line (i.e.) p11,
and user2 will see SO3 with one line (i.e.) p22,
Consider you have acheived the same, I will say logically it is incorrect w.r.t to monetary terms,
suppose say line1 amount is 1000 and line2 amount is 2000, then Order total will be 3000 ..
then user1 will see SO3 with p11, but with 3000 as order total
and user2 will see SO3 with p22, but with 3000 as order total
Note: order total is shown as 3000 for both users, which is quite misleading...
So I suggest, filtering the records wont be a wise solution... however, you can let the user to see the other line(other users' lines) but you can control the record from editing...
I hope you are getting my point... and for locking lines from editing, I can suggest you a better idea for the same...
As I've mentioned you cannot use dot notation to access the fields of many2one fields in a domain, you need to create a related field. e.g. 'product_creator': fields.related('product_id', 'create_uid, type='many2one', store=True, .....), then use this field in domain. The store need to be True to enable this field to be used in domain.
As for the domain for sale.order, you may need to decide if the sale.order has multiple line with different products created by different user, what will be the behaviour. Your current approach is to use the creator of the product of the first line. You need to create a function field to return a value that you can use in domain. Implement fnct_search as well for this function as you may not want it to be stored as it may be too dynamic.
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 12/27/14, 2:40 PM|
|Seen: 2888 times|
|Last updated: 3/16/15, 8:10 AM|