diff options
| author | Simon Lejeune <sle@openerp.com> | 2019-08-22 09:32:46 +0000 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2019-09-03 15:05:04 +0000 |
| commit | 2b802cd5108950d975488cafa3d00de1afb2cbe9 (patch) | |
| tree | dbe0d66e0750f96c2d22f449bb82f8096538a3e0 /addons/maintenance/models | |
| parent | 20692736a99934bb26268d28cdece69b4229425b (diff) | |
[REF] maintenance: multi company
Ensure proper domains are applied and enforced on relation fields thanks
to the `check_company` attributes.
task-1985992
Diffstat (limited to 'addons/maintenance/models')
| -rw-r--r-- | addons/maintenance/models/maintenance.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/addons/maintenance/models/maintenance.py b/addons/maintenance/models/maintenance.py index 2ab6df51909..e2346644294 100644 --- a/addons/maintenance/models/maintenance.py +++ b/addons/maintenance/models/maintenance.py @@ -93,6 +93,7 @@ class MaintenanceEquipment(models.Model): _name = 'maintenance.equipment' _inherit = ['mail.thread', 'mail.activity.mixin'] _description = 'Maintenance Equipment' + _check_company_auto = True def _track_subtype(self, init_values): self.ensure_one() @@ -127,7 +128,7 @@ class MaintenanceEquipment(models.Model): owner_user_id = fields.Many2one('res.users', string='Owner', tracking=True) category_id = fields.Many2one('maintenance.equipment.category', string='Equipment Category', tracking=True, group_expand='_read_group_category_ids') - partner_id = fields.Many2one('res.partner', string='Vendor') + partner_id = fields.Many2one('res.partner', string='Vendor', check_company=True) partner_ref = fields.Char('Vendor Reference') location = fields.Char('Location') model = fields.Char('Model') @@ -258,6 +259,7 @@ class MaintenanceRequest(models.Model): _inherit = ['mail.thread.cc', 'mail.activity.mixin'] _description = 'Maintenance Request' _order = "id desc" + _check_company_auto = True @api.returns('self') def _default_stage(self): @@ -288,7 +290,7 @@ class MaintenanceRequest(models.Model): owner_user_id = fields.Many2one('res.users', string='Created by User', default=lambda s: s.env.uid) category_id = fields.Many2one('maintenance.equipment.category', related='equipment_id.category_id', string='Category', store=True, readonly=True) equipment_id = fields.Many2one('maintenance.equipment', string='Equipment', - ondelete='restrict', index=True) + ondelete='restrict', index=True, check_company=True) user_id = fields.Many2one('res.users', string='Technician', tracking=True) stage_id = fields.Many2one('maintenance.stage', string='Stage', ondelete='restrict', tracking=True, group_expand='_read_group_stage_ids', default=_default_stage) @@ -301,7 +303,7 @@ class MaintenanceRequest(models.Model): archive = fields.Boolean(default=False, help="Set archive to true to hide the maintenance request without deleting it.") maintenance_type = fields.Selection([('corrective', 'Corrective'), ('preventive', 'Preventive')], string='Maintenance Type', default="corrective") schedule_date = fields.Datetime('Scheduled Date', help="Date the maintenance team plans the maintenance. It should not differ much from the Request Date. ") - maintenance_team_id = fields.Many2one('maintenance.team', string='Team', required=True, default=_get_default_team_id) + maintenance_team_id = fields.Many2one('maintenance.team', string='Team', required=True, default=_get_default_team_id, check_company=True) duration = fields.Float(help="Duration in hours.") done = fields.Boolean(related='stage_id.done') @@ -400,7 +402,9 @@ class MaintenanceTeam(models.Model): active = fields.Boolean(default=True) company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company) - member_ids = fields.Many2many('res.users', 'maintenance_team_users_rel', string="Team Members") + member_ids = fields.Many2many( + 'res.users', 'maintenance_team_users_rel', string="Team Members", + domain="[('company_ids', 'in', company_id)]") color = fields.Integer("Color Index", default=0) request_ids = fields.One2many('maintenance.request', 'maintenance_team_id', copy=False) equipment_ids = fields.One2many('maintenance.equipment', 'maintenance_team_id', copy=False) |
