Fix select contracts
This commit is contained in:
parent
2119273ae9
commit
0104ea3e8c
|
@ -695,8 +695,6 @@ class LiquidationAdjustment(Wizard):
|
|||
class LiquidationGroupStart(ModelView):
|
||||
'Liquidation Group Start'
|
||||
__name__ = 'staff.liquidation_group.start'
|
||||
employees = fields.Many2Many('company.employee', None, None, 'Employee',
|
||||
required=True)
|
||||
start_period = fields.Many2One('staff.payroll.period', 'Start Period',
|
||||
required=True)
|
||||
end_period = fields.Many2One('staff.payroll.period', 'End Period',
|
||||
|
@ -710,11 +708,12 @@ class LiquidationGroupStart(ModelView):
|
|||
liquidation_date = fields.Date('Liquidation Date', required=True)
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
description = fields.Char('Description', required=True)
|
||||
account = fields.Many2One('account.account', 'Account',
|
||||
required=True, domain=[
|
||||
('kind', '!=', 'view'),
|
||||
account = fields.Many2One('account.account', 'Account', required=True,
|
||||
domain=[
|
||||
('kind', '=', 'payable'),
|
||||
('company', '=', Eval('company'))
|
||||
])
|
||||
employees = fields.Many2Many('company.employee', None, None, 'Employee')
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
|
@ -745,34 +744,40 @@ class LiquidationGroup(Wizard):
|
|||
description = self.start.description
|
||||
currency_id = self.start.company.currency.id
|
||||
account_id = self.start.account.id
|
||||
employees = self.start.employees
|
||||
employee_ids = [e.id for e in employees]
|
||||
|
||||
contracts = Liquidation.search_read([
|
||||
('employee', 'in', employee_ids),
|
||||
('kind', '=', kind)
|
||||
], fields_names=['contract'])
|
||||
dom_contracts = [('kind', '=', kind)]
|
||||
if self.start.employees:
|
||||
employees = self.start.employees
|
||||
employee_ids = [e.id for e in employees]
|
||||
dom_contracts.append(('employee', 'in', employee_ids))
|
||||
|
||||
contracts = Liquidation.search_read(
|
||||
dom_contracts, fields_names=['contract']
|
||||
)
|
||||
contract_ids = [i['contract'] for i in contracts]
|
||||
for employee in employees:
|
||||
contracts = Contract.search([
|
||||
('employee', '=', employee.id),
|
||||
('id', 'not in', contract_ids),
|
||||
])
|
||||
for contract in contracts:
|
||||
lqt_create = {
|
||||
'start_period': start_period,
|
||||
'end_period': end_period,
|
||||
'employee': employee.id,
|
||||
'contract': contract.id,
|
||||
'kind': kind,
|
||||
'liquidation_date': liquidation_date,
|
||||
'time_contracting': None,
|
||||
'state': 'draft',
|
||||
'company': company_id,
|
||||
'description': description,
|
||||
'currency': currency_id,
|
||||
'account': account_id
|
||||
}
|
||||
if not contracts:
|
||||
continue
|
||||
|
||||
contract = contracts[0]
|
||||
lqt_create = {
|
||||
'start_period': start_period,
|
||||
'end_period': end_period,
|
||||
'employee': employee.id,
|
||||
'contract': contract.id,
|
||||
'kind': kind,
|
||||
'liquidation_date': liquidation_date,
|
||||
'time_contracting': None,
|
||||
'state': 'draft',
|
||||
'company': company_id,
|
||||
'description': description,
|
||||
'currency': currency_id,
|
||||
'account': account_id
|
||||
}
|
||||
liquidation, = Liquidation.create([lqt_create])
|
||||
liquidation.on_change_with_time_contracting()
|
||||
liquidation.save()
|
||||
|
|
Loading…
Reference in New Issue