Commit 70f7754f authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: trigger deposit packing list creation in an alarm

parent ff2b5f0d
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_generateSlapOSDepositSalePackingList</string> </value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_generate_deposit_sale_packing_list</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>0.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SlapOS Generate Deposit Sale Packing List</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -31,6 +31,10 @@
<type>Open Sale Order</type>
<workflow>slapos_accounting_interaction_workflow, slapos_simulation_interaction_workflow</workflow>
</chain>
<chain>
<type>Payment Transaction</type>
<workflow>slapos_accounting_interaction_workflow</workflow>
</chain>
<chain>
<type>Project</type>
<workflow>slapos_accounting_interaction_workflow</workflow>
......
portal = context.getPortalObject()
activate_kw = {'tag': tag}
select_dict= {'causality__uid': None}
portal.portal_catalog.searchAndActivate(
portal_type='Payment Transaction',
simulation_state='stopped',
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
# Only check standalone payment
left_join_list=select_dict.keys(),
causality__uid=None,
method_id='PaymentTransaction_acceptDepositPayment',
method_kw={'activate_kw': activate_kw},
activate_kw=activate_kw
)
context.activate(after_tag=tag).getId()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_generateSlapOSDepositSalePackingList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
from DateTime import DateTime
portal = context.getPortalObject()
payment_transaction = context
payment_transaction.stop()
assert payment_transaction.getSimulationState() == 'stopped'
trade_condition = payment_transaction.getSpecialiseValue()
assert trade_condition is not None
assert trade_condition.getTradeConditionType() == 'deposit'
# Ensure the payment has no grouping reference
assert not [x for x in trade_condition.contentValues(portal_type='Accounting Transaction Line') if x.getGroupingReference(None) is not None]
start_date = DateTime()
stop_date = None
......@@ -14,7 +23,12 @@ quantity_unit_value = resource_value.getQuantityUnitValue()
order_portal_type = 'Sale Packing List'
order_line_portal_type = 'Sale Packing List Line'
activate_kw = None
existing_packing_list = portal.portal_catalog.getResultValue(
portal_type=order_portal_type,
causality__uid=payment_transaction.getUid()
)
if existing_packing_list is not None:
return
#######################################################
# Open Sale Order
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>activate_kw=None, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -19,6 +19,7 @@ currency_module/EUR
portal_alarms/slapos_accounting_generate_packing_list_from_tioxml
portal_alarms/slapos_archive_open_sale_order_with_unused_item
portal_alarms/slapos_cancel_sale_invoice_transaction_paied_payment_list
portal_alarms/slapos_generate_deposit_sale_packing_list
portal_alarms/slapos_manage_building_calculating_delivery
portal_alarms/slapos_remove_bogus_delivery_link
portal_alarms/slapos_stop_confirmed_aggregated_sale_invoice_transaction
......
......@@ -10,6 +10,7 @@ Hosting Subscription | slapos_accounting_interaction_workflow
Instance Tree | slapos_accounting_interaction_workflow
Open Sale Order | slapos_accounting_interaction_workflow
Open Sale Order | slapos_simulation_interaction_workflow
Payment Transaction | slapos_accounting_interaction_workflow
Project | slapos_accounting_interaction_workflow
Sale Invoice Transaction | slapos_accounting_interaction_workflow
Sale Invoice Transaction | slapos_simulation_interaction_workflow
......
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