Skip to content

Commit

Permalink
[IMP] Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
serpentcs-dev1 committed Jul 12, 2017
1 parent 1983aa1 commit 3b38aea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hr_payroll_account_operating_unit/models/hr_payslip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HrPayslip(models.Model):
@api.multi
def write(self, vals):
res = super(HrPayslip, self).write(vals)
if 'move_id' in vals and vals['move_id']:
if 'move_id' in vals and vals.get('move_id', False):
for slip in self:
if slip.contract_id and slip.contract_id.operating_unit_id:
slip.move_id.write({'operating_unit_id':
Expand All @@ -36,7 +36,8 @@ def action_payslip_done(self):
# that belong to the same OU.
if OU:
if slip.contract_id.operating_unit_id.id != OU:
raise UserError(_('Configuration error!\nThe Contracts must\
refer the same Operating Unit.'))
raise UserError(_('Configuration error! '
'The Contracts must refer the same '
'Operating Unit.'))
OU = slip.contract_id.operating_unit_id.id
return super(HrPayslip, self).action_payslip_done()
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from odoo.addons.hr_contract_operating_unit.tests\
import test_hr_contract_operating_unit
from odoo.exceptions import UserError


class TestPayrollAccountOperatingUnit(test_hr_contract_operating_unit.
Expand Down Expand Up @@ -50,6 +51,10 @@ def _create_payslip(self, contract):
return payslip

def test_hr_payroll_account_ou(self):
with self.assertRaises(UserError):
payslip = self.payslip1 + self.payslip2
payslip.action_payslip_done()

"""Test Payroll Account Operating Unit"""
# Operating Unit (OU) of contract in Payslip should
# match with OU of Accounting Entries of that Payslip
Expand Down

0 comments on commit 3b38aea

Please sign in to comment.