mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: ensure partner payment and invoice in reconcile
This commit is contained in:
@@ -289,15 +289,7 @@ class AccountMove(models.Model):
|
|||||||
)
|
)
|
||||||
if to_reconcile:
|
if to_reconcile:
|
||||||
(pay_term_lines + to_reconcile).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
|
return True
|
||||||
|
|
||||||
def _post(self, soft=True):
|
def _post(self, soft=True):
|
||||||
@@ -310,6 +302,41 @@ class AccountMove(models.Model):
|
|||||||
self._autoreconcile_folio_payments()
|
self._autoreconcile_folio_payments()
|
||||||
return res
|
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):
|
def match_pays_by_amount(self, payments, invoice):
|
||||||
"""
|
"""
|
||||||
Match payments by amount
|
Match payments by amount
|
||||||
|
|||||||
Reference in New Issue
Block a user