Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
5340 Visualizzazioni

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
Abbandona
Autore

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.

Post correlati Risposte Visualizzazioni Attività
1
giu 25
15115
2
mag 25
739
3
apr 25
5200
2
lug 24
2075
1
gen 24
1630