Browse Source

[FIX] Bug Fixed 'Payroll'

pull/134/merge
Ajmalcybrosys 6 years ago
parent
commit
5e8b10d413
  1. 2
      hr_payroll_account_community/__manifest__.py
  2. 2
      hr_payroll_account_community/models/hr_payroll_account.py
  3. 1
      hr_payroll_account_community/wizard/hr_payroll_payslips_by_employees.py
  4. 2
      hr_payroll_community/__manifest__.py
  5. 3
      hr_payroll_community/models/hr_contract.py
  6. 1
      hr_payroll_community/models/hr_employee.py
  7. 12
      hr_payroll_community/models/hr_payslip.py
  8. 6
      hr_payroll_community/models/hr_salary_rule.py
  9. 1
      hr_payroll_community/wizard/hr_payroll_contribution_register_report.py
  10. 1
      hr_payroll_community/wizard/hr_payroll_payslips_by_employees.py

2
hr_payroll_account_community/__manifest__.py

@ -7,7 +7,7 @@
Generic Payroll system Integrated with Accounting,Expense Encoding,Payment Encoding,Company Contribution Management Generic Payroll system Integrated with Accounting,Expense Encoding,Payment Encoding,Company Contribution Management
""", """,
'description': """Odoo13 Payroll Accounting,Odoo13 Payroll,Odoo 13,Payroll Accounting,Accounting""", 'description': """Odoo13 Payroll Accounting,Odoo13 Payroll,Odoo 13,Payroll Accounting,Accounting""",
'version': '13.0.1.0.0', 'version': '13.0.1.0.1',
'author': 'Odoo SA,Cybrosys Techno Solutions', 'author': 'Odoo SA,Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions',

2
hr_payroll_account_community/models/hr_payroll_account.py

@ -43,14 +43,12 @@ class HrPayslip(models.Model):
super(HrPayslip, self).onchange_contract() super(HrPayslip, self).onchange_contract()
self.journal_id = self.contract_id.journal_id.id or (not self.contract_id and self.default_get(['journal_id'])['journal_id']) self.journal_id = self.contract_id.journal_id.id or (not self.contract_id and self.default_get(['journal_id'])['journal_id'])
@api.multi
def action_payslip_cancel(self): def action_payslip_cancel(self):
moves = self.mapped('move_id') moves = self.mapped('move_id')
moves.filtered(lambda x: x.state == 'posted').button_cancel() moves.filtered(lambda x: x.state == 'posted').button_cancel()
moves.unlink() moves.unlink()
return super(HrPayslip, self).action_payslip_cancel() return super(HrPayslip, self).action_payslip_cancel()
@api.multi
def action_payslip_done(self): def action_payslip_done(self):
res = super(HrPayslip, self).action_payslip_done() res = super(HrPayslip, self).action_payslip_done()

1
hr_payroll_account_community/wizard/hr_payroll_payslips_by_employees.py

@ -5,7 +5,6 @@ from odoo import api, models
class HrPayslipEmployees(models.TransientModel): class HrPayslipEmployees(models.TransientModel):
_inherit = 'hr.payslip.employees' _inherit = 'hr.payslip.employees'
@api.multi
def compute_sheet(self): def compute_sheet(self):
journal_id = False journal_id = False
if self.env.context.get('active_id'): if self.env.context.get('active_id'):

2
hr_payroll_community/__manifest__.py

@ -3,7 +3,7 @@
{ {
'name': 'Odoo13 Payroll', 'name': 'Odoo13 Payroll',
'category': 'Generic Modules/Human Resources', 'category': 'Generic Modules/Human Resources',
'version': '13.0.1.0.0', 'version': '13.0.1.0.1',
'author': 'Odoo SA,Cybrosys Techno Solutions', 'author': 'Odoo SA,Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions',

3
hr_payroll_community/models/hr_contract.py

@ -24,7 +24,6 @@ class HrContract(models.Model):
help="Defines the frequency of the wage payment.") help="Defines the frequency of the wage payment.")
resource_calendar_id = fields.Many2one(required=True, help="Employee's working schedule.") resource_calendar_id = fields.Many2one(required=True, help="Employee's working schedule.")
@api.multi
def get_all_structures(self): def get_all_structures(self):
""" """
@return: the structures linked to the given contracts, ordered by hierachy (parent=False first, @return: the structures linked to the given contracts, ordered by hierachy (parent=False first,
@ -36,11 +35,9 @@ class HrContract(models.Model):
# YTI TODO return browse records # YTI TODO return browse records
return list(set(structures._get_parent_structure().ids)) return list(set(structures._get_parent_structure().ids))
@api.multi
def get_attribute(self, code, attribute): def get_attribute(self, code, attribute):
return self.env['hr.contract.advantage.template'].search([('code', '=', code)], limit=1)[attribute] return self.env['hr.contract.advantage.template'].search([('code', '=', code)], limit=1)[attribute]
@api.multi
def set_attribute_value(self, code, active): def set_attribute_value(self, code, active):
for contract in self: for contract in self:
if active: if active:

1
hr_payroll_community/models/hr_employee.py

@ -10,7 +10,6 @@ class HrEmployee(models.Model):
slip_ids = fields.One2many('hr.payslip', 'employee_id', string='Payslips', readonly=True) slip_ids = fields.One2many('hr.payslip', 'employee_id', string='Payslips', readonly=True)
payslip_count = fields.Integer(compute='_compute_payslip_count', string='Payslip Count', groups="hr_payroll_community.group_hr_payroll_user") payslip_count = fields.Integer(compute='_compute_payslip_count', string='Payslip Count', groups="hr_payroll_community.group_hr_payroll_user")
@api.multi
def _compute_payslip_count(self): def _compute_payslip_count(self):
for employee in self: for employee in self:
employee.payslip_count = len(employee.slip_ids) employee.payslip_count = len(employee.slip_ids)

12
hr_payroll_community/models/hr_payslip.py

@ -72,12 +72,10 @@ class HrPayslip(models.Model):
copy=False, states={'draft': [('readonly', False)]}) copy=False, states={'draft': [('readonly', False)]})
payslip_count = fields.Integer(compute='_compute_payslip_count', string="Payslip Computation Details") payslip_count = fields.Integer(compute='_compute_payslip_count', string="Payslip Computation Details")
@api.multi
def _compute_details_by_salary_rule_category(self): def _compute_details_by_salary_rule_category(self):
for payslip in self: for payslip in self:
payslip.details_by_salary_rule_category = payslip.mapped('line_ids').filtered(lambda line: line.category_id) payslip.details_by_salary_rule_category = payslip.mapped('line_ids').filtered(lambda line: line.category_id)
@api.multi
def _compute_payslip_count(self): def _compute_payslip_count(self):
for payslip in self: for payslip in self:
payslip.payslip_count = len(payslip.line_ids) payslip.payslip_count = len(payslip.line_ids)
@ -87,22 +85,18 @@ class HrPayslip(models.Model):
if any(self.filtered(lambda payslip: payslip.date_from > payslip.date_to)): if any(self.filtered(lambda payslip: payslip.date_from > payslip.date_to)):
raise ValidationError(_("Payslip 'Date From' must be earlier 'Date To'.")) raise ValidationError(_("Payslip 'Date From' must be earlier 'Date To'."))
@api.multi
def action_payslip_draft(self): def action_payslip_draft(self):
return self.write({'state': 'draft'}) return self.write({'state': 'draft'})
@api.multi
def action_payslip_done(self): def action_payslip_done(self):
self.compute_sheet() self.compute_sheet()
return self.write({'state': 'done'}) return self.write({'state': 'done'})
@api.multi
def action_payslip_cancel(self): def action_payslip_cancel(self):
if self.filtered(lambda slip: slip.state == 'done'): if self.filtered(lambda slip: slip.state == 'done'):
raise UserError(_("Cannot cancel a payslip that is done.")) raise UserError(_("Cannot cancel a payslip that is done."))
return self.write({'state': 'cancel'}) return self.write({'state': 'cancel'})
@api.multi
def refund_sheet(self): def refund_sheet(self):
for payslip in self: for payslip in self:
copied_payslip = payslip.copy({'credit_note': True, 'name': _('Refund: ') + payslip.name}) copied_payslip = payslip.copy({'credit_note': True, 'name': _('Refund: ') + payslip.name})
@ -123,11 +117,9 @@ class HrPayslip(models.Model):
'context': {} 'context': {}
} }
@api.multi
def check_done(self): def check_done(self):
return True return True
@api.multi
def unlink(self): def unlink(self):
if any(self.filtered(lambda payslip: payslip.state not in ('draft', 'cancel'))): if any(self.filtered(lambda payslip: payslip.state not in ('draft', 'cancel'))):
raise UserError(_('You cannot delete a payslip which is not draft or cancelled!')) raise UserError(_('You cannot delete a payslip which is not draft or cancelled!'))
@ -151,7 +143,6 @@ class HrPayslip(models.Model):
clause_final = [('employee_id', '=', employee.id), ('state', '=', 'open'), '|', '|'] + clause_1 + clause_2 + clause_3 clause_final = [('employee_id', '=', employee.id), ('state', '=', 'open'), '|', '|'] + clause_1 + clause_2 + clause_3
return self.env['hr.contract'].search(clause_final).ids return self.env['hr.contract'].search(clause_final).ids
@api.multi
def compute_sheet(self): def compute_sheet(self):
for payslip in self: for payslip in self:
number = payslip.number or self.env['ir.sequence'].next_by_code('salary.slip') number = payslip.number or self.env['ir.sequence'].next_by_code('salary.slip')
@ -386,7 +377,6 @@ class HrPayslip(models.Model):
# YTI TODO To rename. This method is not really an onchange, as it is not in any view # YTI TODO To rename. This method is not really an onchange, as it is not in any view
# employee_id and contract_id could be browse records # employee_id and contract_id could be browse records
@api.multi
def onchange_employee_id(self, date_from, date_to, employee_id=False, contract_id=False): def onchange_employee_id(self, date_from, date_to, employee_id=False, contract_id=False):
#defaults #defaults
res = { res = {
@ -585,11 +575,9 @@ class HrPayslipRun(models.Model):
states={'draft': [('readonly', False)]}, states={'draft': [('readonly', False)]},
help="If its checked, indicates that all payslips generated from here are refund payslips.") help="If its checked, indicates that all payslips generated from here are refund payslips.")
@api.multi
def draft_payslip_run(self): def draft_payslip_run(self):
return self.write({'state': 'draft'}) return self.write({'state': 'draft'})
@api.multi
def close_payslip_run(self): def close_payslip_run(self):
return self.write({'state': 'close'}) return self.write({'state': 'close'})

6
hr_payroll_community/models/hr_salary_rule.py

@ -34,14 +34,12 @@ class HrPayrollStructure(models.Model):
if not self._check_recursion(): if not self._check_recursion():
raise ValidationError(_('You cannot create a recursive salary structure.')) raise ValidationError(_('You cannot create a recursive salary structure.'))
@api.multi
@api.returns('self', lambda value: value.id) @api.returns('self', lambda value: value.id)
def copy(self, default=None): def copy(self, default=None):
self.ensure_one() self.ensure_one()
default = dict(default or {}, code=_("%s (copy)") % (self.code)) default = dict(default or {}, code=_("%s (copy)") % (self.code))
return super(HrPayrollStructure, self).copy(default) return super(HrPayrollStructure, self).copy(default)
@api.multi
def get_all_rules(self): def get_all_rules(self):
""" """
@return: returns a list of tuple (id, sequence) of rules that are maybe to apply @return: returns a list of tuple (id, sequence) of rules that are maybe to apply
@ -51,7 +49,6 @@ class HrPayrollStructure(models.Model):
all_rules += struct.rule_ids._recursive_search_of_rules() all_rules += struct.rule_ids._recursive_search_of_rules()
return all_rules return all_rules
@api.multi
def _get_parent_structure(self): def _get_parent_structure(self):
parent = self.mapped('parent_id') parent = self.mapped('parent_id')
if parent: if parent:
@ -177,7 +174,6 @@ class HrSalaryRule(models.Model):
if not self._check_recursion(parent='parent_rule_id'): if not self._check_recursion(parent='parent_rule_id'):
raise ValidationError(_('Error! You cannot create recursive hierarchy of Salary Rules.')) raise ValidationError(_('Error! You cannot create recursive hierarchy of Salary Rules.'))
@api.multi
def _recursive_search_of_rules(self): def _recursive_search_of_rules(self):
""" """
@return: returns a list of tuple (id, sequence) which are all the children of the passed rule_ids @return: returns a list of tuple (id, sequence) which are all the children of the passed rule_ids
@ -188,7 +184,6 @@ class HrSalaryRule(models.Model):
return [(rule.id, rule.sequence) for rule in self] + children_rules return [(rule.id, rule.sequence) for rule in self] + children_rules
#TODO should add some checks on the type of result (should be float) #TODO should add some checks on the type of result (should be float)
@api.multi
def _compute_rule(self, localdict): def _compute_rule(self, localdict):
""" """
:param localdict: dictionary containing the environement in which to compute the rule :param localdict: dictionary containing the environement in which to compute the rule
@ -215,7 +210,6 @@ class HrSalaryRule(models.Model):
except: except:
raise UserError(_('Wrong python code defined for salary rule %s (%s).') % (self.name, self.code)) raise UserError(_('Wrong python code defined for salary rule %s (%s).') % (self.name, self.code))
@api.multi
def _satisfy_condition(self, localdict): def _satisfy_condition(self, localdict):
""" """
@param contract_id: id of hr.contract to be tested @param contract_id: id of hr.contract to be tested

1
hr_payroll_community/wizard/hr_payroll_contribution_register_report.py

@ -15,7 +15,6 @@ class PayslipLinesContributionRegister(models.TransientModel):
date_to = fields.Date(string='Date To', required=True, date_to = fields.Date(string='Date To', required=True,
default=str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]) default=str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10])
@api.multi
def print_report(self): def print_report(self):
active_ids = self.env.context.get('active_ids', []) active_ids = self.env.context.get('active_ids', [])
datas = { datas = {

1
hr_payroll_community/wizard/hr_payroll_payslips_by_employees.py

@ -10,7 +10,6 @@ class HrPayslipEmployees(models.TransientModel):
employee_ids = fields.Many2many('hr.employee', 'hr_employee_group_rel', 'payslip_id', 'employee_id', 'Employees') employee_ids = fields.Many2many('hr.employee', 'hr_employee_group_rel', 'payslip_id', 'employee_id', 'Employees')
@api.multi
def compute_sheet(self): def compute_sheet(self):
payslips = self.env['hr.payslip'] payslips = self.env['hr.payslip']
[data] = self.read() [data] = self.read()

Loading…
Cancel
Save