Commit 0bea8d32 authored by Romain Courteaud's avatar Romain Courteaud

slapos_panel: update add Sale SUpply action

parent 5dddea56
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>python: (context.Project_getAccountingCurrency() is not None) and context.Base_hasSlapOSProjectUserGroup(manager=True, agent=True)</string> </value> <value> <string>python: portal.Base_checkPermission(\'sale_supply_module\', \'Add portal content\')</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>python: (context.getValidationState() == \'validated\') and (context.Base_hasSlapOSProjectUserGroup(manager=True, agent=True, project_relation=\'destination_project\'))</string> </value> <value> <string>python: (context.getValidationState() == \'validated\') and ((context.Base_hasSlapOSProjectUserGroup(manager=True, agent=True, project_relation=\'destination_project\')) or (context.Base_hasSlapOSProjectUserGroup(manager=True, agent=True, project_relation=\'source_project\')))</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>python: (context.getValidationState() in (\'draft\', \'invalidated\')) and (context.Base_hasSlapOSProjectUserGroup(manager=True, agent=True, project_relation=\'destination_project\'))</string> </value> <value> <string>python: (context.getValidationState() in (\'draft\', \'invalidated\')) and ((context.Base_hasSlapOSProjectUserGroup(manager=True, agent=True, project_relation=\'destination_project\')) or (context.Base_hasSlapOSProjectUserGroup(manager=True, agent=True, project_relation=\'source_project\')))</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -6,6 +6,8 @@ elif project_relation == 'follow_up': ...@@ -6,6 +6,8 @@ elif project_relation == 'follow_up':
project = context.getFollowUpValue() project = context.getFollowUpValue()
elif project_relation == 'destination_project': elif project_relation == 'destination_project':
project = context.getDestinationProjectValue() project = context.getDestinationProjectValue()
elif project_relation == 'source_project':
project = context.getSourceProjectValue()
else: else:
raise ValueError('Unexpected project relation: %s' % project_relation) raise ValueError('Unexpected project relation: %s' % project_relation)
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -3,22 +3,11 @@ from Products.ERP5Type.Message import translateString ...@@ -3,22 +3,11 @@ from Products.ERP5Type.Message import translateString
portal = context.getPortalObject() portal = context.getPortalObject()
project = context project = context
currency = project.Project_getAccountingCurrency()
if currency is None:
return context.Base_redirect(
keep_items={
'portal_status_message': translateString('Can not find project currency'),
'portal_status_level': "error",
}
)
sale_supply = portal.sale_supply_module.newContent( sale_supply = portal.sale_supply_module.newContent(
title="All %s" % DateTime(), title="All %s" % DateTime(),
portal_type="Sale Supply", portal_type="Sale Supply",
destination_project_value=project, source_project_value=project,
start_date_range_min=DateTime(), start_date_range_min=DateTime()
price_currency=currency
) )
software_product_list = portal.portal_catalog( software_product_list = portal.portal_catalog(
...@@ -32,7 +21,14 @@ for sql_software_product in software_product_list: ...@@ -32,7 +21,14 @@ for sql_software_product in software_product_list:
title=sql_software_product.getTitle(), title=sql_software_product.getTitle(),
resource_value=sql_software_product.getObject() resource_value=sql_software_product.getObject()
) )
"""
compute_node_service = portal.restrictedTraverse('service_module/slapos_compute_node_subscription')
sale_supply.newContent(
portal_type="Sale Supply Line",
title=compute_node_service.getTitle(),
resource_value=compute_node_service
)
"""
return sale_supply.Base_redirect( return sale_supply.Base_redirect(
keep_items={'portal_status_message': translateString('New Sale Supply created.')} keep_items={'portal_status_message': translateString('New Sale Supply created.')}
) )
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
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