Skip to content

Commit

Permalink
[IMP]pms: ensure partner payment and invoice in reconcile
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Mar 16, 2024
1 parent 7b5397a commit 2e2bd93
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions pms/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,7 @@ def _autoreconcile_folio_payments(self):
)
if to_reconcile:
(pay_term_lines + to_reconcile).reconcile()
# Set partner in payment
for record in to_reconcile:
if record.payment_id and not record.payment_id.partner_id:
record.payment_id.partner_id = move.partner_id
if (
record.statement_line_id
and not record.statement_line_id.partner_id
):
record.statement_line_id.partner_id = move.partner_id

return True

def _post(self, soft=True):
Expand All @@ -310,6 +302,41 @@ def _post(self, soft=True):
self._autoreconcile_folio_payments()
return res

def reconcile(self):
"""
Reconcile the account move
"""
res = super(AccountMove, self).reconcile()
# Update partner in payments and statement lines
for record in self:
if record.payment_id:
old_payment_partner = record.payment_id.partner_id
if old_payment_partner != record.partner_id:
record.payment_id.partner_id = record.partner_id
if old_payment_partner:
record.payment_id.message_post(
body=_(
f"""
Partner modify automatically from invoice {record.name}:
{old_payment_partner.name} to {record.partner_id.name}
"""
)
)
if record.statement_line_id:
old_statement_partner = record.statement_line_id.partner_id
if old_statement_partner != record.partner_id:
record.statement_line_id.partner_id = record.partner_id
if old_statement_partner:
record.statement_line_id.message_post(
body=_(
f"""
Partner modify automatically from invoice {record.name}:
{old_statement_partner.name} to {record.partner_id.name}
"""
)
)
return res

def match_pays_by_amount(self, payments, invoice):
"""
Match payments by amount
Expand Down

0 comments on commit 2e2bd93

Please sign in to comment.