Migrate to 6.0

This commit is contained in:
José Miguel Pardo Salar 2022-05-11 14:26:33 +02:00
parent 807c8c6d60
commit e572200a68
5 changed files with 35 additions and 18 deletions

View file

@ -2,16 +2,16 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:staff.workplace.calendar:"
msgctxt "model:ir.message,text:msg_staff_workplace_calendar_wp_cal_uk"
msgid "Combination of Workplace and Calendar must be unique."
msgstr "La combinación de Centro de empleo y Calendario debe ser única."
msgctxt "error:staff.workplace.calendar:"
msgid "Cannot add to Workplace \"%s\" many calendars for a year."
msgstr "No puede definir para el Centro de empleo \"%s\" "
msgctxt "model:ir.message,text:msg_staff_workplace_calendar_unique_year"
msgid "Cannot add to Workplace \"%(workplace)s\" many calendars for a year."
msgstr "No puede definir para el Centro de empleo \"%(workplace)s\" "
"varios calendarios de un mismo año."
msgctxt "error:staff.calendar.day:"
msgctxt "model:ir.message,text:msg_staff_calendar_day_calendar_date_uk"
msgid "Date must be unique per Calendar."
msgstr "Fecha debe ser única por calendario."

19
message.xml Normal file
View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tryton>
<data grouped="1">
<!-- staff.calendar.day -->
<record model="ir.message" id="msg_staff_calendar_day_calendar_date_uk">
<field name="text">Date must be unique per Calendar.</field>
</record>
<!-- staff.workplace.calendar -->
<record model="ir.message" id="msg_staff_workplace_calendar_unique_year">
<field name="text">Cannot add to Workplace "%(workplace)s" many calendars for a year.</field>
</record>
<record model="ir.message" id="msg_staff_workplace_calendar_wp_cal_uk">
<field name="text">Combination of Workplace and Calendar must be unique.</field>
</record>
</data>
</tryton>

View file

@ -3,8 +3,6 @@
from trytond.model import fields
from trytond.pool import PoolMeta
__all__ = ['TimeClockPrintStart', 'TimeClockPrint']
class TimeClockPrintStart(metaclass=PoolMeta):
__name__ = 'company.employee.time_clock.print_start'

View file

@ -12,3 +12,4 @@ extras_depend:
xml:
workplace.xml
time_clock.xml
message.xml

View file

@ -4,9 +4,8 @@ from trytond.model import ModelSQL, ModelView, fields
from trytond.model import Unique, DeactivableMixin
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
__all__ = ['Calendar', 'WorkPlace', 'Employee', 'CalendarDay',
'WorkPlaceCalendar']
from trytond.exceptions import UserError
from trytond.i18n import gettext
class Calendar(ModelView, ModelSQL):
@ -97,12 +96,8 @@ class WorkPlaceCalendar(ModelSQL):
t = cls.__table__()
cls._sql_constraints = [
('wp_cal_uk', Unique(t, t.workplace, t.calendar),
'Combination of Workplace and Calendar must be unique.')
'staff_workplace.msg_staff_workplace_calendar_wp_cal_uk')
]
cls._error_messages.update({
'unique_year': ('Cannot add to Workplace "%s" many calendars '
'for a year.')
})
@classmethod
def validate(cls, records):
@ -115,7 +110,9 @@ class WorkPlaceCalendar(ModelSQL):
for record in records:
values.setdefault(record.workplace.id, [])
if record.calendar.year in values[record.workplace.id]:
cls.raise_user_error('unique_year', record.workplace.rec_name)
raise UserError(gettext(
'staff_workplace.msg_staff_workplace_calendar_unique_year',
workplace=record.workplace.rec_name))
values[record.workplace.id].append(record.calendar.year)
others = cls.search([
@ -123,7 +120,9 @@ class WorkPlaceCalendar(ModelSQL):
('workplace', 'in', [r.workplace.id for r in records])])
for other in others:
if other.calendar.year in values[other.workplace.id]:
cls.raise_user_error('unique_year', other.workplace.rec_name)
raise UserError(gettext(
'staff_workplace.msg_staff_workplace_calendar_unique_year',
workplace=other.workplace.rec_name))
values[record.workplace.id].append(other.calendar.year)
@ -153,6 +152,6 @@ class CalendarDay(ModelView, ModelSQL):
t = cls.__table__()
cls._sql_constraints = [
('calendar_date_uk', Unique(t, t.calendar, t.date_),
'Date must be unique per Calendar.')
'staff_workplace.msg_staff_calendar_day_calendar_date_uk')
]
cls._order.insert(0, ('date_', 'ASC'))