Skip to Content
Menu
This question has been flagged
8 Replies
3939 Views

Hello Guys!!!!

I want to inherit hr.contract model.

So that, i want to put an onchange on the state field. 

Here is the code i have tried but not working.

class SoldeToutCompte(models.Model):

 _inherit = 'hr.contract'

 @api.onchange('state')

 def _onchange_state(self):

         _logger.info('---------------------------------')

need help please

Avatar
Discard
Author Best Answer

Hi evrybody!!

Its ok now i know what was the problem.

In fact as i say, its a Bug But odoo community does not see it as a bug because its their phylosophia.

Here is the explanation:

Hello,

Sorry but this is not a bug.
We want the statusbar to act as button and not as a field. A simple reason is the ability to click on it in readonly mode (should not be possible to click as we need a discard button). For objects such as task or tickets, we do not want to do "edit-change status-save", we want to do the action in one click (as you drop from one stage to the other in kanban view).
The patch is not wrong itself (even if it does not seem to take care of edit mode, it should) but I will reject it as we do not want to merge this in standard version.

Regards

Link:

https://bugs.launchpad.net/openerp-web/+bug/1175960

Best regards.

Avatar
Discard
Best Answer

Hi Drees Far,

Your code is correct.

I think that is the problem of indentation.

Try like this.

import logging

_logger = logging.getLogger(__name__)


class SoldeToutCompte(models.Model):
_inherit = 'hr.contract'

@api.onchange('state')
def _onchange_state(self):
_logger.info('---------------------------------')
print "###########"
Avatar
Discard
Author

i have put this :

import logging

_logger = logging.getLogger(__name__)

sorry i didnt mention this

Author

so????

is my code working?

just check all spacing is correct.

Author

its the same despite some lines

Ya, that is what I am saying in my answer, your code is right.

It may be the problem of indentation(spacing).

to understand the correct spacing method, I put my code here.

Or you may forget to mention the inherited module name in your Manifest file.

It is working fine for me