I'm trying to calculate discount field on sale order line, and the method was working well in odoo 12 but in odoo 13 i get this error every time I try to add line
sale.order.line(<NewId 0x7f3dd0d624a8>,).discount_mount
here is the what I've done
class discount_cycle(models.Model):
_inherit = 'sale.order.line'
discount_mount = fields.Float(string="", required=False , compute='discount_calculation')
@api.depends('product_id','discount','price_subtotal')
def discount_calculation(self):
for rec in self:
if rec.discount:
if rec.product_uom_qty > 1:
rec.discount_mount = ((rec.price_unit * rec.product_uom_qty) * (rec.discount / 100))
else:
rec.discount_mount = (rec.price_unit * (rec.discount / 100))
pass
Note that was @api.one in odoo V 12, so how can I solve this issue and what is replacement for @api.one in this case