I have this code, I am trying to divide the total price by 6 and display that under the total price. No matter what I do it's not working - it looks to me like Odoo is ignoring the code altogether or something
from odoo import fields, models
class Expenses(models.Model):
_name = 'expenses.model'
total_price = fields.Float(string='Total Price')
divided_amount = fields.Float(string='Divided Amount', compute='_compute_divided_amount', store=True)
@api.depends('total_price')
def _compute_divided_amount(self):
for expense in self:
expense.divided_amount = expense.total_price / 6
thank you for this, I added api as well but I am not sure about the _init_file, there are two: one under the models folder which is empty and one on the root folder with this:
yes, in the file under models directory you have to import your python file just like init file of root folder
from . import your_python_file_in_models