I have a Module1 in V7, this is part of the code, when call a function of Module2 in V8:
#--Code in Module1
class calc_hours_employees(models.Model): _name = 'calc.hours.employees' _description = 'Somes computes' employees_ids = fields.Many2many('hr.employee', 'hr_employee_calcs_rel', 'calcs_id', 'employee_id', 'Funcionarios')
def compute_sheet(self, cr, uid, ids, context=None): emp_pool = self.pool.get('hr.employee') ext_pool = self.pool.get('hr.py.calc.hours') run_pool = self.pool.get('hr.py.calc.hours.run') ext_ids = [] if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] run_data = {} if context and context.get('active_id', False): run_data = run_pool.read(cr, uid, [context['active_id']], ['date_start', 'date_end'])[0] from_date = run_data.get('date_start', False) to_date = run_data.get('date_end', False)
if not data['employees_ids']: raise osv.except_osv(_("Warning!"), _("Select one, please"))
for emp in emp_pool.browse(cr, uid, data['employees_ids'], context=context)
ext_data = ext_pool.do_employee(cr, uid, [], 2, emp.id, from_date, to_date, emp.department_id, emp.id_inter, contract_id=False, context=context
res = {
'employee': emp.id,
'office': emp.department_id.name,
'matricu': emp.id_inter,
'date_from': from_date,
'date_to': to_date,
'calcs_run_ids': context.get('active_id', False),
} ext_ids.append(ext_pool.create(cr, uid, res, context=context)
return {'type': 'ir.actions.act_window_close'}
And this is a part of code that have the function do_employee():
#--Part of code in Module2
class hr_py_calc_hours(models.Model): _name = 'hr.py.calc.hours'
employee = fields.Many2one('hr.employee', string='Employee', required=True)
hor_repo = fields.Float('Hor Repo', digits=(16,2), default=0.0)
#####have more fields but not is necesary for the example :)
....
@api.multi
@api.onchange('employee')
def do_employee(self, type_calc=1, emp_id=False, from_date=False, to_date=False, emp_off=False, emp_matr=False, contract_id=False, context=None): def _do_create(date1,turnid,ent,sal,work,rep,abse,ear,bef,att,ad30,ex50,ex100,hours_to_create): hours_to_create += [((0,0,{'date_work':date1,'turno_id':turnid,'entrad':ent,'salida':sal,'times_worked':work,'repose':rep,'absence':abse,'early':ear, 'before':bef,'attestation':att,'adic_30':ad30,'ext_50':ex50,'ext_100':ex100}))]
....
if not type_calc==1: repo = self.get('hor_repo',0) ############ HERE ARE THE PROBLEM self.write({'hor_repo': repo + ocho}) else: self.hor_repo += ocho datew += timedelta(days=1)
.....
The function of Module2 need can execute from the onchange employee, and need can execute from the Module1.
I need the value of hor_repo for increase this at one to somes computes, them i need take the value at the moment in the field an increase this.
I see in many parts from google but all is only for V7 or only for V8. How can solve this problem ?
Posd.: This module is similar to performance of the payslip, need can do only for a employee(as module hr.payslip) or for more that one in the same time(as module hr.payslip.run).
Edit: Nothing ?