Add voucher multipayment wizard

This commit is contained in:
Oscar Alvarez 2021-02-23 00:38:03 -05:00
parent 1659be0902
commit ddfebb42ee
6 changed files with 204 additions and 31 deletions

View File

@ -45,6 +45,7 @@ def register():
payroll.PayrollSupportDispersionStart,
employee.UpdateEmployeeStart,
payroll.PayrollLineMoveLine,
payroll.PayrollsMultiPaymentStart,
module='staff_payroll_co', type_='model')
Pool.register(
payroll.PayrollGlobalReport,
@ -74,4 +75,5 @@ def register():
payroll.PayrollSupportDispersion,
employee.UpdateEmployee,
payroll.PayrollFix,
payroll.PayrollsMultiPayment,
module='staff_payroll_co', type_='wizard')

View File

@ -68,7 +68,7 @@ msgstr "El empleado no tiene contrato para el período seleccionado!"
msgctxt "error:staff_payroll.severance_pay_clearing:"
msgid "Missing party in mandatory wage %s for employee %s"
msgstr ""
msgstr "Falta el tercero en el concepto obligatorio %s para el empleado %s"
msgctxt "error:staff_payroll.severance_pay_clearing:"
msgid "Move %s created. \n"
@ -120,7 +120,7 @@ msgstr "Salario Mínimo"
msgctxt "field:staff.configuration,payment_partial_sunday:"
msgid "Payment Partial Sunday"
msgstr ""
msgstr "Pago Parcial del Domingo"
msgctxt "field:staff.configuration,staff_liquidation_sequence:"
msgid "Liquidation Sequence"
@ -248,7 +248,7 @@ msgstr "Número"
msgctxt "field:staff.liquidation,party_to_pay:"
msgid "Party to Pay"
msgstr ""
msgstr "Tercero a Pagar"
msgctxt "field:staff.liquidation,payrolls:"
msgid "Payroll"
@ -340,7 +340,7 @@ msgstr "Terceros"
msgctxt "field:staff.liquidation.line,party_to_pay:"
msgid "Party to Pay"
msgstr ""
msgstr "Tercero a Pagar"
msgctxt "field:staff.liquidation.line,rec_name:"
msgid "Record Name"
@ -416,7 +416,7 @@ msgstr "Descripción"
msgctxt "field:staff.liquidation.line_adjustment,id:"
msgid "ID"
msgstr "UP"
msgstr "ID"
msgctxt "field:staff.liquidation.line_adjustment,rec_name:"
msgid "Record Name"
@ -448,7 +448,7 @@ msgstr "Descripción"
msgctxt "field:staff.liquidation_adjustment.start,id:"
msgid "ID"
msgstr "UP"
msgstr "ID"
msgctxt "field:staff.liquidation_adjustment.start,wage_type:"
msgid "Wage Type"
@ -476,7 +476,7 @@ msgstr "Período Final"
msgctxt "field:staff.liquidation_group.start,id:"
msgid "ID"
msgstr "UP"
msgstr "ID"
msgctxt "field:staff.liquidation_group.start,kind:"
msgid "Kind"
@ -508,7 +508,7 @@ msgstr "Descripción"
msgctxt "field:staff.move_provision_bonus_service.start,id:"
msgid "ID"
msgstr "UP"
msgstr "ID"
msgctxt "field:staff.move_provision_bonus_service.start,period:"
msgid "Period"
@ -568,7 +568,7 @@ msgstr "Período Final"
msgctxt "field:staff.payroll.export.start,id:"
msgid "ID"
msgstr "UP"
msgstr "ID"
msgctxt "field:staff.payroll.export.start,start_period:"
msgid "Start Period"
@ -596,44 +596,36 @@ msgstr "Período Inicial"
msgctxt "field:staff.payroll.line,move_lines:"
msgid "Payroll Line - Move Line"
msgstr ""
msgstr "Línea de Nómina - Línea de Asiento"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgstr "Usuario de creación"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,id:"
msgid "ID"
msgstr "UP"
msgstr "ID"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,line:"
msgid "Line"
msgstr "Línea"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,move_line:"
msgid "Move Line"
msgstr "Línea de Asiento"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
#, fuzzy
msgctxt "field:staff.payroll.line-move.line,write_uid:"
msgid "Write User"
msgstr "Usuario Modificación"
@ -696,7 +688,7 @@ msgstr "Período Final"
msgctxt "field:staff.payroll_exo2276.start,id:"
msgid "ID"
msgstr "UP"
msgstr "ID"
msgctxt "field:staff.payroll_exo2276.start,start_period:"
msgid "Start Period"
@ -730,6 +722,34 @@ msgctxt "field:staff.payroll_group.start,department:"
msgid "Department"
msgstr "Departamento"
msgctxt "field:staff.payroll_multi_payment.start,company:"
msgid "Company"
msgstr "Empresa"
msgctxt "field:staff.payroll_multi_payment.start,department:"
msgid "Department"
msgstr "Departamento"
msgctxt "field:staff.payroll_multi_payment.start,description:"
msgid "Description"
msgstr "Descripción"
msgctxt "field:staff.payroll_multi_payment.start,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:staff.payroll_multi_payment.start,payment_mode:"
msgid "Payment Mode"
msgstr "Modo de Pago"
msgctxt "field:staff.payroll_multi_payment.start,period:"
msgid "Period"
msgstr "Período"
msgctxt "field:staff.payroll_multi_payment.start,wage_type:"
msgid "Wage Type"
msgstr "Tipo de Pago"
msgctxt "field:staff.payroll_paycheck.start,company:"
msgid "Company"
msgstr "Compañia"
@ -1021,6 +1041,10 @@ msgctxt "model:ir.action,name:payroll_export_wizard"
msgid "Payroll Export Wizard"
msgstr ""
msgctxt "model:ir.action,name:payroll_multi_payment_wizard"
msgid "Create Payroll MultiPayment"
msgstr "Crear Multipago de Nómina "
msgctxt "model:ir.action,name:report_exo_2276"
msgid "Exo 2276 Report"
msgstr "Reporte Exogena2276"
@ -1065,6 +1089,10 @@ msgctxt "model:ir.action,name:wizard_fix_payroll"
msgid "Fix Payroll"
msgstr ""
msgctxt "model:ir.action,name:wizard_fix_payroll_account"
msgid "Fix Payroll Account"
msgstr ""
msgctxt "model:ir.action,name:wizard_move_provision_bonus_service"
msgid "Create Provision Bonus Service"
msgstr "Crear Provisión Prima de Servicios"
@ -1152,6 +1180,10 @@ msgctxt "model:ir.ui.menu,name:menu_payroll_global"
msgid "Payroll Global Wizard"
msgstr "Nómina Consolidada"
msgctxt "model:ir.ui.menu,name:menu_payroll_multi_payment_wizard"
msgid "Create Payroll MultiPayment"
msgstr "Crear Multipago de Nómina "
msgctxt "model:ir.ui.menu,name:menu_payroll_paycheck"
msgid "Payroll Paycheck Wizard"
msgstr "Liquidación Planilla Pila"
@ -1222,7 +1254,7 @@ msgstr "Certificado Ingresos y Retenciones"
msgctxt "model:staff.payroll.line-move.line,name:"
msgid "Payroll Line - MoveLine"
msgstr ""
msgstr "Línea de Nómina - Línea de Asiento"
msgctxt "model:staff.payroll.sheet.start,name:"
msgid "Payroll Sheet Start"
@ -1240,6 +1272,10 @@ msgctxt "model:staff.payroll_global.start,name:"
msgid "Payroll Global Start"
msgstr "Nómina Consolidada"
msgctxt "model:staff.payroll_multi_payment.start,name:"
msgid "Payroll Multi Payment Start"
msgstr "Crear Multipago de Nómina "
msgctxt "model:staff.payroll_paycheck.start,name:"
msgid "Payroll Paycheck Start"
msgstr "Liquidación Planilla Pila"
@ -1268,10 +1304,9 @@ msgctxt "model:staff_payroll_co.payroll_by_period_dynamic,name:"
msgid "Payroll By Period Dynamic"
msgstr "Nómina por Período Dinamica"
#, fuzzy
msgctxt "selection:staff.event_category,discount_method:"
msgid ""
msgstr "Punto de Orden"
msgstr ""
msgctxt "selection:staff.event_category,discount_method:"
msgid "Fixed Amount"
@ -1337,10 +1372,9 @@ msgctxt "selection:staff.liquidation_group.start,kind:"
msgid "Vacation"
msgstr "Vacaciones"
#, fuzzy
msgctxt "selection:staff.wage_type,round_amounts:"
msgid ""
msgstr "Punto de Orden"
msgstr ""
msgctxt "selection:staff.wage_type,round_amounts:"
msgid "Above Amount"
@ -1486,7 +1520,6 @@ msgctxt "view:staff.liquidation:"
msgid "Post"
msgstr "Contabilizar"
#, fuzzy
msgctxt "view:staff.payroll.line:"
msgid "General"
msgstr "General"
@ -1631,6 +1664,18 @@ msgctxt "wizard_button:staff.payroll_exo2276,start,print_:"
msgid "Print"
msgstr "Imprimir"
msgctxt "wizard_button:staff.payroll_multi_payment,start,create_:"
msgid "Accept"
msgstr "Aceptar"
msgctxt "wizard_button:staff.payroll_multi_payment,start,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:staff.payroll_multi_payment,start,open_:"
msgid "Accept"
msgstr "Aceptar"
msgctxt "wizard_button:staff_payroll.severance_pay_clearing,done,end:"
msgid "Done"
msgstr "Hecho"

View File

@ -8,7 +8,9 @@ from trytond.exceptions import UserError
from trytond.model import ModelView, fields, Workflow, ModelSQL
from trytond.pool import Pool, PoolMeta
from trytond.report import Report
from trytond.wizard import Wizard, StateView, Button, StateAction, StateReport, StateTransition
from trytond.wizard import (
Wizard, StateView, Button, StateAction, StateReport, StateTransition
)
from trytond.transaction import Transaction
from trytond.pyson import Eval
from trytond.modules.staff_payroll import Period
@ -26,6 +28,7 @@ __all__ = [
'ExportMovesReport', 'IncomeWithholdingsReport', 'PayrollExportStart',
'PayrollExport', 'PayrollExportReport', 'PayrollSupportDispersionStart',
'PayrollSupportDispersion', 'PayrollLineMoveLine', 'PayrollFix',
'PayrollsMultiPayment', 'PayrollsMultiPaymentStart',
]
@ -33,8 +36,9 @@ STATES = {'readonly': (Eval('state') != 'draft')}
_ZERO = Decimal('0.0')
PAYMENTS = ['salary', 'bonus', 'reco', 'recf', 'hedo', 'heno',
'dom', 'hedf', 'henf']
PAYMENTS = [
'salary', 'bonus', 'reco', 'recf', 'hedo', 'heno', 'dom', 'hedf', 'henf',
]
SOCIAL_SEGURITY = [
'risk', 'health', 'retirement', 'box_family', 'sena', 'icbf'
@ -1965,3 +1969,93 @@ class PayrollFix(Wizard):
# p.move.save()
return 'end'
class PayrollsMultiPaymentStart(ModelView):
'Payroll Multi Payment Start'
__name__ = 'staff.payroll_multi_payment.start'
period = fields.Many2One('staff.payroll.period', 'Period',
required=True, domain=[('state', '=', 'open')])
payment_mode = fields.Many2One('account.voucher.paymode', 'Payment Mode',
required=True)
company = fields.Many2One('company.company', 'Company',
required=True)
department = fields.Many2One('company.department', 'Department')
wage_type = fields.Many2One('staff.wage_type', 'Wage Type', domain=[
('definition', '=', 'payment'),
('type_concept', '=', 'salary'),
], required=True)
description = fields.Char('Description')
@staticmethod
def default_company():
return Transaction().context.get('company')
class PayrollsMultiPayment(Wizard):
'Payrolls MultiPayment'
__name__ = 'staff.payroll_multi_payment'
start = StateView('staff.payroll_multi_payment.start',
'staff_payroll_co.payroll_multi_payment_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Accept', 'open_', 'tryton-ok', default=True),
])
open_ = StateTransition()
# create_ = StateTransition()
def transition_open_(self):
pool = Pool()
Payroll = pool.get('staff.payroll')
Voucher = pool.get('account.voucher')
MoveLine = pool.get('account.move.line')
dom_pay = [
('period', '=', self.start.period.id),
('state', '=', 'posted'),
('move', '!=', None),
]
if self.start.department:
dom_pay.append(
('department', '=', self.start.period.id)
)
payrolls = Payroll.search(dom_pay)
moves_payroll_ids = [p.move.id for p in payrolls]
lines = MoveLine.search([
('account', '=', self.start.wage_type.credit_account.id),
('move', 'in', moves_payroll_ids),
('reconciliation', '=', None),
('party', '!=', None),
('credit', '>', 0),
])
line_to_create = []
for line in lines:
line_to_create.append({
'amount': line.credit,
'account': line.account.id,
'party': line.party.id,
'move_line': line.id,
'detail': line.move.origin.number,
'amount_original': line.credit,
})
account_id = Voucher.get_account('multipayment', self.start.payment_mode)
journal_id = self.start.payment_mode.journal.id
voucher, = Voucher.create([{
'payment_mode': self.start.payment_mode.id,
'date': self.start.period.end,
'voucher_type': 'multipayment',
'lines': [('create', line_to_create)],
'journal': journal_id,
'state': 'draft',
'account': account_id,
'description': self.start.description,
}])
amount_to_pay = voucher._get_amount_to_pay()
voucher.amount_to_pay = amount_to_pay
print(voucher)
voucher.save()
return 'end'
# def transition_create_(self):
# return 'open_'

View File

@ -309,5 +309,18 @@ this repository contains the full copyright notices and license terms. -->
<field name="model">staff.payroll,-1</field>
<field name="action" ref="wizard_fix_payroll_account"/>
</record>
<record model="ir.ui.view" id="payroll_multi_payment_start_view_form">
<field name="model">staff.payroll_multi_payment.start</field>
<field name="type">form</field>
<field name="name">payroll_multi_payment_start_form</field>
</record>
<record model="ir.action.wizard" id="payroll_multi_payment_wizard">
<field name="name">Create Payroll MultiPayment</field>
<field name="wiz_name">staff.payroll_multi_payment</field>
</record>
<menuitem parent="staff.menu_staff" id="menu_payroll_multi_payment_wizard"
action="payroll_multi_payment_wizard"/>
</data>
</tryton>

View File

@ -1,5 +1,5 @@
[tryton]
version=5.0.7
version=5.0.8
depends:
company
company_department
@ -9,6 +9,7 @@ depends:
staff_co
staff_event
staff_payroll
account_voucher
email
xml:
configuration.xml

View File

@ -0,0 +1,18 @@
<?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. -->
<form >
<label name="period"/>
<field name="period" widget="selection"/>
<label name="company"/>
<field name="company" widget="selection"/>
<label name="payment_mode"/>
<field name="payment_mode" widget="selection"/>
<label name="wage_type"/>
<field name="wage_type" widget="selection"/>
<label name="department"/>
<field name="department" widget="selection"/>
<newline />
<label name="description"/>
<field name="description" colspan="3"/>
</form>