diff --git a/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py b/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py index 66976b48db1c224342b32c85bd0a919cc1784455..8c457b1639710b2836c38c1f2bc684783c478c4a 100644 --- a/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py +++ b/bt5/erp5_real_time_inventory_accounting/DocumentTemplateItem/portal_components/document.erp5.InventoryAssetPriceAccountingSimulationRule.py @@ -43,33 +43,11 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM def _getInputMovementList(self, movement_list=None, rounding=False): simulation_movement = self._applied_rule.getParentValue() - # ERP5 generic implementation of getPrice(): - # 1. PL 'price' => - # 2. Movement_getPriceCalculationOperandDict() - # => Supply Line... + # No expand if price is not set (already checked in 'Test Method ID' on the Rule). + # Price is automatically acquired from Supply if not set directly on PL Movement. quantity = simulation_movement.getPrice() if quantity is None: - # XXX: "or fails to generate, and creates a "stock decrease" (expense)"??? - raise NotImplementedError - - # use = simulation_movement.getUse() - # if use == 'trade/sale': - # portal_type = 'Sale Supply Line' - # elif use == 'trade/purchase': - # portal_type = 'Purchase Supply Line' - # else: - # raise NotImplementatedError("%s: use='%s' not handled by this Rule" % - # (simulation_movement.getPath(), use)) - - # domain_tool = simulation_movement.getPortalObject().portal_domains - # sale_supply_line_list = domain_tool.searchPredicateList( - # simulation_movement, - # portal_type=portal_type) - - # if len(sale_supply_line_list) == 0: - # return () - - # quantity = sale_supply_line_list[0].getBasePrice() + return [] return [simulation_movement.asContext(quantity=quantity)] diff --git a/bt5/erp5_real_time_inventory_accounting/SkinTemplateItem/portal_skins/erp5_real_time_inventory_accounting/SimulationMovement_testInventoryAccountingTransactionSimulationRule.py b/bt5/erp5_real_time_inventory_accounting/SkinTemplateItem/portal_skins/erp5_real_time_inventory_accounting/SimulationMovement_testInventoryAccountingTransactionSimulationRule.py index b5a6f7cc04f98b16f311d05290403a20aa4fbb5e..87301930769f598ce5bbe9398459c89a3885be8c 100644 --- a/bt5/erp5_real_time_inventory_accounting/SkinTemplateItem/portal_skins/erp5_real_time_inventory_accounting/SimulationMovement_testInventoryAccountingTransactionSimulationRule.py +++ b/bt5/erp5_real_time_inventory_accounting/SkinTemplateItem/portal_skins/erp5_real_time_inventory_accounting/SimulationMovement_testInventoryAccountingTransactionSimulationRule.py @@ -2,6 +2,9 @@ parent = context.getParentValue() if parent.getPortalType() != 'Applied Rule': return False +if not context.hasPrice(): + return False + parent_rule = parent.getSpecialiseValue() if parent_rule.getPortalType() not in ('Delivery Root Simulation Rule', 'Delivery Simulation Rule'): diff --git a/bt5/erp5_real_time_inventory_accounting_test/TestTemplateItem/portal_components/test.erp5.testRealTimeInventoryAccounting.py b/bt5/erp5_real_time_inventory_accounting_test/TestTemplateItem/portal_components/test.erp5.testRealTimeInventoryAccounting.py index 79340a03aa0eecec2c8e8e9cc08a12a1a0623c63..26e9d8da3fc0ab7b96ad92dd71a767f734acd6ba 100644 --- a/bt5/erp5_real_time_inventory_accounting_test/TestTemplateItem/portal_components/test.erp5.testRealTimeInventoryAccounting.py +++ b/bt5/erp5_real_time_inventory_accounting_test/TestTemplateItem/portal_components/test.erp5.testRealTimeInventoryAccounting.py @@ -92,6 +92,14 @@ class TestRealTimeInventoryAccountingMixin: self.assertIterableLen(causality_related_list, causality_related_list_expected_len) return causality_related_list + def stepCheckAccountingTransactionNotGeneratedFromSalePackingList(self, sequence=None, sequence_list=None): + packing_list = sequence['current_sale_packing_list'] + self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 0) + + def stepCheckAccountingTransactionNotGeneratedFromPurchasePackingList(self, sequence=None, sequence_list=None): + packing_list = sequence['current_purchase_packing_list'] + self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 0) + def stepCheckAccountingTransactionGeneratedFromSalePackingList(self, sequence=None, sequence_list=None): packing_list = sequence['current_sale_packing_list'] accounting_transaction = self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 1)[0] @@ -309,6 +317,20 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc if product_big_b_car.getValidationState() != 'validated': product_big_b_car.validate() + try: + product_car_no_supply = self.portal.product_module.car_no_supply + except AttributeError: + product_car_no_supply = self.portal.product_module.newContent( + portal_type='Product', + id='car_no_supply', + title='Car No Supply', + reference='843326789', + product_line_value=category_tool.product_line.component, + use_value=category_tool.use.trade.purchase, + quantity_unit_value=category_tool.quantity_unit.unit.piece) + if product_car_no_supply.getValidationState() != 'validated': + product_car_no_supply.validate() + try: product_part_1 = self.portal.product_module.part_1 except AttributeError: @@ -449,6 +471,49 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc sequence_list.addSequenceString(sequence_str) sequence_list.play(self, quiet=0) + def stepTestSalePackingListNoPriceAndNoSupply_create(self, sequence=None, sequence_list=None): + sale_packing_list = self.portal.sale_packing_list_module.newContent( + portal_type='Sale Packing List', + specialise_value=self.portal.sale_trade_condition_module.hoge, + title='Vente depuis le Prac (No Price/Supply)', + start_date=DateTime('2018/01/30 00:00:00 GMT+9'), + stop_date=DateTime('2018/01/31 00:00:00 GMT+9'), + source_value=self.portal.organisation_module.hoge, + source_section_value=self.portal.organisation_module.hoge, + destination_value=self.portal.organisation_module.client, + destination_section_value=self.portal.organisation_module.client, + price_currency_value=self.portal.currency_module.DOL) + + sale_packing_list.newContent( + portal_type='Sale Packing List Line', + title='Vente voiture', + int_index=1, + resource_value=self.portal.product_module.car_no_supply, + quantity=1, + quantity_unit_value=self.portal.portal_categories.quantity_unit.unit.piece, + use_value=self.portal.portal_categories.use.trade.sale) + + sequence.edit(sale_packing_list_1=sale_packing_list) + + def testSalePackingListNoPriceAndNoSupply(self): + sequence_list = SequenceList() + sequence_str = """ + TestSalePackingListNoPriceAndNoSupply_create + Tic + SelectSalePackingList1 + ConfirmSalePackingList + Tic + StartSalePackingList + Tic + StopSalePackingList + Tic + CallBuilder + Tic + CheckAccountingTransactionNotGeneratedFromSalePackingList + """ + sequence_list.addSequenceString(sequence_str) + sequence_list.play(self, quiet=0) + def stepTestPurchasePackingList_create(self, sequence=None, sequence_list=None): purchase_packing_list = self.portal.purchase_packing_list_module.newContent( portal_type='Purchase Packing List', @@ -524,6 +589,48 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc sequence_list.addSequenceString(sequence_str) sequence_list.play(self, quiet=0) + def stepTestPurchasePackingListNoPriceAndNoSupply_create(self, sequence=None, sequence_list=None): + purchase_packing_list = self.portal.purchase_packing_list_module.newContent( + portal_type='Purchase Packing List', + specialise_value=self.portal.purchase_trade_condition_module.hoge, + title='Reception Supplier (No Supply/Price)', + start_date=DateTime('2018/01/09 00:00:00 GMT+9'), + stop_date=DateTime('2018/01/10 00:00:00 GMT+9'), + source_value=self.portal.organisation_module.hoge, + source_section_value=self.portal.organisation_module.supplier, + destination_value=self.portal.organisation_module.supplier, + destination_section_value=self.portal.organisation_module.hoge, + price_currency_value=self.portal.currency_module.DOL) + + purchase_packing_list.newContent( + portal_type='Purchase Packing List Line', + int_index=1, + resource_value=self.portal.product_module.car_no_supply, + quantity=1, + quantity_unit_value=self.portal.portal_categories.quantity_unit.unit.piece, + use_value=self.portal.portal_categories.use.trade.purchase) + + sequence.edit(purchase_packing_list_1=purchase_packing_list) + + def testPurchasePackingListNoPriceAndNoSupply(self): + sequence_list = SequenceList() + sequence_str = """ + TestPurchasePackingListNoPriceAndNoSupply_create + Tic + SelectPurchasePackingList1 + ConfirmPurchasePackingList + Tic + StartPurchasePackingList + Tic + StopPurchasePackingList + Tic + CallBuilder + Tic + CheckAccountingTransactionNotGeneratedFromPurchasePackingList + """ + sequence_list.addSequenceString(sequence_str) + sequence_list.play(self, quiet=0) + import unittest def test_suite(): suite = unittest.TestSuite()