Search code examples
odooodoo-8

Fetching the complete 'date' field was not coming form 'hr.employee' model


I am trying to get the data from 'date' field that 'date' field is in 'hr.employee' to 'hr.payslip'.I create a function for that task.

Code:

class employee_datecheck(models.Model):
    _inherit = 'hr.payslip'

    @api.onchange('employee_id')
    @api.constrains('employee_id')
    def date_check(self):
        if self.employee_id:
            self.t2 = self.date_from
            self.tax 
            product_obj = self.env['hr.employee'].search([('name' , '=' ,self.employee_id.name)])
            if product_obj:
                for products in product_obj:
                    product_new_obj = self.env['hr.employee'].browse([products.id])

                    for tax in product_new_obj.joindate:
                        raise Warning(self.tax) 

problem is:

The date was not fetching properly i.e it just showing the '2' instead of '2017-09-21'.Please help me.


Solution

  • I think you could try to print directly the joindate without doing a loop:

    for products in product_obj:
        product_new_obj = self.env['hr.employee'].browse([products.id])
        self.tax = product_new_obj.joindate:
        raise Warning(self.tax) 
    

    I hope this help you.