Commit 42c2a915 authored by Jérome Perrin's avatar Jérome Perrin

configurator_standard: repair accounting generation with default accounts

in 772d8fed (configurator_standard: use specific sale and purchase
business processes, 2020-07-16) we introduced scripts to look up
dynamically accounts to use for expense/income and VAT accounts, from
supply lines, but this accidentally broke the case where no account can be
found on supply lines: in this case, the accounting line was not generated.

Ideally, there should be fallback accounts, to keep the same behavior and
also to prevent generation of incomplete transactions.

Review the scripts, so that the "Dynamic" scripts fallback on the account
defined on the trade model path if not found and introduce new scripts,
where the account is not taken dynamically, but only from the trade model
path, for use on the payable/receivable lines (where we don't want to
lookup the account dynamically, otherwise we'll use same account as for
expense/income)
parent 7058ab6f
return [
c for c in [
movement.getDestinationSection(base=True),
movement.getDestinationPayment(base=True),
context.getDestination(base=True)
] if c
]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getAccountingDestinationCategoryListWithoutAnalytic</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -7,9 +7,10 @@ category_list = [ ...@@ -7,9 +7,10 @@ category_list = [
] if c ] if c
] ]
account = movement.getDestinationAccount() or context.getDestination() account = movement.getDestinationAccount()
if not account: if not account:
# try to find from predicates # try to find from predicates, with fallback on the account
# defined on the trade model path
resource = movement.getResourceValue() resource = movement.getResourceValue()
if resource is not None: if resource is not None:
account = next( account = next(
...@@ -19,8 +20,7 @@ if not account: ...@@ -19,8 +20,7 @@ if not account:
context=movement, context=movement,
portal_type='Purchase Supply Line', portal_type='Purchase Supply Line',
) )
if predicate.getDestinationAccount()), None) if predicate.getDestinationAccount()), context.getDestination())
if account: if account:
category_list.append('destination/%s' % account) category_list.append('destination/%s' % account)
......
...@@ -7,9 +7,10 @@ category_list = [ ...@@ -7,9 +7,10 @@ category_list = [
] if c ] if c
] ]
account = movement.getSourceAccount() or context.getSource() account = movement.getSourceAccount()
if not account: if not account:
# try to find from predicates # try to find from predicates, with fallback on the account
# defined on the trade model path
resource = movement.getResourceValue() resource = movement.getResourceValue()
if resource is not None: if resource is not None:
account = next( account = next(
...@@ -19,7 +20,7 @@ if not account: ...@@ -19,7 +20,7 @@ if not account:
context=movement, context=movement,
portal_type='Sale Supply Line', portal_type='Sale Supply Line',
) )
if predicate.getSourceAccount()), None) if predicate.getSourceAccount()), context.getSource())
if account: if account:
category_list.append('source/%s' % account) category_list.append('source/%s' % account)
......
return [
c for c in [
movement.getSourceSection(base=True),
movement.getSourcePayment(base=True),
context.getSource(base=True),
] if c
]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getAccountingSourceCategoryListWithoutAnalytic</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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