I want to put the employee name to the 'account.analytic.line' model.
For that I need to go to 'hr.payslip' and get the "number" field value. With this value I need to compare this value to the 'account.analytic.line' "ref" field value. So that I know to wich record what employee is set.
step:
compare hr.payslip(number) with account.analytic.line(number)
Then get the employee name and put that in the account.analytic.line(testing) - new field.
This is my code:
from openerp import models, fields, api, osv
from openerp.http import requestfrom openerp import SUPERUSER_ID
class account_analytic_line(models.Model):
_inherit = ['account.analytic.line']
testing = fields.Integer(compute="employee")
@api.one
def employee(self):
cr, uid, context, pool = request.cr, request.uid, request.context, request.cr
model_obj = self.pool.get('hr.payslip')
test = self.env['account.analytic.line']
#record = model_obj.browse(cr, uid, your id, context = context)
rec_ids = model_obj.search(cr, uid, [(test.ref, '=', 'number')], context=context)
for record in model_obj.browse(cr, uid, rec_ids, context=context):
record.ref
print record.ref
The final result should be, that the employee should be on the account.analytic.line.