Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
5358 Näkymät

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)
Avatar
Hylkää
Tekijä

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.

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
kesäk. 25
15184
2
toukok. 25
754
3
huhtik. 25
5286
2
heinäk. 24
2165
1
tammik. 24
1675