code refactoring
This commit is contained in:
parent
7223afa486
commit
b105d87745
@ -35,7 +35,7 @@ class GolemResourcePack(models.Model):
|
|||||||
False : [('readonly', False)]})
|
False : [('readonly', False)]})
|
||||||
|
|
||||||
note = fields.Text(help='Notes, optional subject for the reservation, reason',
|
note = fields.Text(help='Notes, optional subject for the reservation, reason',
|
||||||
track_visibility='onchange',readonly=True,
|
track_visibility='onchange', readonly=True,
|
||||||
states={'draft': [('readonly', False)],
|
states={'draft': [('readonly', False)],
|
||||||
False : [('readonly', False)]})
|
False : [('readonly', False)]})
|
||||||
|
|
||||||
@ -59,6 +59,7 @@ class GolemResourcePack(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('partner_id')
|
@api.constrains('partner_id')
|
||||||
def set_reservation_partner(self):
|
def set_reservation_partner(self):
|
||||||
|
""" Set reservation partner """
|
||||||
for pack in self:
|
for pack in self:
|
||||||
pack.reservation_ids.write({'partner_id': pack.partner_id.id})
|
pack.reservation_ids.write({'partner_id': pack.partner_id.id})
|
||||||
|
|
||||||
@ -114,6 +115,7 @@ class GolemResourcePack(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
@api.constrains('reservation_ids')
|
@api.constrains('reservation_ids')
|
||||||
def check_reservation_partner(self):
|
def check_reservation_partner(self):
|
||||||
|
""" Check reservation partner """
|
||||||
for pack in self:
|
for pack in self:
|
||||||
if len(filter(lambda x: x.partner_id == pack.partner_id, pack.reservation_ids)) < len(pack.reservation_ids):
|
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'))
|
raise ValidationError(_('Pack client should be the same for all reservations'))
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
|
|
||||||
""" GOLEM Resource Reservation """
|
""" GOLEM Resource Reservation """
|
||||||
|
|
||||||
from math import modf
|
from odoo import models, fields
|
||||||
from datetime import timedelta
|
|
||||||
from odoo import models, fields, api, _
|
|
||||||
from odoo.exceptions import ValidationError
|
|
||||||
|
|
||||||
|
|
||||||
class GolemResourceReservation(models.Model):
|
class GolemResourceReservation(models.Model):
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
from odoo.tests.common import TransactionCase
|
from odoo.tests.common import TransactionCase
|
||||||
from odoo.exceptions import ValidationError
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ class TestGolemResourcePack(TransactionCase):
|
|||||||
pack.reservation_ids[0].state_confirm()
|
pack.reservation_ids[0].state_confirm()
|
||||||
self.assertEqual(pack.reservation_ids[0].state, "validated")
|
self.assertEqual(pack.reservation_ids[0].state, "validated")
|
||||||
self.assertEqual(pack.state, "validated")
|
self.assertEqual(pack.state, "validated")
|
||||||
pack.reservation_ids=[(5,0,0)]
|
pack.reservation_ids = [(5, 0, 0)]
|
||||||
self.assertFalse(pack.reservation_ids)
|
self.assertFalse(pack.reservation_ids)
|
||||||
self.assertEqual(pack.reservation_count, 0)
|
self.assertEqual(pack.reservation_count, 0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user