Release v6.0
This commit is contained in:
parent
a342d6463c
commit
788a200eda
22
__init__.py
22
__init__.py
|
@ -2,19 +2,19 @@
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from .position import Position
|
from . import position
|
||||||
from .employee import Employee
|
from . import employee
|
||||||
from .holidays import Holidays
|
from . import holidays
|
||||||
from .contract import StaffContract
|
from . import contract
|
||||||
from .configuration import Configuration, StaffConfigurationSequence
|
from . import configuration
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
Holidays,
|
holidays.Holidays,
|
||||||
Position,
|
position.Position,
|
||||||
Employee,
|
employee.Employee,
|
||||||
StaffContract,
|
contract.StaffContract,
|
||||||
Configuration,
|
configuration.Configuration,
|
||||||
StaffConfigurationSequence,
|
configuration.StaffConfigurationSequence,
|
||||||
module='staff', type_='model')
|
module='staff', type_='model')
|
||||||
|
|
|
@ -3,13 +3,11 @@
|
||||||
from trytond import backend
|
from trytond import backend
|
||||||
from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
|
from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
|
||||||
from trytond.pool import Pool
|
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.tools.multivalue import migrate_property
|
||||||
from trytond.modules.company.model import (
|
from trytond.modules.company.model import (
|
||||||
CompanyMultiValueMixin, CompanyValueMixin)
|
CompanyMultiValueMixin, CompanyValueMixin)
|
||||||
|
|
||||||
__all__ = ['Configuration', 'StaffConfigurationSequence']
|
|
||||||
|
|
||||||
|
|
||||||
def default_func(field_name):
|
def default_func(field_name):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -25,7 +23,8 @@ class Configuration(
|
||||||
'Staff Configuration'
|
'Staff Configuration'
|
||||||
__name__ = 'staff.configuration'
|
__name__ = 'staff.configuration'
|
||||||
staff_contract_sequence = fields.Many2One('ir.sequence', 'Contract Sequence',
|
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')
|
default_staff_contract_sequence = default_func('staff_contract_sequence')
|
||||||
|
|
||||||
|
@ -44,15 +43,13 @@ class StaffConfigurationSequence(ModelSQL, CompanyValueMixin):
|
||||||
'ir.sequence', "Staff Contract Sequence", required=True,
|
'ir.sequence', "Staff Contract Sequence", required=True,
|
||||||
domain=[
|
domain=[
|
||||||
('company', 'in', [Eval('company', -1), None]),
|
('company', 'in', [Eval('company', -1), None]),
|
||||||
('code', '=', 'staff.contract'),
|
('sequence_type', '=', Id('staff', 'sequence_type_staff_contract'))
|
||||||
],
|
],
|
||||||
depends=['company'])
|
depends=['company'])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __register__(cls, module_name):
|
def __register__(cls, module_name):
|
||||||
TableHandler = backend.get('TableHandler')
|
exist = backend.TableHandler.table_exist(cls._table)
|
||||||
exist = TableHandler.table_exist(cls._table)
|
|
||||||
|
|
||||||
super(StaffConfigurationSequence, cls).__register__(module_name)
|
super(StaffConfigurationSequence, cls).__register__(module_name)
|
||||||
|
|
||||||
if not exist:
|
if not exist:
|
||||||
|
|
20
contract.py
20
contract.py
|
@ -3,10 +3,12 @@
|
||||||
from trytond.model import ModelView, Workflow, ModelSQL, fields
|
from trytond.model import ModelView, Workflow, ModelSQL, fields
|
||||||
from trytond.pyson import Eval
|
from trytond.pyson import Eval
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
from trytond.i18n import gettext
|
||||||
|
from trytond.model.exceptions import AccessError
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
from .exceptions import (StaffContractError)
|
||||||
from sql import Null
|
from sql import Null
|
||||||
|
|
||||||
__all__ = ['StaffContract']
|
|
||||||
|
|
||||||
STATES = {'readonly': (Eval('state') != 'draft')}
|
STATES = {'readonly': (Eval('state') != 'draft')}
|
||||||
|
|
||||||
|
@ -67,11 +69,6 @@ class StaffContract(Workflow, ModelSQL, ModelView):
|
||||||
'invisible': Eval('state') != 'active',
|
'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
|
# @classmethod
|
||||||
# def __register__(cls, module_name):
|
# def __register__(cls, module_name):
|
||||||
|
@ -144,22 +141,21 @@ class StaffContract(Workflow, ModelSQL, ModelView):
|
||||||
def _check_finish_date(self):
|
def _check_finish_date(self):
|
||||||
today = Pool().get('ir.date').today()
|
today = Pool().get('ir.date').today()
|
||||||
if self.end_date and self.end_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):
|
def set_number(self):
|
||||||
'''
|
'''
|
||||||
Fill the reference field with the request sequence
|
Fill the reference field with the request sequence
|
||||||
'''
|
'''
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Sequence = pool.get('ir.sequence')
|
|
||||||
Config = pool.get('staff.configuration')
|
Config = pool.get('staff.configuration')
|
||||||
config = Config(1)
|
config = Config(1)
|
||||||
|
|
||||||
if self.number:
|
if self.number:
|
||||||
return
|
return
|
||||||
if not config.staff_contract_sequence:
|
if not config.staff_contract_sequence:
|
||||||
self.raise_user_error('missing_contract_sequence')
|
raise StaffContractError(gettext('missing_contract_sequence'))
|
||||||
number = Sequence.get_id(config.staff_contract_sequence.id)
|
number = config.staff_contract_sequence.get()
|
||||||
self.write([self], {'number': number})
|
self.write([self], {'number': number})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -171,6 +167,6 @@ class StaffContract(Workflow, ModelSQL, ModelView):
|
||||||
('state', 'in', ('active', 'draft')),
|
('state', 'in', ('active', 'draft')),
|
||||||
])
|
])
|
||||||
if contracts_current:
|
if contracts_current:
|
||||||
cls.raise_user_error('employee_with_contract_current',
|
raise AccessError(gettext('employee_with_contract_current',
|
||||||
contracts_current[0].employee.rec_name)
|
contract=contracts_current[0].employee.rec_name))
|
||||||
return super(StaffContract, cls).create(vlist)
|
return super(StaffContract, cls).create(vlist)
|
||||||
|
|
|
@ -34,11 +34,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
|
|
||||||
<record model="ir.sequence.type" id="sequence_type_staff_contract">
|
<record model="ir.sequence.type" id="sequence_type_staff_contract">
|
||||||
<field name="name">Staff Contract</field>
|
<field name="name">Staff Contract</field>
|
||||||
<field name="code">staff.contract</field>
|
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence" id="sequence_staff_contract">
|
<record model="ir.sequence" id="sequence_staff_contract">
|
||||||
<field name="name">Contracts</field>
|
<field name="name">Contracts</field>
|
||||||
<field name="code">staff.contract</field>
|
<field name="sequence_type" ref="sequence_type_staff_contract"/>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence.type-res.group"
|
<record model="ir.sequence.type-res.group"
|
||||||
id="sequence_type_staff_contract_group_admin">
|
id="sequence_type_staff_contract_group_admin">
|
||||||
|
|
|
@ -4,8 +4,6 @@ from trytond.model import fields, Unique
|
||||||
from trytond.pool import PoolMeta, Pool
|
from trytond.pool import PoolMeta, Pool
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
__all__ = ['Employee']
|
|
||||||
|
|
||||||
|
|
||||||
class Employee(metaclass=PoolMeta):
|
class Employee(metaclass=PoolMeta):
|
||||||
__name__ = 'company.employee'
|
__name__ = 'company.employee'
|
||||||
|
@ -72,7 +70,7 @@ class Employee(metaclass=PoolMeta):
|
||||||
|
|
||||||
def get_salary(self, name=None):
|
def get_salary(self, name=None):
|
||||||
if self.contract:
|
if self.contract:
|
||||||
return self.contract.last_salary
|
return self.contract.salary
|
||||||
|
|
||||||
@fields.depends('contract')
|
@fields.depends('contract')
|
||||||
def on_change_with_salary(self):
|
def on_change_with_salary(self):
|
||||||
|
|
|
@ -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
|
|
@ -3,8 +3,6 @@
|
||||||
#from datetime import datetime
|
#from datetime import datetime
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import ModelView, ModelSQL, fields
|
||||||
|
|
||||||
__all__ = ['Holidays']
|
|
||||||
|
|
||||||
|
|
||||||
class Holidays(ModelSQL, ModelView):
|
class Holidays(ModelSQL, ModelView):
|
||||||
"Holidays"
|
"Holidays"
|
||||||
|
|
|
@ -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>
|
|
@ -2,8 +2,6 @@
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import ModelView, ModelSQL, fields
|
||||||
|
|
||||||
__all__ = ['Position']
|
|
||||||
|
|
||||||
|
|
||||||
class Position(ModelSQL, ModelView):
|
class Position(ModelSQL, ModelView):
|
||||||
'Position'
|
'Position'
|
||||||
|
|
|
@ -18,14 +18,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="group" ref="group_staff_admin"/>
|
<field name="group" ref="group_staff_admin"/>
|
||||||
</record>
|
</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">
|
<record model="ir.ui.icon" id="staff_icon">
|
||||||
<field name="name">tryton-staff</field>
|
<field name="name">tryton-staff</field>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=5.0.0
|
version=6.0.0
|
||||||
depends:
|
depends:
|
||||||
ir
|
ir
|
||||||
party
|
party
|
||||||
|
|
Loading…
Reference in New Issue