[TMP] beginning of state of last invoice
This commit is contained in:
parent
30d218c64e
commit
c844cf732f
@ -40,12 +40,16 @@ class GolemMember(models.Model):
|
|||||||
'default_partner_id': self.partner_id.id}}
|
'default_partner_id': self.partner_id.id}}
|
||||||
|
|
||||||
|
|
||||||
# state_invoice = fields.One2many(related='member_id.invoice_ids')
|
# payment_ids = fields.One2many("account.payment","payment_ids")
|
||||||
state_last_invoice = fields.Char(compute='_compute_state_of_last_invoice')
|
state_last_invoice = fields.Integer(compute='_compute_state_of_last_invoice')
|
||||||
|
account_payment_ids = fields.One2many('account.payment', 'partner_id')
|
||||||
|
|
||||||
@api.depends('invoice_ids')
|
@api.depends('invoice_ids')
|
||||||
def _compute_state_of_last_invoice(self):
|
def _compute_state_of_last_invoice(self):
|
||||||
for member in self:
|
for member in self:
|
||||||
state = member.invoice_ids.filtered(lambda inv: inv.state in ('open', 'paid'))
|
state_invoice = member.invoice_ids.filtered(lambda inv: inv.state in ('open', 'paid'))
|
||||||
sorted_date = state.sorted(key=lambda r: r.date_invoice)
|
date_state_invoice = state_invoice.sorted(key=lambda r: r.date_invoice, reverse=True)
|
||||||
member.state_last_invoice = sorted_date[-1]
|
state_payment = member.account_payment_ids.filtered(lambda inv: inv.state in ('open', 'paid'))
|
||||||
|
date_state_payment = state_payment.sorted(key=lambda r: r.write_date, reverse=True)
|
||||||
|
|
||||||
|
member.state_last_invoice = date_state_invoice[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user