|
|
transaction_data = self.env["payment.transaction"]._read_group(
domain=[
("provider_id", "in", self.ids),
("state", "=", "done"),
"|",
("child_transaction_ids", "=", False),
("source_transaction_id", "!=", False),
],
groupby=["provider_id", "currency_id"],
aggregates=["amount:sum"],
)
currency_total_by_provider = {provider: [] for provider in self}
for provider, currency, subtotal in transaction_data:
currency_total_by_provider[provider].append((currency, subtotal))
today = fields.Date.today()
for provider in self:
processed_amount = 0
for currency, currency_total in currency_total_by_provider[provider]:
target_currency = provider.main_currency_id
processed_amount += currency._convert(
currency_total, target_currency, company=provider.company_id, date=today
)
provider.processed_amount = processed_amount
|
|