Я хочу, чтобы сумма общего поля ru.invoice
отображалась на ru.students
, если поле имени ru.students
равно student_id
из ru.invoice
.
Я использовал метод browse
, но он не работает.
class ru_students(models.Model):
_name = 'ru.students'
_rec_name = 'code'
def _get_total(self, cr, uid, ids, context=None):
pool_re = self.pool.get('ru.invoice')
pool_rec = pool_re.browse(cr, uid, ids, [('name','=','student_id')],
context=context)
for field in self:
for line in pool_rec:
x = 0.0
x += line.total
field.payed += x
name = fields.Char(string="Name")
payed = fields.Float(compute="_get_total")
class ru_invoice(models.Model):
_name = 'ru.invoice'
_rec_name = 'code'
@api.multi
@api.depends('qty','unit_price')
def get_total(self):
for rec in self:
x = 0.0
x = rec.qty * rec.unit_price
rec.total = x
student_id = fields.Many2one('ru.students','Student ID")
qty = fields.Float(string="Quantity")
unit_price = fields.Float(string="Unit Price")
total = fields.Float(compute="_get_totals",string="Total")