diff options
Diffstat (limited to 'fixco_custom/models/account_payment.py')
| -rw-r--r-- | fixco_custom/models/account_payment.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/fixco_custom/models/account_payment.py b/fixco_custom/models/account_payment.py index 2c7a5b4..41a2ce5 100644 --- a/fixco_custom/models/account_payment.py +++ b/fixco_custom/models/account_payment.py @@ -8,4 +8,31 @@ class AccountPayment(models.Model): @api.constrains('journal_id') def set_default_journal_id(self): for rec in self: - rec.journal_id = 21
\ No newline at end of file + rec.journal_id = 21 + + def auto_sync_payment(self): + for payment in self: + if not payment.ref: + continue + + # bill_names = payment.ref.split() + bill_names = [x.strip() for x in payment.ref.split() if x.strip()] + + move_line = self.env['account.move.line'].search([ + ('move_id', '=', payment.move_id.id), + ('account_id', '=', 388), + ]) + + for bill_name in bill_names: + bill = self.env['account.move'].search([ + ('name', '=', bill_name), + ('move_type', '=', 'in_invoice'), + ('state', '=', 'posted'), + ('payment_state', '=', 'not_paid'), + ], limit=1) + + if not bill: + continue + + if move_line: + bill.js_assign_outstanding_line(move_line.id) |
