add fields relation line payroll in events

This commit is contained in:
wilson gomez sanchez 2021-04-14 11:36:15 -05:00
parent f315bcd522
commit 5ca7170a06
8 changed files with 69 additions and 11 deletions

View File

@ -10,6 +10,7 @@ import employee
import uvt
import event_category
import account
import event
def register():
@ -47,6 +48,7 @@ def register():
payroll.PayrollLineMoveLine,
payroll.PayrollsMultiPaymentStart,
liquidation.LiquidationExportStart,
event.Event,
module='staff_payroll_co', type_='model')
Pool.register(
payroll.PayrollGlobalReport,

View File

@ -21,11 +21,3 @@ class Configuration(metaclass=PoolMeta):
], required=True)
payment_partial_sunday = fields.Boolean('Payment Partial Sunday')
template_email_confirm = fields.Many2One('email.template', 'Template Email of Confirmation')
period_payroll = fields.Selection([
('1', 'Weekly'),
('2', 'Decennial'),
('3', 'Catorcenal'),
('4', 'Quincenal'),
('5', 'Monthly'),
('6', 'Other')
], 'Period Payroll')

20
event.py Normal file
View File

@ -0,0 +1,20 @@
# 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.model import fields
__all__ = ['Event']
class Event(metaclass=PoolMeta):
'Staff Event'
__name__ = 'staff.event'
line_payroll = fields.Many2One('staff.payroll', 'Line Payroll', states={'readonly': True})
@classmethod
def __setup__(cls):
super(Event, cls).__setup__()
cls._error_messages.update({
})

19
event.xml Normal file
View File

@ -0,0 +1,19 @@
<?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>
<record model="ir.ui.view" id="staff_event_view_form">
<field name="model">staff.event</field>
<field name="inherit" ref="staff_event.staff_event_view_form"/>
<field name="name">staff_event_form</field>
</record>
<record model="ir.ui.view" id="staff_event_view_tree">
<field name="model">staff.event</field>
<field name="inherit" ref="staff_event.staff_event_view_tree"/>
<field name="name">staff_event_tree</field>
</record>
</data>
</tryton>

View File

@ -447,7 +447,6 @@ class Payroll(metaclass=PoolMeta):
('end_date', '>=', self.start),
('state', '=', 'done'),
])
events_lines_to_create = []
absenteeism_days = 0
discounts = {}
for event in events:
@ -465,7 +464,10 @@ class Payroll(metaclass=PoolMeta):
else:
unit_value = wage.compute_unit_price(salary_args)
res = self.get_line(wage, qty_pay, unit_value)
events_lines_to_create.append(res)
# events_lines_to_create.append(res)
line = PayrollLine.create(res)
event.line_payroll = line.id
event.save()
if event.category.wage_type_discount and event.quantity_discount:
id_wt_event = event.category.wage_type_discount.id
@ -475,7 +477,6 @@ class Payroll(metaclass=PoolMeta):
self.absenteeism_days = absenteeism_days
self.save()
PayrollLine.create(events_lines_to_create)
return discounts
def update_wage_no_salary(self):

View File

@ -21,3 +21,4 @@ xml:
event_category.xml
account.xml
employee.xml
event.xml

13
view/staff_event_form.xml Normal file
View File

@ -0,0 +1,13 @@
<?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. -->
<data>
<xpath
expr="/form/field[@name='absenteeism']"
position="after">
<!-- <label name="available_days"/>
<field name="available_days"/> -->
<label name="line_payroll"/>
<field name="line_payroll"/>
</xpath>
</data>

10
view/staff_event_tree.xml Normal file
View File

@ -0,0 +1,10 @@
<?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. -->
<data>
<xpath
expr="/tree/field[@name='end_date']"
position="after">
<!-- <field name="payroll_effect"/> -->
</xpath>
</data>