You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
659 B

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Daniel Reis
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import models, fields, api
  5. class ResPartner(models.Model):
  6. _inherit = 'res.partner'
  7. lau1_id = fields.Many2one(
  8. 'res.partner.lau',
  9. 'Local Admin. Unit 1',
  10. domain=[('level', '=', 1)])
  11. lau2_id = fields.Many2one(
  12. 'res.partner.lau',
  13. 'Local Admin. Unit 2',
  14. domain=[('level', '=', 2)])
  15. @api.multi
  16. @api.onchange('lau1_id')
  17. def _onchange_lau1(self):
  18. for p in self:
  19. if p.lau2_id and p.lau2_id.parent_id != p.lau1_id:
  20. p.lau2_id = None