Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @api.multi
- def _get_aml_for_register_payment(self):
- """ Get the aml to consider to reconcile in register payment """
- self.ensure_one()
- return self.move_id.line_ids.filtered(lambda r: not r.reconciled and r.account_id.internal_type in ('payable', 'receivable'))
- @api.multi
- def register_payment(self, payment_line, writeoff_acc_id=False, writeoff_journal_id=False):
- """ Reconcile payable/receivable lines from the invoice with payment_line """
- line_to_reconcile = self.env['account.move.line']
- for inv in self:
- line_to_reconcile += inv._get_aml_for_register_payment()
- return (line_to_reconcile + payment_line).reconcile(writeoff_acc_id, writeoff_journal_id)
- @api.multi
- def assign_outstanding_credit(self, credit_aml_id):
- self.ensure_one()
- credit_aml = self.env['account.move.line'].browse(credit_aml_id)
- if not credit_aml.currency_id and self.currency_id != self.company_id.currency_id:
- credit_aml.with_context(allow_amount_currency=True, check_move_validity=False).write({
- 'amount_currency': self.company_id.currency_id.with_context(date=credit_aml.date).compute(credit_aml.balance, self.currency_id),
- 'currency_id': self.currency_id.id})
- if credit_aml.payment_id:
- credit_aml.payment_id.write({'invoice_ids': [(4, self.id, None)]})
- return self.register_payment(credit_aml)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement