From 2c40abcd80d4da40734686a624a430a37cab1a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 18 Jan 2008 13:57:43 +0000 Subject: [PATCH] The simulation movement corresponding to the invoice transaction line should have the order price currency as resource. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18793 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../ERP5/Document/InvoiceTransactionRule.py | 2 +- product/ERP5/tests/testInvoice.py | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/product/ERP5/Document/InvoiceTransactionRule.py b/product/ERP5/Document/InvoiceTransactionRule.py index 44f859c53c..a6d4dbc51d 100644 --- a/product/ERP5/Document/InvoiceTransactionRule.py +++ b/product/ERP5/Document/InvoiceTransactionRule.py @@ -101,7 +101,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): delivery = simulation_movement.getDeliveryValue() if delivery is not None: resource = delivery.getProperty('price_currency', None) - if (resource is not None) and \ + if (resource is None) and \ (simulation_movement.getParentValue().getParentValue() \ == portal_simulation) : # we are on the first simulation movement, we'll try diff --git a/product/ERP5/tests/testInvoice.py b/product/ERP5/tests/testInvoice.py index f86762c115..e222a6e9e0 100644 --- a/product/ERP5/tests/testInvoice.py +++ b/product/ERP5/tests/testInvoice.py @@ -1914,6 +1914,44 @@ class TestInvoice(TestPackingListMixin, """) sequence_list.play(self, quiet=quiet) + def test_invoice_transaction_line_resource(self): + # tests that simulation movements corresponding to accounting line have a + # good resource in the simulation + + sequence_list = SequenceList() + sequence = sequence_list.addSequenceString(''' + stepCreateEntities + stepCreateCurrency + stepCreateSaleInvoiceTransactionRule + stepCreateOrder + stepSetOrderProfile + stepSetOrderPriceCurrency + stepCreateNotVariatedResource + stepTic + stepCreateOrderLine + stepSetOrderLineResource + stepSetOrderLineDefaultValues + stepOrderOrder + stepTic + ''') + sequence_list.play(self, quiet=1) + order = sequence.get('order') + order_price_currency = order.getPriceCurrency() + self.assertNotEquals(None, order_price_currency) + related_applied_rule = order.getCausalityRelatedValue( + portal_type='Applied Rule') + delivery_movement = related_applied_rule.contentValues()[0] + invoice_applied_rule = delivery_movement.contentValues()[0] + invoice_movement = invoice_applied_rule.contentValues()[0] + invoice_transaction_applied_rule = invoice_movement.contentValues()[0] + invoice_transaction_movement =\ + invoice_transaction_applied_rule.contentValues()[0] + self.assertEquals(order_price_currency, + invoice_transaction_movement.getResource()) + # TODO: price currency have to be copied on simulation movements too + # self.assertEquals(order_price_currency, + # invoice_transaction_movement.getPriceCurrency()) + #class TestPurchaseInvoice(TestInvoice): # order_portal_type = 'Purchase Order' # order_line_portal_type = 'Purchase Order Line' -- 2.30.9