2👍
It should be enough to use b_id
on your compute method, because it’s related:
@api.multi
@api.depends('b_id')
def compute_all(self):
for record in self:
record.all_taxes = record.b_id.tax_value + record.tax_old
The compute method can be called with a multi record recordset. So use a for loop inside it. And you don’t have to do an update()
at the end.
1👍
You can try it
@api.one
@api.depends('b_id', 'b_id.tax_value')
def compute_all(self):
self.all_taxes = self.tax_value + self.tax_old
Two things:
It ist compute
not _compute
and you don’t need to use self.update()
.
- [Django]-Django and Nginx try_files 403 for site root page
- [Django]-UWSGI processes lose Django sessions
- [Django]-Celery with redis backend
- [Django]-404 (Not Found) for CSS files
0👍
Try this instead:
# You'll need this
from django.db.models import F
@api.depends('tax_value')
def compute_all(self):
self.update(all_taxes=F('tax_value') + F('tax_old'))
You’re missing the self
. What you’ve done is defined a local variable called all_taxes
, not the instance variable.. which is what you’re after
Source:stackexchange.com