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

configurator: Introduce scripts to get region and function items

Some configurator profiles uses a spreadsheet to define categories
(consulting configurator), some use a business templates.

For the ones using business template, because the categories are not available
yet we have the values directly in the script.
parent f998ec38
......@@ -151,7 +151,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.BusinessConfiguration_getCategoriesSpreadsheetConfiguratorItem().getCategoryTitleItemList(\'region\')</string> </value>
<value> <string>context/BusinessConfiguration_getRegionTitleItemList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -127,7 +127,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.BusinessConfiguration_getCategoriesSpreadsheetConfiguratorItem().getCategoryTitleItemList(\'function\')</string> </value>
<value> <string>context/BusinessConfiguration_getFunctionTitleItemList</string> </value>
</item>
</dictionary>
</pickle>
......
from Products.ERP5Type.Message import translateString
if context.getGlobalConfigurationAttr('categories_spreadsheet_configuration_save_relative_url'):
item_list_from_spreadsheet = context.BusinessConfiguration_getCategoriesSpreadsheetConfiguratorItem().getCategoryTitleItemList('function')
if item_list_from_spreadsheet != [('', '')]:
return item_list_from_spreadsheet
function_item_list = [
('Accounting & Finance', None),
('Accounting', 'af/accounting'),
('Accounting Agent', 'af/accounting/agent'),
('Accounting Manager', 'af/accounting/manager'),
('Accounting & Finance Manager', 'af/manager'),
('Company', None),
('Company Agent', 'company/agent'),
('Company Executive', 'company/executive'),
('Company Manager', 'company/manager'),
('Headquarters', None),
('Headquarters Agent', 'hq/agent'),
('Headquarters Executive', 'hq/executive'),
('Headquarters Manager', 'hq/manager'),
('Human Resources', None),
('Human Resources Agent', 'hr/agent'),
('Human Resources Manager', 'hr/manager'),
('Information Systems', None),
('Information Systems Manager', 'is/manager'),
('Software Developer', 'is/developer'),
('System Administrator', 'is/admin'),
('Marketing', None),
('Marketing Agent', 'marketing/agent'),
('Marketing Manager', 'marketing/manager'),
('Production \xe2\x80\x93 Manufacturing', None),
('Production Agent', 'production/agent'),
('Production Manager', 'production/manager'),
('Project Management & Implementation', None),
('Developer for a Project', 'project/developer'),
('Project Manager', 'project/manager'),
('Purchase', None),
('Purchase Agent', 'purchase/agent'),
('Purchase Manager', 'purchase/manager'),
('Research and Development', None),
('Research and Development Agent', 'rd/agent'),
('Research and Development Manager', 'rd/manager'),
('Sales', None),
('Sales Agent', 'sales/agent'),
('Sales Manager', 'sales/manager'),
('Subsidiary', None),
('Subsidiary Agent', 'subsidiary/agent'),
('Subsidiary Manager', 'subsidiary/manager'),
('Warehouse', None),
('Warehouse Agent', 'warehouse/agent'),
('Warehouse Manager', 'warehouse/manager'),
]
return [('', '')] + [(translateString(title), relative_url) for (title, relative_url) in function_item_list]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BusinessConfiguration_getFunctionTitleItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Message import translateString
if context.getGlobalConfigurationAttr('categories_spreadsheet_configuration_save_relative_url'):
item_list_from_spreadsheet = context.BusinessConfiguration_getCategoriesSpreadsheetConfiguratorItem().getCategoryTitleItemList('region')
if item_list_from_spreadsheet != [('', '')]:
return item_list_from_spreadsheet
region_item_list = [
('Afghanistan', 'asia/southern_asia/afghanistan'),
('Albania', 'europe/southern_europe/albania'),
('Algeria', 'africa/northern_africa/algeria'),
('American Samoa', 'oceania/polynesia/american_samoa'),
('Andorra', 'europe/southern_europe/andorra'),
('Angola', 'africa/middle_africa/angola'),
('Anguilla', 'americas/caribbean/anguilla'),
('Antigua and Barbuda', 'americas/caribbean/antigua_and_barbuda'),
('Argentina', 'americas/south_america/argentina'),
('Armenia', 'asia/western_asia/armenia'),
('Aruba', 'americas/caribbean/aruba'),
('Australia', 'oceania/australia/australia'),
('Austria', 'europe/western_europe/austria'),
('Azerbaijan', 'asia/western_asia/azerbaijan'),
('Bahamas', 'americas/caribbean/bahamas'),
('Bahrain', 'asia/western_asia/bahrain'),
('Bangladesh', 'asia/southern_asia/bangladesh'),
('Barbados', 'americas/caribbean/barbados'),
('Belarus', 'europe/eastern_europe/belarus'),
('Belgium', 'europe/western_europe/belgium'),
('Belize', 'americas/central_america/belize'),
('Benin', 'africa/western_africa/benin'),
('Bermuda', 'americas/northern_america/bermuda'),
('Bhutan', 'asia/southern_asia/bhutan'),
('Bolivia', 'americas/south_america/bolivia'),
('Bosnia and Herzegovina', 'europe/southern_europe/bosnia_and_herzegovina'),
('Botswana', 'africa/southern_africa/botswana'),
('Brazil', 'americas/south_america/brazil'),
('British Virgin Islands', 'americas/caribbean/british_virgin_islands'),
('Brunei Darussalam', 'asia/south-eastern_asia/brunei_darussalam'),
('Bulgaria', 'europe/eastern_europe/bulgaria'),
('Burkina Faso', 'africa/western_africa/burkina_faso'),
('Burundi', 'africa/eastern_africa/burundi'),
('Cambodia', 'asia/south-eastern_asia/cambodia'),
('Cameroon', 'africa/middle_africa/cameroon'),
('Canada', 'americas/northern_america/canada'),
('Cape Verde', 'africa/western_africa/cape_verde'),
('Cayman Islands', 'americas/caribbean/cayman_islands'),
('Central African Republic', 'africa/middle_africa/central_african_republic'),
('Chad', 'africa/middle_africa/chad'),
('Channel Islands', 'europe/northern_europe/channel_islands'),
('Chile', 'americas/south_america/chile'),
('China', 'asia/eastern_asia/china'),
('Colombia', 'americas/south_america/colombia'),
('Comoros', 'africa/eastern_africa/comoros'),
('Congo', 'africa/middle_africa/congo'),
('Cook Islands', 'oceania/polynesia/cook_islands'),
('Costa Rica', 'americas/central_america/costa_rica'),
("Cote d'Ivoire", 'africa/western_africa/cote_diivoire'),
('Croatia', 'europe/southern_europe/croatia'),
('Cuba', 'americas/caribbean/cuba'),
('Cyprus', 'asia/western_asia/cyprus'),
('Czech Republic', 'europe/eastern_europe/czech_republic'),
("Democratic People's Republic of Korea", 'asia/eastern_asia/democratic_peoples_republic_of_korea'),
('Democratic Republic of the Congo', 'africa/middle_africa/democratic_republic_of_the_congo'),
('Denmark', 'europe/northern_europe/denmark'),
('Djibouti', 'africa/eastern_africa/djibouti'),
('Dominica', 'americas/caribbean/dominica'),
('Dominican Republic', 'americas/caribbean/dominican_republic'),
('Ecuador', 'americas/south_america/ecuador'),
('Egypt', 'africa/northern_africa/egypt'),
('El Salvador', 'americas/central_america/el_salvador'),
('Equatorial Guinea', 'africa/middle_africa/equatorial_guinea'),
('Eritrea', 'africa/eastern_africa/eritrea'),
('Estonia', 'europe/northern_europe/estonia'),
('Ethiopia', 'africa/eastern_africa/ethiopia'),
('Faeroe Islands', 'europe/northern_europe/faeroe_islands'),
('Falkland Islands (Malvinas)', 'americas/south_america/falkland_islands'),
('Fiji', 'oceania/melanesia/fiji'),
('Finland', 'europe/northern_europe/finland'),
('France', 'europe/western_europe/france'),
('French Guiana', 'americas/south_america/french_guiana'),
('French Polynesia', 'oceania/polynesia/french_polynesia'),
('Gabon', 'africa/middle_africa/gabon'),
('Gambia', 'africa/western_africa/gambia'),
('Georgia', 'asia/western_asia/georgia'),
('Germany', 'europe/western_europe/germany'),
('Ghana', 'africa/western_africa/ghana'),
('Gibraltar', 'europe/southern_europe/gibraltar'),
('Greece', 'europe/southern_europe/greece'),
('Greenland', 'americas/northern_america/greenland'),
('Grenada', 'americas/caribbean/grenada'),
('Guadeloupe', 'americas/caribbean/guadeloupe'),
('Guam', 'oceania/micronesia/guam'),
('Guatemala', 'americas/central_america/guatemala'),
('Guernsey', 'europe/northern_europe/guernsey'),
('Guinea', 'africa/western_africa/guinea'),
('Guinea-Bissau', 'africa/western_africa/guinea-bissau'),
('Guyana', 'americas/south_america/guyana'),
('Haiti', 'americas/caribbean/haiti'),
('Holy See', 'europe/southern_europe/holy_see'),
('Honduras', 'americas/central_america/honduras'),
('Hong Kong Special Administrative Region of China', 'asia/eastern_asia/hong_kong'),
('Hungary', 'europe/eastern_europe/hungary'),
('Iceland', 'europe/northern_europe/iceland'),
('India', 'asia/southern_asia/india'),
('Indonesia', 'asia/south-eastern_asia/indonesia'),
('Iran, Islamic Republic of', 'asia/southern_asia/iran'),
('Iraq', 'asia/western_asia/iraq'),
('Ireland', 'europe/northern_europe/ireland'),
('Isle of Man', 'europe/northern_europe/isle_of_man'),
('Israel', 'asia/western_asia/israel'),
('Italy', 'europe/southern_europe/italy'),
('Jamaica', 'americas/caribbean/jamaica'),
('Japan', 'asia/eastern_asia/japan'),
('Jersey', 'europe/northern_europe/jersey'),
('Jordan', 'asia/western_asia/jordan'),
('Kazakhstan', 'asia/central_asia/kazakhstan'),
('Kenya', 'africa/eastern_africa/kenya'),
('Kiribati', 'oceania/micronesia/kiribati'),
('Kuwait', 'asia/western_asia/kuwait'),
('Kyrgyzstan', 'asia/central_asia/kyrgyzstan'),
("Lao People's Democratic Republic", 'asia/south-eastern_asia/lao_peoples_democratic_republic'),
('Latvia', 'europe/northern_europe/latvia'),
('Lebanon', 'asia/western_asia/lebanon'),
('Lesotho', 'africa/southern_africa/lesotho'),
('Liberia', 'africa/western_africa/liberia'),
('Libyan Arab Jamahiriya', 'africa/northern_africa/libyan_arab_jamahiriya'),
('Liechtenstein', 'europe/western_europe/liechtenstein'),
('Lithuania', 'europe/northern_europe/lithuania'),
('Luxembourg', 'europe/western_europe/luxembourg'),
('Macao Special Administrative Region of China', 'asia/eastern_asia/macao'),
('Madagascar', 'africa/eastern_africa/madagascar'),
('Malawi', 'africa/eastern_africa/malawi'),
('Malaysia', 'asia/south-eastern_asia/malaysia'),
('Maldives', 'asia/southern_asia/maldives'),
('Mali', 'africa/western_africa/mali'),
('Malta', 'europe/southern_europe/malta'),
('Marshall Islands', 'oceania/micronesia/marshall_islands'),
('Martinique', 'americas/caribbean/martinique'),
('Mauritania', 'africa/western_africa/mauritania'),
('Mauritius', 'africa/eastern_africa/mauritius'),
('Mayotte', 'africa/eastern_africa/mayotte'),
('Mexico', 'americas/central_america/mexico'),
('Micronesia, Federated States of', 'oceania/micronesia/federated_states_of_micronesia'),
('Monaco', 'europe/western_europe/monaco'),
('Mongolia', 'asia/eastern_asia/mongolia'),
('Montenegro', 'europe/southern_europe/montenegro'),
('Montserrat', 'americas/caribbean/montserrat'),
('Morocco', 'africa/northern_africa/morocco'),
('Mozambique', 'africa/eastern_africa/mozambique'),
('Myanmar', 'asia/south-eastern_asia/myanmar'),
('Namibia', 'africa/southern_africa/namibia'),
('Nauru', 'oceania/micronesia/nauru'),
('Nepal', 'asia/southern_asia/nepal'),
('Netherlands', 'europe/western_europe/netherlands'),
('Netherlands Antilles', 'americas/caribbean/netherlands_antilles'),
('New Caledonia', 'oceania/melanesia/new_caledonia'),
('New Zealand', 'oceania/australia/new_zealand'),
('Nicaragua', 'americas/central_america/nicaragua'),
('Niger', 'africa/western_africa/niger'),
('Nigeria', 'africa/western_africa/nigeria'),
('Niue', 'oceania/polynesia/niue'),
('Norfolk Island', 'oceania/australia/norfolk_island'),
('Northern Mariana Islands', 'oceania/micronesia/northern_mariana_islands'),
('Norway', 'europe/northern_europe/norway'),
('Occupied Palestinian Territory', 'asia/western_asia/occupied_palestinian_territory'),
('Oman', 'asia/western_asia/oman'),
('Pakistan', 'asia/southern_asia/pakistan'),
('Palau', 'oceania/micronesia/palau'),
('Panama', 'americas/central_america/panama'),
('Papua New Guinea', 'oceania/melanesia/papua_new_guinea'),
('Paraguay', 'americas/south_america/paraguay'),
('Peru', 'americas/south_america/peru'),
('Philippines', 'asia/south-eastern_asia/philippines'),
('Pitcairn', 'oceania/polynesia/pitcairn'),
('Poland', 'europe/eastern_europe/poland'),
('Portugal', 'europe/southern_europe/portugal'),
('Puerto Rico', 'americas/caribbean/puerto_rico'),
('Qatar', 'asia/western_asia/qatar'),
('Republic of Korea', 'asia/eastern_asia/republic_of_korea'),
('Republic of Moldova', 'europe/eastern_europe/republic_of_moldova'),
('Romania', 'europe/eastern_europe/romania'),
('Russian Federation', 'europe/eastern_europe/russian_federation'),
('Rwanda', 'africa/eastern_africa/rwanda'),
('R\xc3\xa9union', 'africa/eastern_africa/reunion'),
('Saint Helena', 'africa/western_africa/saint_helena'),
('Saint Kitts and Nevis', 'americas/caribbean/saint_kitts_and_nevis'),
('Saint Lucia', 'americas/caribbean/saint_lucia'),
('Saint Martin (French part)', 'americas/caribbean/saint_martin'),
('Saint Pierre and Miquelon', 'americas/northern_america/saint_pierre_and_miquelon'),
('Saint Vincent and the Grenadines', 'americas/caribbean/saint_vincent_and_the_grenadines'),
('Saint-Barth\xc3\xa9lemy', 'americas/caribbean/saint-barthelemy'),
('Samoa', 'oceania/polynesia/samoa'),
('San Marino', 'europe/southern_europe/san_marino'),
('Sao Tome and Principe', 'africa/middle_africa/sao_tome_and_principe'),
('Saudi Arabia', 'asia/western_asia/saudi_arabia'),
('Senegal', 'africa/western_africa/senegal'),
('Serbia', 'europe/southern_europe/serbia'),
('Seychelles', 'africa/eastern_africa/seychelles'),
('Sierra Leone', 'africa/western_africa/sierra_leone'),
('Singapore', 'asia/south-eastern_asia/singapore'),
('Slovakia', 'europe/eastern_europe/slovakia'),
('Slovenia', 'europe/southern_europe/slovenia'),
('Solomon Islands', 'oceania/melanesia/solomon_islands'),
('Somalia', 'africa/eastern_africa/somalia'),
('South Africa', 'africa/southern_africa/south_africa'),
('Spain', 'europe/southern_europe/spain'),
('Sri Lanka', 'asia/southern_asia/sri_lanka'),
('Sudan', 'africa/northern_africa/sudan'),
('Suriname', 'americas/south_america/suriname'),
('Svalbard and Jan Mayen Islands', 'europe/northern_europe/svalbard_and_jan_mayen_islands'),
('Swaziland', 'africa/southern_africa/swaziland'),
('Sweden', 'europe/northern_europe/sweden'),
('Switzerland', 'europe/western_europe/switzerland'),
('Syrian Arab Republic', 'asia/western_asia/syrian_arab_republic'),
('Tajikistan', 'asia/central_asia/tajikistan'),
('Thailand', 'asia/south-eastern_asia/thailand'),
('The former Yugoslav Republic of Macedonia', 'europe/southern_europe/macedonia'),
('Timor-Leste', 'asia/south-eastern_asia/timor-leste'),
('Togo', 'africa/western_africa/togo'),
('Tokelau', 'oceania/polynesia/tokelau'),
('Tonga', 'oceania/polynesia/tonga'),
('Trinidad and Tobago', 'americas/caribbean/trinidad_and_tobago'),
('Tunisia', 'africa/northern_africa/tunisia'),
('Turkey', 'asia/western_asia/turkey'),
('Turkmenistan', 'asia/central_asia/turkmenistan'),
('Turks and Caicos Islands', 'americas/caribbean/turks_and_caicos_islands'),
('Tuvalu', 'oceania/polynesia/tuvalu'),
('Uganda', 'africa/eastern_africa/uganda'),
('Ukraine', 'europe/eastern_europe/ukraine'),
('United Arab Emirates', 'asia/western_asia/united_arab_emirates'),
('United Kingdom of Great Britain and Northern Ireland', 'europe/northern_europe/united_kingdom'),
('United Republic of Tanzania', 'africa/eastern_africa/united_republic_of_tanzania'),
('United States Virgin Islands', 'americas/caribbean/united_states_virgin_islands'),
('United States of America', 'americas/northern_america/united_states_of_america'),
('Uruguay', 'americas/south_america/uruguay'),
('Uzbekistan', 'asia/central_asia/uzbekistan'),
('Vanuatu', 'oceania/melanesia/vanuatu'),
('Venezuela (Bolivarian Republic of)', 'americas/south_america/venezuela'),
('Viet Nam', 'asia/south-eastern_asia/viet_nam'),
('Wallis and Futuna Islands', 'oceania/polynesia/wallis_and_futuna_islands'),
('Western Sahara', 'africa/northern_africa/western_sahara'),
('Yemen', 'asia/western_asia/yemen'),
('Zambia', 'africa/eastern_africa/zambia'),
('Zimbabwe', 'africa/eastern_africa/zimbabwe'),
('\xc3\x85land Islands', 'europe/northern_europe/aland_islands'),
]
return [('', '')] + [(translateString(title), relative_url) for (title, relative_url) in region_item_list]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BusinessConfiguration_getRegionTitleItemList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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