Commit 070eeba4 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: User has no access to Account Documents anymore

   Use shadow user to access Account document, this prevent us to setup complex security.
parent 372fc666
...@@ -9,10 +9,23 @@ elif simulation_state in ("planned", "confirmed", "ordered", "started"): ...@@ -9,10 +9,23 @@ elif simulation_state in ("planned", "confirmed", "ordered", "started"):
else: else:
portal = context.getPortalObject() portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
paid = True paid = True
for line in context.getMovementList(portal.getPortalAccountingMovementTypeList()):
def isNodeFromLineReceivable(line):
node_value = line.getSourceValue(portal_type='Account') node_value = line.getSourceValue(portal_type='Account')
if node_value.getAccountType() == 'asset/receivable': return node_value.getAccountType() == 'asset/receivable'
for line in context.getMovementList(portal.getPortalAccountingMovementTypeList()):
if person is not None:
is_node_from_line_receivable = person.Person_restrictMethodAsShadowUser(
shadow_document=person,
callable_object=isNodeFromLineReceivable,
argument_list=[line])
else:
is_node_from_line_receivable = isNodeFromLineReceivable(line)
if is_node_from_line_receivable:
if not line.hasGroupingReference(): if not line.hasGroupingReference():
paid = False paid = False
break break
...@@ -35,7 +48,6 @@ else: ...@@ -35,7 +48,6 @@ else:
result = "Unpaid" result = "Unpaid"
else: else:
# Check if mapping exists # Check if mapping exists
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
external_payment_id = person.Person_restrictMethodAsShadowUser( external_payment_id = person.Person_restrictMethodAsShadowUser(
shadow_document=person, shadow_document=person,
callable_object=payment.PaymentTransaction_getExternalPaymentId, callable_object=payment.PaymentTransaction_getExternalPaymentId,
......
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