title: Getting an error as "Wrong python code defined for salary rule" odoo 11
body: <p>I am getting an error while calling a function from ODOO 11 Payslip, when calling a function that is defined in my code. The error says, "Wrong python code defined for salary rule Overtime Pay (OT)."</p>
  
  <p>The code I wrote is as below -</p>
  
  <pre><code>class SalaryRuleFunctions(models.Model):
  
      _inherit = 'hr.payslip'
  
      @api.multi
      def get_overtime_salary(self):
  
          emp_id = self.employee_id
          dt_from = self.date_from
          dt_to = self.date_to
          emp_rec = self.env['x_attendance_summary'].search([('employee_id', '=', emp_id), ('start_date', '=', dt_from), ('end_date', '=', dt_to)])[0]
  
          g_sal = (self.contract_id.x_ctc_gross / emp_rec.max_days)
          o_day = emp_rec.x_overtime_days_normal
  
          result = g_sal * o_day
          return result
  </code></pre>
  
  <p>The code inside the Salary Rule for Overtime Pay is as below -</p>
  
  <pre><code>result = payslip.env['hr.payslip'].get_overtime_salary()
  </code></pre>
  
  <p>I am not sure if the function is ever called. I tried putting in some messages also in my function to know if there is an error on function code. But, none of those messages show up, indicating that the function has never been called and the error is thrown from the salary rule itself.</p>
  
  <p>Is it that env variable is not available in Odoo 11? Or something else?</p>
  
  <p>Thanks in advance for all the help.</p>