I'm migrating a few modules from Odoo version 12 to version 14 , however I just found out some of the decorators were removed from version 13 so some functions I have with @api.one and @api decorator. multi no longer work in the same way since when trying to run them I get the following error:
What would be the alternative to these decorators?
I attach the functions that I have so far
#@api.one
@api.depends('marketplace_order_id')
#@api.onchange('marketplace_order_id')
def _compute_display_order_id(self):
if self.marketplace_order_id:
if len(str(self.marketplace_order_id)) > 20:
self.dsp_marketplace_order_id = str(self.marketplace_order_id)[0:20]+'...'
else:
self.dsp_marketplace_order_id = self.marketplace_order_id
else:
self.dsp_marketplace_order_id = 'Venta Piso'
#@api.one
@api.depends('etiqueta_meli')
#@api.onchange('marketplace_order_id')
def _display_etiqueta(self):
seller_name = str(self.seller_marketplace)
token = str(self.env['tokens_markets.tokens_markets'].search([('seller_name', '=', seller_name)]).access_token)
if self.etiqueta_meli:
self.dsp_etiqueta_meli = str(self.etiqueta_meli)+ token
else:
self.dsp_etiqueta_meli = 'Sin Etiqueta'
_sql_constraints = [
('marketplace_order_id_uniq', 'unique(marketplace_order_id)', "El Id de la Orden de Venta de Mercado Libre ya existe!"),
]
Since version 13 all decorators have been removed (@api.multi, @api.returns, @api.one, @api.cr, @api.model_cr). Right now they are all multi-record by default.
Right now what you have to do is loop through the class as usual:
If your function can only retrieve one record and is going to return a single action based on a single record, you have to put the following at the beginning of the function: