Browse Source

[MIG] b_shift : migration to 11.0

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
2b6800bd25
  1. 5
      beesdoo_shift/__init__.py
  2. 3
      beesdoo_shift/__manifest__.py
  3. 11
      beesdoo_shift/models/__init__.py
  4. 3
      beesdoo_shift/models/attendance_sheet.py
  5. 1
      beesdoo_shift/models/cooperative_status.py
  6. 3
      beesdoo_shift/models/planning.py
  7. 1
      beesdoo_shift/models/res_config.py
  8. 1
      beesdoo_shift/models/task.py
  9. 3
      beesdoo_shift/tests/__init__.py
  10. 91
      beesdoo_shift/tests/test_beesdoo_shift.py
  11. 16
      beesdoo_shift/wizard/__init__.py
  12. 1
      beesdoo_shift/wizard/assign_super_coop.py
  13. 1
      beesdoo_shift/wizard/batch_template.py
  14. 1
      beesdoo_shift/wizard/extension.py
  15. 1
      beesdoo_shift/wizard/holiday.py
  16. 1
      beesdoo_shift/wizard/instanciate_planning.py
  17. 1
      beesdoo_shift/wizard/subscribe.py
  18. 1
      beesdoo_shift/wizard/temporary_exemption.py
  19. 1
      beesdoo_shift/wizard/validate_attendance_sheet.py

5
beesdoo_shift/__init__.py

@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
import models
import wizard
from . import models
from . import wizard

3
beesdoo_shift/__manifest__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
{
'name': "Beescoop Shift Management",
@ -13,7 +12,7 @@
'website': "https://github.com/beescoop/Obeesdoo",
'category': 'Cooperative management',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'depends': ['beesdoo_base', 'barcodes'],

11
beesdoo_shift/models/__init__.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import attendance_sheet
import planning
import res_config
import task
import cooperative_status
from . import attendance_sheet
from . import planning
from . import res_config
from . import task
from . import cooperative_status

3
beesdoo_shift/models/attendance_sheet.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest
@ -376,7 +375,7 @@ class AttendanceSheet(models.Model):
is_compensation = worker.working_mode == "regular"
added_ids = map(lambda s: s.worker_id.id, self.added_shift_ids)
added_ids = [s.worker_id.id for s in self.added_shift_ids]
if worker.id not in added_ids:
# Added shift creation

1
beesdoo_shift/models/cooperative_status.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError, UserError

3
beesdoo_shift/models/planning.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import UserError
@ -155,7 +154,7 @@ class TaskTemplate(models.Model):
def _generate_task_day(self):
tasks = self.env['beesdoo.shift.shift']
for rec in self:
for i in xrange(0, rec.worker_nb):
for i in range(0, rec.worker_nb):
worker_id = rec.worker_ids[i] if len(rec.worker_ids) > i else False
#remove worker in holiday and temporary exempted
if worker_id and worker_id.cooperative_status_ids:

1
beesdoo_shift/models/res_config.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2019-2020 Elouan Le Bars <elouan@coopiteasy.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
beesdoo_shift/models/task.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json
from datetime import datetime, timedelta

3
beesdoo_shift/tests/__init__.py

@ -1,2 +1 @@
# -*- coding: utf-8 -*-
import test_beesdoo_shift
from . import test_beesdoo_shift

91
beesdoo_shift/tests/test_beesdoo_shift.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2019 - Today Coop IT Easy SCRLfs (<http://www.coopiteasy.be>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@ -174,9 +173,9 @@ class TestBeesdooShift(TransactionCase):
param_id = self.env["ir.config_parameter"].get_param(
"beesdoo_shift.default_task_type_id"
)
self.assertEquals(int(param_id), task_type.id)
self.assertEqual(int(param_id), task_type.id)
# Check propagation on attendance sheet shifts
self.assertEquals(
self.assertEqual(
self.attendance_sheet_shift_model.default_task_type_id(),
task_type,
)
@ -196,16 +195,16 @@ class TestBeesdooShift(TransactionCase):
# Test attendance sheets creation
self.attendance_sheet_model._generate_attendance_sheet()
self.assertEquals(
self.assertEqual(
len(self.search_sheets(self.start_in_1, self.end_in_1)), 1
)
self.assertEquals(
self.assertEqual(
len(self.search_sheets(self.start_in_2, self.end_in_2)), 1
)
self.assertEquals(
self.assertEqual(
len(self.search_sheets(self.start_out_1, self.end_out_1)), 0
)
self.assertEquals(
self.assertEqual(
len(self.search_sheets(self.start_out_2, self.end_out_2)), 0
)
@ -220,32 +219,32 @@ class TestBeesdooShift(TransactionCase):
self.assertTrue(sheet_1.end_time)
# Empty shift should not be added
self.assertEquals(len(sheet_1.expected_shift_ids), 3)
self.assertEquals(len(sheet_1.added_shift_ids), 0)
self.assertEquals(len(sheet_2.expected_shift_ids), 1)
self.assertEqual(len(sheet_1.expected_shift_ids), 3)
self.assertEqual(len(sheet_1.added_shift_ids), 0)
self.assertEqual(len(sheet_2.expected_shift_ids), 1)
# Test consistency with actual shift for sheet 1
for shift in sheet_1.expected_shift_ids:
self.assertEquals(shift.worker_id, shift.task_id.worker_id)
self.assertEquals(
self.assertEqual(shift.worker_id, shift.task_id.worker_id)
self.assertEqual(
shift.replacement_worker_id, shift.task_id.replaced_id
)
self.assertEquals(shift.task_type_id, shift.task_id.task_type_id)
self.assertEquals(shift.super_coop_id, shift.task_id.super_coop_id)
self.assertEquals(shift.working_mode, shift.task_id.working_mode)
self.assertEqual(shift.task_type_id, shift.task_id.task_type_id)
self.assertEqual(shift.super_coop_id, shift.task_id.super_coop_id)
self.assertEqual(shift.working_mode, shift.task_id.working_mode)
# Status should be "absent" for all shifts
self.assertEquals(shift.state, "absent")
self.assertEquals(shift.compensation_no, "2")
self.assertEqual(shift.state, "absent")
self.assertEqual(shift.compensation_no, "2")
# Empty shift should be considered in max worker number calculation
self.assertEquals(sheet_1.max_worker_no, 4)
self.assertEqual(sheet_1.max_worker_no, 4)
# Test default values creation
self.assertTrue(sheet_1.time_slot)
self.assertEquals(sheet_1.day, fields.Date.to_string(self.start_in_1))
self.assertEquals(sheet_1.day_abbrevation, "Lundi")
self.assertEquals(sheet_1.week, "Semaine A")
self.assertEqual(sheet_1.day, fields.Date.to_string(self.start_in_1))
self.assertEqual(sheet_1.day_abbrevation, "Lundi")
self.assertEqual(sheet_1.week, "Semaine A")
self.assertTrue(sheet_1.name)
self.assertFalse(sheet_1.notes)
self.assertFalse(sheet_1.is_annotated)
@ -276,7 +275,7 @@ class TestBeesdooShift(TransactionCase):
# Check expected shifts update
for id in sheet_1.expected_shift_ids.ids:
shift = sheet_1.expected_shift_ids.browse(id)
self.assertEquals(shift.state, "done")
self.assertEqual(shift.state, "done")
"""
Added workers are :
@ -290,18 +289,18 @@ class TestBeesdooShift(TransactionCase):
# Scan barcode for added workers
sheet_1.on_barcode_scanned(421457731741)
self.assertEquals(len(sheet_1.added_shift_ids), 1)
self.assertEqual(len(sheet_1.added_shift_ids), 1)
sheet_1.on_barcode_scanned(421457731743)
# Scan an already added worker should not change anything
sheet_1.on_barcode_scanned(421457731743)
self.assertEquals(len(sheet_1.added_shift_ids), 2)
self.assertEqual(len(sheet_1.added_shift_ids), 2)
# Check added shifts fields
for id in sheet_1.added_shift_ids.ids:
shift = sheet_1.added_shift_ids.browse(id)
self.assertEquals(sheet_1, shift.attendance_sheet_id)
self.assertEquals(shift.state, "done")
self.assertEquals(
self.assertEqual(sheet_1, shift.attendance_sheet_id)
self.assertEqual(shift.state, "done")
self.assertEqual(
shift.task_type_id,
self.attendance_sheet_shift_model.default_task_type_id(),
)
@ -385,8 +384,8 @@ class TestBeesdooShift(TransactionCase):
sheet_1.validate_with_checks()
self.assertIn("already been validated", str(e.exception))
self.assertEquals(sheet_1.state, "validated")
self.assertEquals(sheet_1.validated_by, self.user_admin.partner_id)
self.assertEqual(sheet_1.state, "validated")
self.assertEqual(sheet_1.validated_by, self.user_admin.partner_id)
self.assertTrue(sheet_1.is_annotated)
self.assertFalse(sheet_1.is_read)
@ -394,19 +393,19 @@ class TestBeesdooShift(TransactionCase):
workers = sheet_1.expected_shift_ids.mapped(
"worker_id"
) | sheet_1.added_shift_ids.mapped("worker_id")
self.assertEquals(len(workers), 5)
self.assertEquals(
self.assertEqual(len(workers), 5)
self.assertEqual(
sheet_1.expected_shift_ids[0].task_id.state, "absent_2"
)
self.assertEquals(sheet_1.expected_shift_ids[1].task_id.state, "done")
self.assertEquals(
self.assertEqual(sheet_1.expected_shift_ids[1].task_id.state, "done")
self.assertEqual(
sheet_1.expected_shift_ids[2].task_id.state, "absent_1"
)
self.assertEquals(sheet_1.added_shift_ids[0].task_id.state, "done")
self.assertEquals(sheet_1.added_shift_ids[1].task_id.state, "done")
self.assertEqual(sheet_1.added_shift_ids[0].task_id.state, "done")
self.assertEqual(sheet_1.added_shift_ids[1].task_id.state, "done")
# Empty shift should have been updated
self.assertEquals(
self.assertEqual(
sheet_1.added_shift_ids[0].task_id, self.shift_empty_1
)
@ -455,10 +454,10 @@ class TestBeesdooShift(TransactionCase):
# For a regular worker
status_1.sr = 0
status_1.sc = 0
self.assertEquals(status_1.status, "ok")
self.assertEqual(status_1.status, "ok")
shift_regular.state = "absent_1"
self.assertEquals(status_1.sr, -1)
self.assertEquals(status_1.status, "alert")
self.assertEqual(status_1.sr, -1)
self.assertEqual(status_1.status, "alert")
shift_regular.state = "done"
self.assertEquals(status_1.sr, 0)
self.assertEquals(status_1.sc, 0)
@ -492,16 +491,16 @@ class TestBeesdooShift(TransactionCase):
status_2.sc = 0
shift_regular.replaced_id = self.worker_regular_3
shift_regular.state = "absent_2"
self.assertEquals(status_1.sr, 0)
self.assertEquals(status_1.sc, 0)
self.assertEquals(status_2.sr, -1)
self.assertEquals(status_2.sc, -1)
self.assertEqual(status_1.sr, 0)
self.assertEqual(status_1.sc, 0)
self.assertEqual(status_2.sr, -1)
self.assertEqual(status_2.sc, -1)
# For an irregular worker
status_3.sr = 0
status_3.sc = 0
self.assertEquals(status_3.status, "ok")
self.assertEqual(status_3.status, "ok")
shift_irregular.state = "done"
self.assertEquals(status_3.sr, 1)
self.assertEqual(status_3.sr, 1)
shift_irregular.state = "absent_2"
self.assertEquals(status_3.sr, -1)
self.assertEqual(status_3.sr, -1)

16
beesdoo_shift/wizard/__init__.py

@ -1,8 +1,8 @@
import instanciate_planning
import batch_template
import assign_super_coop
import subscribe
import extension
import holiday
import temporary_exemption
import validate_attendance_sheet
from . import instanciate_planning
from . import batch_template
from . import assign_super_coop
from . import subscribe
from . import extension
from . import holiday
from . import temporary_exemption
from . import validate_attendance_sheet

1
beesdoo_shift/wizard/assign_super_coop.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _

1
beesdoo_shift/wizard/batch_template.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
'''
Created on 2 janv. 2017

1
beesdoo_shift/wizard/extension.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import UserError

1
beesdoo_shift/wizard/holiday.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError

1
beesdoo_shift/wizard/instanciate_planning.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _

1
beesdoo_shift/wizard/subscribe.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import UserError

1
beesdoo_shift/wizard/temporary_exemption.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError

1
beesdoo_shift/wizard/validate_attendance_sheet.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import ast

Loading…
Cancel
Save