Fix import

This commit is contained in:
Oscar 2021-08-12 20:41:35 -05:00
parent 351d86050e
commit 1f647318a2
4 changed files with 48 additions and 73 deletions

View File

@ -332,7 +332,6 @@ class Employee(metaclass=PoolMeta):
Contract.active([contract])
cont += 1
return cont
def get_party_concept(self, name=None):
@ -344,72 +343,52 @@ class Employee(metaclass=PoolMeta):
break
return res
def get_party_bank(self, name=None):
return None
def update_employee(data):
pool = Pool()
MandatoryWage = pool.get('staff.payroll.mandatory_wage')
Employee = pool.get('company.employee')
Party = pool.get('party.party')
# Party = pool.get('party.party')
headers = data[0]
data = data[1:]
# print(parties)
for row in data:
emp = row[0]
dom = [('party.id_number', '=', str(emp)), ]
employee = Employee.search(dom)
if employee:
for e in employee:
dom = [
('employee', '=', e.id),
('wage_type.type_concept', 'in', ['health', 'retirement', 'risk', 'box_family' ])
]
lines = MandatoryWage.search(dom)
for line in lines:
concept = line.wage_type.type_concept
if concept == 'health':
value = row[1]
elif concept == 'retirement':
value = row[2]
elif concept == 'risk':
value = row[3]
elif concept == 'box_family':
value = row[4]
if value:
parties = Party.search([('id_number', '=', value)])
if parties:
MandatoryWage.write([line], {'party': parties[0].id})
else:
raise ImportDataEmployeeError(
gettext('staff_payroll_co.msg_party_not_exists', s=value))
if value:
parties = Party.search([('id_number', '=', value)])
if parties:
MandatoryWage.write([line], {'party': parties[0].id})
else:
raise ImportDataEmployeeError(
gettext('staff_payroll_co.msg_party_not_exists', s=value))
if value:
parties = Party.search([('id_number', '=', value)])
if parties:
MandatoryWage.write([line], {'party': parties[0].id})
else:
raise ImportDataEmployeeError(
gettext('staff_payroll_co.msg_party_not_exists', s=value))
if value:
parties = Party.search([('id_number', '=', value)])
if parties:
MandatoryWage.write([line], {'party': parties[0].id})
else:
raise ImportDataEmployeeError(
gettext('staff_payroll_co.msg_party_not_exists', s=value))
else:
emp = str(row[0])
employees = Employee.search([
('party.id_number', '=', emp)
])
if not employees:
raise ImportDataEmployeeError(
gettext('staff_payroll_co.msg_party_not_exists', s=value))
return
gettext('staff_payroll_co.msg_party_not_exists', s=emp))
else:
employee = employees[0]
def get_party_bank(self, name=None):
return None
lines = MandatoryWage.search([
('employee', '=', employee.id),
('wage_type.type_concept', 'in', [
'health', 'retirement', 'risk', 'box_family'
])
]
for line in lines:
concept = line.wage_type.type_concept
value = None
if concept == 'health':
value = row[1]
elif concept == 'retirement':
value = row[2]
elif concept == 'risk':
value = row[3]
elif concept == 'box_family':
value = row[4]
if not value:
continue
parties = Party.search([('id_number', '=', value)])
if parties:
MandatoryWage.write([line], {'party': parties[0].id})
else:
raise ImportDataEmployeeError(
gettext('staff_payroll_co.msg_party_not_exists', s=value))
class MandatoryWage(metaclass=PoolMeta):
@ -442,8 +421,9 @@ class UpdateEmployeeStart(ModelView):
'Update Employee Start'
__name__ = 'staff.employee.update_employee.start'
company = fields.Many2One('company.company', 'Company', required=True)
file = fields.Binary('CSV file', help="Load file csv separated comma in utf-8 format",
required=True, filename='employees_update')
file = fields.Binary(
'CSV file', help="Load file csv separated comma in utf-8 format",
required=True, filename='employees_update')
@staticmethod
def default_company():
@ -463,7 +443,6 @@ class UpdateEmployee(Wizard):
def transition_open_(self):
pool = Pool()
company = self.start.company
Employee = pool.get('company.employee')
csv_file = self.start.file.decode('utf-8')
reader = csv_file.splitlines()

View File

@ -1,16 +1,11 @@
# 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 decimal import Decimal
from trytond.pool import PoolMeta, Pool
from trytond.pool import PoolMeta
from trytond.model import fields
class Event(metaclass=PoolMeta):
'Staff Event'
__name__ = 'staff.event'
line_payroll = fields.Many2One('staff.payroll.line', 'Line Payroll', states={'readonly': True})
@classmethod
def __setup__(cls):
super(Event, cls).__setup__()
line_payroll = fields.Many2One('staff.payroll.line',
'Line Payroll', states={'readonly': True})

View File

@ -1,8 +1,6 @@
# 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 decimal import Decimal
from datetime import timedelta, date
from trytond import backend
from trytond.model import Workflow, ModelSQL, ModelView, fields
from trytond.pool import Pool
from trytond.report import Report
@ -10,8 +8,10 @@ from trytond.pyson import Eval, If, Bool
from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
from trytond.transaction import Transaction
from trytond.i18n import gettext
from .exceptions import (LiquidationEmployeeError, MissingSecuenceLiquidation,
LiquidationMoveError, WageTypeConceptError)
from .exceptions import (
LiquidationEmployeeError, MissingSecuenceLiquidation,
LiquidationMoveError, WageTypeConceptError
)
STATES = {'readonly': (Eval('state') != 'draft')}

View File

@ -22,3 +22,4 @@ xml:
account.xml
employee.xml
event.xml
message.xml