user.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. # @authors: Alexander Ezquevo <alexander@acysos.com>
  3. # Copyright (C) 2015 Acysos S.L.
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from openerp import models, fields
  6. class User(models.Model):
  7. _inherit = 'res.users'
  8. farm = fields.Many2many(comodel_name='res.user_stock.location',
  9. inverse_name='user', colum1='location',
  10. string='Farms',
  11. help="Farms to which this user is assigned."
  12. "Determine animals that he/she can manage.")
  13. class UserLocation(models.Model):
  14. _name = 'res.user_stock.location'
  15. user = fields.Many2one(comodel_name='res.users', string='User',
  16. ondelete='CASCADE', required=True, select=True)
  17. location = fields.Many2one(comodel_name='stock.location',
  18. string='Location', ondelete='CASCADE',
  19. domain=[('usage', '=', 'view'), ],
  20. required=True, select=True
  21. )