Commit b5138e84 authored by Romain Courteaud's avatar Romain Courteaud 🐙

slapos_accounting:

* consider Software Product as a Service
* use Software Product
* search the trade condition with searchPredicateList
* ensure trade condition is found
parent f56ee68f
...@@ -2,7 +2,6 @@ portal = context.getPortalObject() ...@@ -2,7 +2,6 @@ portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
method_id='InstanceTree_requestUpdateOpenSaleOrder', method_id='InstanceTree_requestUpdateOpenSaleOrder',
method_kw=dict(specialise="sale_trade_condition_module/default_subscription_trade_condition", ),
portal_type="Instance Tree", portal_type="Instance Tree",
causality_state="diverged", causality_state="diverged",
activate_kw={'tag': tag, 'priority': 2}, activate_kw={'tag': tag, 'priority': 2},
......
...@@ -115,13 +115,28 @@ if instance_tree.getCausalityState() == 'diverged': ...@@ -115,13 +115,28 @@ if instance_tree.getCausalityState() == 'diverged':
**edit_kw **edit_kw
) )
open_order = open_order_line.getParentValue()
open_order.SaleOrder_applySaleTradeCondition(batch_mode=1, force=1)
# Check compatibility with previous template
if specialise is not None:
assert open_order.getSpecialise() == specialise
predicate_list = [] predicate_list = []
log_predicate_list = []
inherited_trade_condition = open_sale_order.getSpecialiseValue() inherited_trade_condition = open_sale_order.getSpecialiseValue()
if specialise is None:
assert inherited_trade_condition is not None
while inherited_trade_condition is not None: while inherited_trade_condition is not None:
predicate_list.extend([ predicate_list.extend([
x for x in inherited_trade_condition.contentValues(portal_type='Sale Supply Line') x for x in inherited_trade_condition.contentValues(portal_type='Sale Supply Line')
if x.getResource() == service.getRelativeUrl() if x.getResource() == service.getRelativeUrl()
]) ])
log_predicate_list.extend([
x for x in inherited_trade_condition.contentValues(portal_type='Sale Supply Line')
])
inherited_trade_condition = inherited_trade_condition.getSpecialiseValue(portal_type=inherited_trade_condition.getPortalType()) inherited_trade_condition = inherited_trade_condition.getSpecialiseValue(portal_type=inherited_trade_condition.getPortalType())
price = service.getPrice( price = service.getPrice(
...@@ -130,7 +145,13 @@ if instance_tree.getCausalityState() == 'diverged': ...@@ -130,7 +145,13 @@ if instance_tree.getCausalityState() == 'diverged':
default=None, default=None,
) )
if price is None: if price is None:
raise NotImplementedError('Price must be defined') raise NotImplementedError('Price not found on %s (%s) for %s %s - %s' % (
open_sale_order.getSpecialiseTitle(),
open_sale_order.getSpecialise(),
service.getRelativeUrl(),
str([x.getRelativeUrl() for x in predicate_list]),
str([(x.getRelativeUrl(), x.getResource()) for x in log_predicate_list]),
))
open_order_line.edit( open_order_line.edit(
price=price price=price
) )
...@@ -141,12 +162,6 @@ if instance_tree.getCausalityState() == 'diverged': ...@@ -141,12 +162,6 @@ if instance_tree.getCausalityState() == 'diverged':
storeWorkflowComment(open_sale_order, open_order_explanation) storeWorkflowComment(open_sale_order, open_order_explanation)
open_order = open_order_line.getParentValue()
open_order.SaleOrder_applySaleTradeCondition(batch_mode=1, force=1)
# Check compatibility with previous template
assert open_order.getSpecialise() == specialise
if open_order_line is not None: if open_order_line is not None:
open_order = open_order_line.getParentValue() open_order = open_order_line.getParentValue()
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>specialise, REQUEST=None</string> </value> <value> <string>specialise=None, REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -18,7 +18,7 @@ consumption_specialise_uid_list = [q.getUid() for q in portal.ERP5Site_searchRel ...@@ -18,7 +18,7 @@ consumption_specialise_uid_list = [q.getUid() for q in portal.ERP5Site_searchRel
portal_type='Sale Trade Condition')] portal_type='Sale Trade Condition')]
aggregateable_service_uid_list = [service.getUid() for service in \ aggregateable_service_uid_list = [service.getUid() for service in \
portal.portal_categories.base_amount.invoicing.getBaseContributionRelatedValueList(portal_type=["Service", "Software Product"])] portal.portal_categories.base_amount.invoicing.getBaseContributionRelatedValueList(portal_type=portal.getPortalServiceTypeList())]
select_dict= {'default_aggregate_portal_type': None} select_dict= {'default_aggregate_portal_type': None}
......
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