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()
portal.portal_catalog.searchAndActivate(
method_id='InstanceTree_requestUpdateOpenSaleOrder',
method_kw=dict(specialise="sale_trade_condition_module/default_subscription_trade_condition", ),
portal_type="Instance Tree",
causality_state="diverged",
activate_kw={'tag': tag, 'priority': 2},
......
......@@ -115,13 +115,28 @@ if instance_tree.getCausalityState() == 'diverged':
**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 = []
log_predicate_list = []
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:
predicate_list.extend([
x for x in inherited_trade_condition.contentValues(portal_type='Sale Supply Line')
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())
price = service.getPrice(
......@@ -130,7 +145,13 @@ if instance_tree.getCausalityState() == 'diverged':
default=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(
price=price
)
......@@ -141,12 +162,6 @@ if instance_tree.getCausalityState() == 'diverged':
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:
open_order = open_order_line.getParentValue()
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>specialise, REQUEST=None</string> </value>
<value> <string>specialise=None, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -18,7 +18,7 @@ consumption_specialise_uid_list = [q.getUid() for q in portal.ERP5Site_searchRel
portal_type='Sale Trade Condition')]
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}
......
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