Create field `advancepay` either in `hr.employee` or in `hr.contract`, then you can access it in `hr.salary.rule` model, like `result = contract.advancepay`. Because object of `hr.advance.pay` model is not available in `hr.salary.rule`. These are the objects available:
# Available variables:
#----------------------
# payslip: object containing the payslips
# employee: hr.employee object
# contract: hr.contract object
# rules: object containing the rules code (previously computed)
# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).
# worked_days: object containing the computed worked days.
# inputs: object containing the computed inputs.
# Note: returned value have to be set in the variable 'result'