|
- # -*- coding: utf-8 -*-
- # Copyright 2016 上海开阖软件有限公司 (http://www.osbzr.com)
- # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-
- from odoo import fields, models, api, _
-
- change = [('time', '计时'),
- ('piece', '计件'),
- ('efficiency', '计效')]
-
-
- class CreateWagesLineWizard(models.TransientModel):
- _name = 'create.wages.line.wizard'
- _description = 'input staff wages'
-
- wages_change = fields.Selection(change, '记工类型')
-
- def input_change_wages(self):
- if not self.env.context.get('active_id'):
- return
- date = fields.Date.context_today(self)
- wages = self.env['staff.wages'].browse(
- self.env.context.get('active_id'))
- staff_ids = self.env['staff'].search(['&',
- ('active', '=', True),
- ('contract_ids', '!=', False)])
- for staff in staff_ids:
- for line in staff.contract_ids:
- if date < line.over_date and (self.wages_change == line.wages_change or not self.wages_change):
- self.env['wages.line'].create({
- 'name': staff.id,
- 'order_id': wages.id,
- 'basic_wage': line.basic_wage,
- 'basic_date': line.basic_date if hasattr(line, 'basic_date') else 21.75,
- 'endowment': line.endowment,
- 'health': line.health,
- 'unemployment': line.unemployment,
- 'housing_fund': line.housing_fund,
- 'endowment_co': line.endowment_co if hasattr(line, 'endowment_co') else 0,
- 'health_co': line.health_co if hasattr(line, 'health_co') else 0,
- 'unemployment_co': line.unemployment_co if hasattr(line, 'unemployment_co') else 0,
- 'housing_fund_co': line.housing_fund_co if hasattr(line, 'housing_fund_co') else 0,
- 'injury': line.injury if hasattr(line, 'injury') else 0,
- 'maternity': line.maternity if hasattr(line, 'maternity') else 0,
- })
- continue
|