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.
I try to figure how I can show a restricted list of orders, purchases or invoice based on a field I added in the product model, stock_owner_id. He should see only records related to his allowed_stock_owner_ids.
Am I forced to copy stock_owner_id from product.template to sale.order.line to sale.order to apply my domain filter? Is there another way around?
Here are my models:
_inherit = 'res.users'
current_stock_owner_id = fields.Many2one('res.partner', string='Current Stock Owner')
allowed_stock_owner_ids = fields.Many2many('res.partner', 'res_partner_users_rel',
class ProductTemplate(models.Model): _inherit = 'product.template' stock_owner_id = fields.Many2one('res.partner', string='Stock Owner', domain="[('stock_owner','=',True)]")
Got it! Here is the record rule I need :)
<record id="isolate_stock_owners_sale_order_rule" model="ir.rule"> <field name="name">Isolate Stock Owner Sale Order</field> <field name="model_id" ref="model_sale_order"/> <field eval="True" name="global"/> <field name="domain_force">[('order_line.product_tmpl_id.stock_owner_id', '=', user.allowed_stock_owner_ids.id)]</field> </record>
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: 7/27/15, 1:09 PM|
|Seen: 1311 times|
|Last updated: 7/28/15, 6:03 PM|