Release v6.0

This commit is contained in:
wilson gomez 2021-06-02 12:26:32 -05:00
parent a342d6463c
commit 788a200eda
11 changed files with 52 additions and 49 deletions

View File

@ -2,19 +2,19 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from .position import Position
from .employee import Employee
from .holidays import Holidays
from .contract import StaffContract
from .configuration import Configuration, StaffConfigurationSequence
from . import position
from . import employee
from . import holidays
from . import contract
from . import configuration
def register():
Pool.register(
Holidays,
Position,
Employee,
StaffContract,
Configuration,
StaffConfigurationSequence,
holidays.Holidays,
position.Position,
employee.Employee,
contract.StaffContract,
configuration.Configuration,
configuration.StaffConfigurationSequence,
module='staff', type_='model')

View File

@ -3,13 +3,11 @@
from trytond import backend
from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
from trytond.pool import Pool
from trytond.pyson import Eval
from trytond.pyson import Eval, Id
from trytond.tools.multivalue import migrate_property
from trytond.modules.company.model import (
CompanyMultiValueMixin, CompanyValueMixin)
__all__ = ['Configuration', 'StaffConfigurationSequence']
def default_func(field_name):
@classmethod
@ -25,7 +23,8 @@ class Configuration(
'Staff Configuration'
__name__ = 'staff.configuration'
staff_contract_sequence = fields.Many2One('ir.sequence', 'Contract Sequence',
required=True, domain=[('code', '=', 'staff.contract')])
required=True, domain=[('sequence_type', '=',
Id('staff', 'sequence_type_staff_contract')), ])
default_staff_contract_sequence = default_func('staff_contract_sequence')
@ -44,15 +43,13 @@ class StaffConfigurationSequence(ModelSQL, CompanyValueMixin):
'ir.sequence', "Staff Contract Sequence", required=True,
domain=[
('company', 'in', [Eval('company', -1), None]),
('code', '=', 'staff.contract'),
('sequence_type', '=', Id('staff', 'sequence_type_staff_contract'))
],
depends=['company'])
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
exist = TableHandler.table_exist(cls._table)
exist = backend.TableHandler.table_exist(cls._table)
super(StaffConfigurationSequence, cls).__register__(module_name)
if not exist:

View File

@ -3,10 +3,12 @@
from trytond.model import ModelView, Workflow, ModelSQL, fields
from trytond.pyson import Eval
from trytond.pool import Pool
from trytond.i18n import gettext
from trytond.model.exceptions import AccessError
from trytond.transaction import Transaction
from .exceptions import (StaffContractError)
from sql import Null
__all__ = ['StaffContract']
STATES = {'readonly': (Eval('state') != 'draft')}
@ -67,11 +69,6 @@ class StaffContract(Workflow, ModelSQL, ModelView):
'invisible': Eval('state') != 'active',
},
})
cls._error_messages.update({
'employee_with_contract_current': ('The employee %s already has a contract in draft or active!'),
'missing_contract_sequence': ('The contract sequence is missing on configuration!'),
'finish_contract_out_date': ('You can not to finish a contract with end date on future!'),
})
# @classmethod
# def __register__(cls, module_name):
@ -144,22 +141,21 @@ class StaffContract(Workflow, ModelSQL, ModelView):
def _check_finish_date(self):
today = Pool().get('ir.date').today()
if self.end_date and self.end_date > today:
self.raise_user_error('finish_contract_out_date')
raise StaffContractError(gettext('finish_contract_out_date'))
def set_number(self):
'''
Fill the reference field with the request sequence
'''
pool = Pool()
Sequence = pool.get('ir.sequence')
Config = pool.get('staff.configuration')
config = Config(1)
if self.number:
return
if not config.staff_contract_sequence:
self.raise_user_error('missing_contract_sequence')
number = Sequence.get_id(config.staff_contract_sequence.id)
raise StaffContractError(gettext('missing_contract_sequence'))
number = config.staff_contract_sequence.get()
self.write([self], {'number': number})
@classmethod
@ -171,6 +167,6 @@ class StaffContract(Workflow, ModelSQL, ModelView):
('state', 'in', ('active', 'draft')),
])
if contracts_current:
cls.raise_user_error('employee_with_contract_current',
contracts_current[0].employee.rec_name)
raise AccessError(gettext('employee_with_contract_current',
contract=contracts_current[0].employee.rec_name))
return super(StaffContract, cls).create(vlist)

View File

@ -34,11 +34,10 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.sequence.type" id="sequence_type_staff_contract">
<field name="name">Staff Contract</field>
<field name="code">staff.contract</field>
</record>
<record model="ir.sequence" id="sequence_staff_contract">
<field name="name">Contracts</field>
<field name="code">staff.contract</field>
<field name="sequence_type" ref="sequence_type_staff_contract"/>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_staff_contract_group_admin">

View File

@ -4,8 +4,6 @@ from trytond.model import fields, Unique
from trytond.pool import PoolMeta, Pool
from trytond.transaction import Transaction
__all__ = ['Employee']
class Employee(metaclass=PoolMeta):
__name__ = 'company.employee'
@ -72,7 +70,7 @@ class Employee(metaclass=PoolMeta):
def get_salary(self, name=None):
if self.contract:
return self.contract.last_salary
return self.contract.salary
@fields.depends('contract')
def on_change_with_salary(self):

8
exceptions.py Normal file
View File

@ -0,0 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model.exceptions import ValidationError
class StaffContractError(ValidationError):
pass

View File

@ -3,8 +3,6 @@
#from datetime import datetime
from trytond.model import ModelView, ModelSQL, fields
__all__ = ['Holidays']
class Holidays(ModelSQL, ModelView):
"Holidays"

17
message.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data grouped="1">
<record model="ir.message" id="msg_employee_with_contract_current">
<field name="text">The employee "%(contract)" already has a contract in draft or active!.</field>
</record>
<record model="ir.message" id="msg_missing_contract_sequence">
<field name="text">The contract sequence is missing on configuration!</field>
</record>
<record model="ir.message" id="msg_finish_contract_out_date">
<field name="text">You can not to finish a contract with end date on future!</field>
</record>
</data>
</tryton>

View File

@ -2,8 +2,6 @@
# this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
__all__ = ['Position']
class Position(ModelSQL, ModelView):
'Position'

View File

@ -18,14 +18,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="group" ref="group_staff_admin"/>
</record>
<record model="res.user-res.group" id="user_trigger_group_staff">
<field name="user" ref="res.user_trigger"/>
<field name="group" ref="group_staff"/>
</record>
<record model="res.user-res.group" id="user_trigger_group_staff_admin">
<field name="user" ref="res.user_trigger"/>
<field name="group" ref="group_staff_admin"/>
</record>
<record model="ir.ui.icon" id="staff_icon">
<field name="name">tryton-staff</field>

View File

@ -1,5 +1,5 @@
[tryton]
version=5.0.0
version=6.0.0
depends:
ir
party