Commit ec1b8ba1 authored by Jérome Perrin's avatar Jérome Perrin

Also give higher priority to supply cells inside trade conditions during price calculation

parent 33252d75
master allow_login_change allow_login_change_wip arnau arnau-RD-Components-CacheTool arnau-RD-Components-ERP5Form-ERP5Report arnau-RD-Components-ERP5Form-SelectionTool-MemcachedTool arnau-RD-Components-ERP5OOo arnau-RD-Components-PreferenceTool-Preference arnau-RD-Components-Products-import-compat arnau-RD-Components-astroid_cache_per_component_reset arnau-RD-Components-erp5_crm arnau-RD-Components-erp5_trade-TODO-Interactor arnau-TM-Components-Migrate-PortalTransforms arnau-TM-Components-ModuleSecurityInfo arnau-TM-Components-PortalTransforms arnau-TM-FEC-output arnau-TM-WIP arnau-TM-isBuildable-with-multiple-BusinessLinks arnau-TM-jabber-client-desktop-notifications arnau-TM-newContent-temp_object arnau-TM-runUnitTest-clear-previous-execution-catalog arnau-TM-wkhtmltopdf arnau-WIP arnau-kns arnau-kns-without-property-mapping arnau-real-time-inventory-accounting auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog bt5_config callable-jupyter-storage catalog_filter catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos cherry-pick-4a8e045d clean_up_upgrader cleanup_acquisition_base_category cloud_reliability_test cmf_upgrade_versions credential_update_action cribjs-bootloader datetimefield delivery_item_barcode douglas_forum dream_distributor dsn-phase3 enhance_scalability_testing eos-dev erp5-component erp5-forum erp5-imt erp5-messenger erp5-preference erp5-release erp5-slapos-upgrade erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_catalog erp5_catalog_final erp5_corporate_identity erp5_free_subscription erp5_hal_json_style_fix_restricted_access_with_traverse erp5_payslip_migration erp5_workflow erp5testnode_max_timeout feat/coding_style_form_naming feat/dms_implicit_predecessor_successor_fields feat/erp5_ide feat/inventory_api_group_by_time_interval_list feat/olapy feat/python_language_support feat/stock-report-valuation feat/task_distribution_retry_flaky_tests feature/renderjs-ui-no-header fix/ZMI_editor_preference fix/advance_ecommerce_coding_crimes fix/business-template-update-tool fix/hide_diff_action fix/legacy_products_erp5type_document_migration fix/login_validate_check_consistency fix/migrated_person_become_user fix/support-request-app-empty fix/test_result_after_mep fix/testnode_node_title fix/workflow_method_security for_testrunner_1 for_testrunner_2 for_testrunner_3 gabriel gadget-json-value hotfix/rjs-formfields-padding improve_default_caching_policy_manager initsite isDeletable jerome-bt-reference-doc jerome_graph_editor_renderjs jerome_user_preference_time_zone jm/form-action-guard js-ui kns listbox_url macros_fix mame-test-stock-indexation mic_wind monitoring-graph mrp my2to3 no_longer_simulated_state officejs override_cache_control_header_by_caching_policy_manager portal_callables portal_solver_process_security_configuration publish_recursiveReindexObject rebased_mrp refactor/base_edit reindex_calendar_after_change_calendar_exception revert-38554dbe scalability-master scalability-roque scalability-roque-2 scalability-run-command shop-box shop-box-rebase streaming_fix streaming_fix-0 support_request syncml taskdistribution-xmlrpc-binary test_page testnode_software_link timezones tristan tristan-merge tristan-performance trustable-x-forwarded-for ttrm valentin_translation_fix view-aggregated-amounts vivekpab_renderjs_interfaces wenjie wenjie_branch wsgi wsgi-gevent wsgi_backport_setbody_lock wsgi_medusa_stream_fix 0.4.59.1 0.4.59 test-ui test-rjsacc test-rjs renderjs-test erp5.util-0.4.68 erp5.util-0.4.67 erp5.util-0.4.66 erp5.util-0.4.65 erp5.util-0.4.64 erp5.util-0.4.63 erp5.util-0.4.62 erp5.util-0.4.61 erp5.util-0.4.60 erp5.util-0.4.59.1 erp5.util-0.4.59 erp5.util-0.4.58 erp5.util-0.4.57 erp5.util-0.4.56 erp5.util-0.4.55 erp5.util-0.4.54 erp5.util-0.4.53 erp5.util-0.4.52 erp5.util-0.4.49 erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43 erp5.util-0.4.41 erp5.util-0.4.40 erp5.util-0.4.37
No related merge requests found
......@@ -148,10 +148,16 @@ if explanation is not None:\n
# if there are trade conditions containing supply lines related to that\n
# order/invoice, we give high priority to those supply lines\n
for trade_condition in getRelatedTradeConditionList(explanation):\n
high_priority_supply_line_list.extend(\n
list(trade_condition.contentValues(\n
for supply_line in trade_condition.contentValues(\n
portal_type=context.getPortalSupplyPathTypeList(),\n
checked_permission=\'View\')))\n
checked_permission=\'View\'):\n
supply_cell_list = supply_line.contentValues(\n
portal_type=context.getPortalSupplyPathTypeList(),\n
checked_permission=\'View\')\n
if supply_cell_list:\n
high_priority_supply_line_list.extend(list(supply_cell_list))\n
else:\n
high_priority_supply_line_list.append(supply_line)\n
\n
# XXX FIXME: Hardcoded values\n
if "Internal" in explanation_type:\n
......
41126
\ No newline at end of file
41127
\ No newline at end of file
......@@ -55,6 +55,12 @@ class TradeConditionTestCase(ERP5TypeTestCase, SubcontentReindexingWrapper):
self.resource = self.portal.product_module.newContent(
portal_type='Product',
title='Resource')
self.variated_resource = self.portal.product_module.newContent(
portal_type='Product',
title='Variated Resource',
variation_base_category_list=['size'],
variation_category_list=['size/small',
'size/big'])
self.currency = self.portal.currency_module.newContent(
portal_type='Currency',
title='Currency')
......@@ -302,6 +308,59 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
# using the supply line inside trade condition
self.assertEquals(2, line.getPrice())
def test_supply_cell_priority(self):
# supply lines from related trade condition should have priority over
# supply cells from supply modules
other_supply = self.portal.getDefaultModule(self.supply_type
).newContent(portal_type=self.supply_type,
resource_value=self.resource,
source_section_value=self.vendor,
destination_section_value=self.client)
other_supply.validate()
other_supply_line = other_supply.newContent(
portal_type=self.supply_line_type,
resource_value=self.variated_resource)
other_supply_line.setPVariationBaseCategoryList(['size'])
other_supply_line.updateCellRange(base_id='path')
self.tic()
other_small_cell = other_supply_line.newCell(base_id='path', *['size/small'])
other_small_cell.setMappedValuePropertyList(['base_price'])
other_small_cell.setVariationCategoryList(['size/small'])
other_small_cell.setMembershipCriterionBaseCategoryList(['size'])
other_small_cell.setMembershipCriterionCategoryList(['size/small'])
other_small_cell.setBasePrice(1)
supply_line = self.trade_condition.newContent(
portal_type=self.supply_line_type,
resource_value=self.variated_resource,)
supply_line.setPVariationBaseCategoryList(['size'])
supply_line.updateCellRange(base_id='path')
self.tic()
small_cell = supply_line.newCell(base_id='path', *['size/small'])
small_cell.setMappedValuePropertyList(['base_price'])
small_cell.setVariationCategoryList(['size/small'])
small_cell.setMembershipCriterionBaseCategoryList(['size'])
small_cell.setMembershipCriterionCategoryList(['size/small'])
small_cell.setBasePrice(2)
self.order.setSpecialiseValue(self.trade_condition)
self.order.setSourceSectionValue(self.vendor)
self.order.setDestinationSectionValue(self.client)
self.tic()
line = self.order.newContent(portal_type=self.order_line_type,
resource_value=self.variated_resource,)
self.assertEquals(None, line.getPrice())
line.setVariationBaseCategoryList(['size'])
line.setVariationCategoryList(['size/small'])
line.updateCellRange(base_id='movement')
self.tic()
cell = line.newCell(base_id='movement', *['size/small'])
cell.setQuantity(1)
self.assertEquals(2, cell.getPrice())
def test_supply_line_in_invalidated_trade_condition_does_not_apply(self):
# supply lines from supply modules
other_supply = self.portal.getDefaultModule(self.supply_type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment