Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. @api.multi
  2.     def _get_aml_for_register_payment(self):
  3.         """ Get the aml to consider to reconcile in register payment """
  4.         self.ensure_one()
  5.         return self.move_id.line_ids.filtered(lambda r: not r.reconciled and r.account_id.internal_type in ('payable', 'receivable'))
  6.  
  7.     @api.multi
  8.     def register_payment(self, payment_line, writeoff_acc_id=False, writeoff_journal_id=False):
  9.         """ Reconcile payable/receivable lines from the invoice with payment_line """
  10.         line_to_reconcile = self.env['account.move.line']
  11.         for inv in self:
  12.             line_to_reconcile += inv._get_aml_for_register_payment()
  13.         return (line_to_reconcile + payment_line).reconcile(writeoff_acc_id, writeoff_journal_id)
  14.  
  15.     @api.multi
  16.     def assign_outstanding_credit(self, credit_aml_id):
  17.         self.ensure_one()
  18.         credit_aml = self.env['account.move.line'].browse(credit_aml_id)
  19.         if not credit_aml.currency_id and self.currency_id != self.company_id.currency_id:
  20.             credit_aml.with_context(allow_amount_currency=True, check_move_validity=False).write({
  21.                 'amount_currency': self.company_id.currency_id.with_context(date=credit_aml.date).compute(credit_aml.balance, self.currency_id),
  22.                 'currency_id': self.currency_id.id})
  23.         if credit_aml.payment_id:
  24.             credit_aml.payment_id.write({'invoice_ids': [(4, self.id, None)]})
  25.         return self.register_payment(credit_aml)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement