Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

TypeError: on_change

By
lyes
on 7/25/16, 4:24 AM 199 views

Hi 

i have this error when i come to see view


File "C:\Program Files (x86)\Odoo 8\server\.\openerp\models.py", line 5863, in _onchange_eval
TypeError: on_change_secteur_id() takes exactly 2 arguments (5 given)
0
lyes
On 7/25/16, 5:48 AM

my code python 

import time

from openerp import models, fields, api

from datetime import datetime

class convention(models.Model):

_name="hr.convention"

_description="Convention"

name = fields.Char(string="Nom",size=128,required=True)

description = fields.Text("Description")

hr_secteur_ids = fields.One2many("hr.secteur.activite","hr_convention_id","Secteurs d'activtés")

convention()

class hr_secteur_activite(models.Model):

_name="hr.secteur.activite"

_description = "Secteur d'activite"

name = fields.Char("Name",size=128,required=True)

description = fields.Text("Description")

hr_convention_id = fields.Many2one("hr.convention",String="Convention",required=True)

hr_categorie_salariale_ids = fields.One2many("hr.categorie.salariale","hr_secteur_activite_id","Catégories salariales")

hr_secteur_activite()

class categorie_salariale(models.Model):

_name = "hr.categorie.salariale"

_description = "Categorie salariale"

name = fields.Char('Libellé', size=64, required=False, readonly=False)

salaire_base = fields.Float('Salaire de base')

description = fields.Text('Description')

hr_secteur_activite_id = fields.Many2one("hr.secteur.activite","Secteur d'activté")

def write(self, vals):

for salarie in self.browse(vals):

for contract in salarie.contract_ids:

#raise osv.except_osv(_('TEST'),contract)

cr.execute('UPDATE hr_contract set wage=%s WHERE id=%s',(salarie.salaire_base,contract.id))

cr.commit()

return super(categorie_salariale,self).write(vals)

categorie_salariale()


and XML 


<field name="hr_convention_id" on_change="on_change_convention_id(hr_convention_id)"/>

<field name="hr_secteur_id" on_change="on_change_secteur_id(hr_secteur_id)"/>

<field name="categorie_salariale_id" on_change="change_categorie(categorie_salariale_id)"/>

0

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 7/25/16, 5:11 AM

You seem that you defined the on_change_secteur_id as follows

def on_change_secteur_id(self, cr):
...

and in the xml file you seem that you passed other parameters not defined in the method signature, noting that the self, cr, uid parameters are counted implicitly.

You have to review the parameters your method and be sure that all parameters passed in the xml file are defined in the method definition

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/25/16, 4:24 AM
Seen: 199 times
Last updated: 7/25/16, 5:48 AM