code refactoring

This commit is contained in:
eloyoussef 2018-04-16 18:04:05 +02:00
parent 7223afa486
commit b105d87745
3 changed files with 5 additions and 7 deletions

View File

@ -59,6 +59,7 @@ class GolemResourcePack(models.Model):
@api.multi
@api.constrains('partner_id')
def set_reservation_partner(self):
""" Set reservation partner """
for pack in self:
pack.reservation_ids.write({'partner_id': pack.partner_id.id})
@ -114,6 +115,7 @@ class GolemResourcePack(models.Model):
@api.multi
@api.constrains('reservation_ids')
def check_reservation_partner(self):
""" Check reservation partner """
for pack in self:
if len(filter(lambda x: x.partner_id == pack.partner_id, pack.reservation_ids)) < len(pack.reservation_ids):
raise ValidationError(_('Pack client should be the same for all reservations'))

View File

@ -18,10 +18,7 @@
""" GOLEM Resource Reservation """
from math import modf
from datetime import timedelta
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo import models, fields
class GolemResourceReservation(models.Model):

View File

@ -20,7 +20,6 @@
import logging
from odoo.tests.common import TransactionCase
from odoo.exceptions import ValidationError
_LOGGER = logging.getLogger(__name__)