diff --git a/product/ERP5/Document/BPMInvoiceTransactionRule.py b/product/ERP5/Document/BPMInvoiceTransactionRule.py index 268aea0f32994bec15995c5a34e794dcc74286b5..9cf040b0a2121012a3ad0f5ae0c07f285cf3b5f4 100644 --- a/product/ERP5/Document/BPMInvoiceTransactionRule.py +++ b/product/ERP5/Document/BPMInvoiceTransactionRule.py @@ -52,6 +52,10 @@ class BPMInvoiceTransactionRule(BPMRule, PredicateMatrix): def _getCurrencyRatioByArrow(self, arrow, prevision_line): from Products.ERP5Type.Document import newTempSimulationMovement + try: + prevision_currency = prevision_line['resource_list'][0] + except IndexError: + prevision_currency = None temporary_movement = newTempSimulationMovement(self.getPortalObject(), '1', **prevision_line) exchange_ratio = None @@ -64,13 +68,13 @@ class BPMInvoiceTransactionRule(BPMRule, PredicateMatrix): 'price_currency', None) else: currency_url = None - if currency_url is not None and self.getResource() != currency_url: + if currency_url is not None and prevision_currency != currency_url: precision = section.getPriceCurrencyValue() \ .getQuantityPrecision() exchange_ratio = currency.getPrice( context=temporary_movement.asContext( categories=['price_currency/%s' % currency_url, - 'resource/%s' % self.getResource()], + 'resource/%s' % prevision_currency], start_date=temporary_movement.getStartDate())) return exchange_ratio