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

pdm_ui_test: create both a product and a component

and make it possible to create the test delivery using a component as
resource
parent 351776a8
......@@ -12,7 +12,6 @@ delivery_title = "erp5_pdm_ui_test_delivery_title"
source_node_id = "erp5_pdm_ui_test_source_node"
destination_node_id = "erp5_pdm_ui_test_destination_node"
resource_id = "erp5_pdm_ui_test_product"
business_process_id = 'erp5_default_business_process'
business_process_module = portal.getDefaultModule("Business Process")
......@@ -40,7 +39,7 @@ if state in ['planned', 'ordered']:
)
order.newContent(
portal_type=order_line_portal_type,
resource='product_module/%s' % resource_id,
resource=resource_relative_url,
quantity=1,
)
order.portal_workflow.doActionFor(order, 'plan_action')
......@@ -63,7 +62,7 @@ else:
)
delivery.newContent(
portal_type=delivery_line_portal_type,
resource='product_module/%s' % resource_id,
resource=resource_relative_url,
quantity=1,
)
for next_state, transition in [
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state, delivery_type="Sale"</string> </value>
<value> <string>state, delivery_type="Sale", resource_relative_url="product_module/erp5_pdm_ui_test_product"</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
portal = context.getPortalObject()
resource_portal_type = "Product"
node_portal_type = "Organisation"
resource_id = "erp5_pdm_ui_test_product"
source_node_id = "erp5_pdm_ui_test_source_node"
destination_node_id = "erp5_pdm_ui_test_destination_node"
......@@ -12,10 +9,11 @@ destination_site_id = "erp5_pdm_ui_test_destination_site"
delivery_id = "erp5_pdm_ui_test_delivery"
# Delete resource
module = portal.getDefaultModule(resource_portal_type)
if getattr(module, resource_id, None) is not None:
module.manage_delObjects([resource_id])
# Delete resources
if getattr(portal.product_module, 'erp5_pdm_ui_test_product', None) is not None:
portal.product_module.manage_delObjects(['erp5_pdm_ui_test_product'])
if getattr(portal.component_module, 'erp5_pdm_ui_test_component', None) is not None:
portal.component_module.manage_delObjects(['erp5_pdm_ui_test_component'])
# Delete nodes
module = portal.getDefaultModule(node_portal_type)
......
portal = context.getPortalObject()
resource_portal_type = "Product"
node_portal_type = "Organisation"
site_portal_type = "Category"
resource_id = "erp5_pdm_ui_test_product"
resource_title = "erp5_pdm_ui_test_product_title"
source_node_id = "erp5_pdm_ui_test_source_node"
source_node_title = "erp5_pdm_ui_test_source_node_title"
destination_node_id = "erp5_pdm_ui_test_destination_node"
......@@ -21,21 +18,25 @@ for rule in portal.portal_rules.objectValues():
if rule.getValidationState() != 'validated':
rule.validate()
# Create resource
# Create resources
if getattr(quantity_unit_category, "unit", None) is None:
quantity_unit_category.newContent(
portal_type="Category",
id="unit"
)
module = portal.getDefaultModule(resource_portal_type)
resource = module.newContent(
portal_type=resource_portal_type,
id=resource_id,
title=resource_title,
portal.product_module.newContent(
portal_type='Product',
id='erp5_pdm_ui_test_product',
title='erp5_pdm_ui_test_product_title',
quantity_unit='unit',
).validate()
portal.component_module.newContent(
portal_type='Component',
id='erp5_pdm_ui_test_component',
title='erp5_pdm_ui_test_component_title',
quantity_unit='unit',
)
resource.validate()
).validate()
# Create site categories
base_category = portal.restrictedTraverse('portal_categories/site')
......
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