Migrate to 6.0
This commit is contained in:
parent
a47cad01cd
commit
66e509ca18
10
__init__.py
10
__init__.py
|
@ -1,13 +1,13 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .category import Category
|
||||
from .timesheet import Work, WorkCategory
|
||||
from . import category
|
||||
from . import timesheet
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Category,
|
||||
Work,
|
||||
WorkCategory,
|
||||
category.Category,
|
||||
timesheet.Work,
|
||||
timesheet.WorkCategory,
|
||||
module='timesheet_work_category', type_='model')
|
||||
|
|
26
category.py
26
category.py
|
@ -2,15 +2,9 @@
|
|||
# copyright notices and license terms.
|
||||
from trytond.model import (ModelSQL, ModelView, fields, Unique,
|
||||
DeactivableMixin, tree)
|
||||
from trytond.pyson import Eval
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
|
||||
__all__ = ['Category']
|
||||
|
||||
STATES = {
|
||||
'readonly': ~Eval('active'),
|
||||
}
|
||||
|
||||
DEPENDS = ['active']
|
||||
SEPARATOR = ' / '
|
||||
|
||||
|
||||
|
@ -19,9 +13,9 @@ class Category(tree(), DeactivableMixin, ModelSQL, ModelView):
|
|||
__name__ = 'timesheet.work.category'
|
||||
name = fields.Char('Name', required=True)
|
||||
parent = fields.Many2One('timesheet.work.category', 'Parent',
|
||||
select=True, states=STATES, depends=DEPENDS)
|
||||
select=True)
|
||||
childs = fields.One2Many('timesheet.work.category', 'parent',
|
||||
'Children', states=STATES, depends=DEPENDS)
|
||||
'Children')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -29,12 +23,9 @@ class Category(tree(), DeactivableMixin, ModelSQL, ModelView):
|
|||
t = cls.__table__()
|
||||
cls._sql_constraints = [
|
||||
('name_parent_uniq', Unique(t, t.name, t.parent),
|
||||
'The name of a party category must be unique by parent.'),
|
||||
'timesheet_work_category.'
|
||||
'msg_timesheet_work_category_name_parent_uniq'),
|
||||
]
|
||||
cls._error_messages.update({
|
||||
'wrong_name': ('Invalid category name "%%s": You can not use '
|
||||
'"%s" in name field.' % SEPARATOR),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def validate(cls, categories):
|
||||
|
@ -44,7 +35,10 @@ class Category(tree(), DeactivableMixin, ModelSQL, ModelView):
|
|||
|
||||
def check_name(self):
|
||||
if SEPARATOR in self.name:
|
||||
self.raise_user_error('wrong_name', (self.name,))
|
||||
raise UserError(gettext(
|
||||
'timesheet_work_category.'
|
||||
'msg_timesheet_work_category_wrong_name',
|
||||
category=self.name))
|
||||
|
||||
def get_rec_name(self, name):
|
||||
if self.parent:
|
||||
|
|
|
@ -42,12 +42,12 @@ msgctxt "field:timesheet.work.category,rec_name:"
|
|||
msgid "Name"
|
||||
msgstr "Nombre"
|
||||
|
||||
msgctxt "error:timesheet.work.category:"
|
||||
msgctxt "model:ir.message,text:msg_timesheet_work_category_name_parent_uniq"
|
||||
msgid "The name of a party category must be unique by parent."
|
||||
msgstr "El nombre de la categoría del tercero debe ser único según el padre."
|
||||
|
||||
msgctxt "error:timesheet.work.category:"
|
||||
msgid "Invalid category name \"%s\": You can not use \" / \" in name field."
|
||||
msgctxt "model:ir.message,text:msg_timesheet_work_category_name_parent_uniq"
|
||||
msgid "Invalid category name \"%(category)s\": You can not use \" / \" in name field."
|
||||
msgstr ""
|
||||
"El nombre de la categoría \"%s\" no es correcto: No puede utilizar \" / \" "
|
||||
"El nombre de la categoría \"%(category)s\" no es correcto: No puede utilizar \" / \" "
|
||||
"en el campo nombre."
|
|
@ -0,0 +1,14 @@
|
|||
<?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">
|
||||
<!-- timesheet.work.category -->
|
||||
<record model="ir.message" id="msg_timesheet_work_category_wrong_name">
|
||||
<field name="text">Invalid category name "%(category)s": You can not use " / " in name field.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_timesheet_work_category_name_parent_uniq">
|
||||
<field name="text">The name of a party category must be unique by parent.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -4,8 +4,6 @@ from trytond.model import fields, ModelSQL
|
|||
from trytond.pool import PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['Work', 'WorkCategory']
|
||||
|
||||
|
||||
class Work(metaclass=PoolMeta):
|
||||
__name__ = 'timesheet.work'
|
||||
|
|
|
@ -7,3 +7,4 @@ depends:
|
|||
xml:
|
||||
category.xml
|
||||
timesheet.xml
|
||||
message.xml
|
||||
|
|
Loading…
Reference in New Issue