Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5353 Lượt xem

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)
Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
15163
2
thg 5 25
751
3
thg 4 25
5260
Compute Fields Đã xử lý
2
thg 7 24
2129
1
thg 1 24
1658