Se rendre au contenu
Menu
Cette question a été signalée
1874 Vues
DiningRoomLimit class (models.Model):

_name = 'dining.room.limit'

_order = 'sequence'



name = fields.Char (readonly = True, create = "false", store = True)

limit = fields.Float (string = 'Credit Limit', mandatory = True, digits = (64, 2))

@ api.onchange ('limit')

def _onchange_limit (self):

h = j = 0.0

to r itself:

h = r.limit

j = r.limit - h

result = self.env ['hr.employee']. search ([])

result.write ({

'limit_id': j,

})

DiningRoomIndexCord class (models.Model):

_rec_name = 'record'

_inherit = ['hr.employee']



limit_id = fieldss.Float (string = 'Credit Limit', mandatory = True, digits = (64, 2))




I am trying to perform a subtraction between the limit and the limit_id that is in the class hr.employee and this result is the one that is saved in limit_id
Avatar
Ignorer

pls structure your code, and pls be specific what you want to do

Auteur

I use this form to update the limit_id value that is found in hr.employee automatically but I want to make a subtraction before between the amount that is in limit_id and the amount that is in the limit class called limit and that result is the one that is place when you pass the value to travz

of this code

@api.onchange('limit')

def _onchange_limit(self):

h = j = 0.0

for r in self:

h = r.limit

j = r.limit - h

result = self.env['hr.employee'].search([])

result.write({

'limit_id': j,

})