'Helper function to compute value for fields debit/credit/amount_currency based on an amount and the currencies given in parameter'

@api.model
def compute_amount_fields(self, amount, src_currency, company_currency, invoice_currency=False):

    amount_currency = False
    currency_id = False
    if (src_currency and (src_currency != company_currency)):
        amount_currency = amount
        amount = src_currency.with_context(self._context).compute(amount, company_currency)
        currency_id = src_currency.id
    debit = (((amount > 0) and amount) or 0.0)
    credit = (((amount < 0) and (- amount)) or 0.0)
    if (invoice_currency and (invoice_currency != company_currency) and (not amount_currency)):
        amount_currency = src_currency.with_context(self._context).compute(amount, invoice_currency)
        currency_id = invoice_currency.id
    return (debit, credit, amount_currency, currency_id)
