Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5351 Представления

I have a computed field named 'balance' which has store=True, computed from credit-debit formula, and I can update this from customer's payment or invoice moves with using @api.depends. The question is this -> When balance is $100.00, I try receiving payment, let's say $30.00. Credit-debit now equals $70.00, but balance isn't changed. When to receive $20.00 more, the formula equals $50.00, but balance is changed to $70.00, which is the previous value of the formula.

So, how to sync triggered actions and computed fields? Thanks in advance...

payment_ids = fields.One2many('account.payment', 'partner_id', string="Payments", readonly=True, copy=False)

@api.one
@api.depends('invoice_ids','payment_ids')
def _balancecalc(self):
    for record in self:
        record.balance = record.credit - record.debit

balance = fields.Float(string="Balance", compute="_balancecalc", store=True)
Аватар
Отменить
Автор

Ok, I found a field, move_name in account.payments. As far as I see, move_name field used after payment registeration. My model inherited from res.partner. How can I check from my class that whether if move_name field is updated? Thanks in advance.

Related Posts Ответы Просмотры Активность
1
июн. 25
15160
2
мая 25
751
3
апр. 25
5247
Compute Fields Решено
2
июл. 24
2116
1
янв. 24
1651