only logic with the below formula is , first check if last invoice date to selected customer is less than selected invoice date, if yes then check if last issued bill was paid by him on or before last invoice due date, if yes, then current_lps = 0 , if not then current_lps = amount_payable * 0.15.
Problem: the field is showing empty didn't do any calculations nor any error has been face.
class CurrentLPS(models.Model):
_inherit = 'account.move'
current_lps = fields.Float(string='Current LPS', store=True, help='Place to store the amount',readonly=True)
@api.depends('partner_id', 'invoice_date')
def _compute_current_lps(self):
for move in self:
last_invoice = move.env['account.move'].search([
('partner_id', '=', move . partner_id. id),
('move_type', '=', 'out_invoice'),
], order='invoice_date desc, id desc', limit=1)
if last_invoice and last_invoice.invoice_date < move.invoice_date:
# Find the last payment for the last invoice
last_payment = self.env['account.payment'].search([
('partner_id', '=', move,partner_id,id),
('communication', '=', last_invoice.invoice_payment_term_id),
('payment_date', '<=', last_invoice.invoice_date_due),
], order='payment_date desc', limit=1)
if last_payment and last_payment.state == 'posted':
move.current_lps = 0.0
else:
move.current_lps = move.amount_payable * 0.15
else:
move.current_lps = move.amount_payable * 0.15
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1711
Lượt xem
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 5 24
|
719 | ||
|
2
thg 3 24
|
1577 | ||
|
2
thg 6 23
|
7958 | ||
|
0
thg 5 23
|
90 | ||
what is a suspense account?
Đã xử lý
|
|
4
thg 5 22
|
25177 |