Commit 0ac9d669 authored by Jérome Perrin's avatar Jérome Perrin

accounting: show a column for items on accounting transactions views

The view of accounting transactions have dynamic columns so that all the
information that matters the most is displayed directly on the "main"
view. This extends the columns to add a column for all the items attached
to accounting movements.
parent 5ad2b222
Pipeline #19436 failed with stage
......@@ -9,10 +9,12 @@ payment_set = set((None,))
payment_request_set = set((None,))
project_set = set((None,))
resource_set = set((context.getResource(),))
item_set = set((None, ))
movement_type_list = context.getPortalAccountingMovementTypeList()
for line in context.getMovementList(portal_type=movement_type_list):
resource_set.add(line.getResource())
item_set.add(line.getAggregate())
if source:
section_set.add(line.getDestinationSection())
payment_set.add(line.getSourcePayment())
......@@ -95,6 +97,9 @@ if force_project or len(project_set) > min_project_count:
else:
a(('getDestinationProjectTitle', 'Project'))
if len(item_set) > 1:
a(('aggregate_title_list', 'Items'))
if source:
a(('source_debit', 'Debit'))
a(('source_credit', 'Credit'))
......
......@@ -84,6 +84,7 @@
<string>listbox_source_debit</string>
<string>listbox_source_function</string>
<string>listbox_source_funding</string>
<string>listbox_aggregate_title_list</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountingTransaction_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -114,6 +114,7 @@
<string>listbox_function</string>
<string>listbox_funding</string>
<string>my_ledger</string>
<string>listbox_aggregate_title_list</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_lines_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Items</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.getAggregateTitleList() or \'\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -84,6 +84,7 @@
<string>listbox_source_credit</string>
<string>listbox_source_function</string>
<string>listbox_source_funding</string>
<string>listbox_aggregate_title_list</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountingTransaction_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -84,6 +84,7 @@
<string>listbox_destination_debit</string>
<string>listbox_destination_function</string>
<string>listbox_destination_funding</string>
<string>listbox_aggregate_title_list</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountingTransaction_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -84,6 +84,7 @@
<string>listbox_source_debit</string>
<string>listbox_source_function</string>
<string>listbox_source_funding</string>
<string>listbox_aggregate_title_list</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>listbox_aggregate_title_list</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountingTransaction_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -30,6 +30,9 @@
"""
from StringIO import StringIO
import lxml
from DateTime import DateTime
from Products.CMFCore.utils import _checkPermission
......@@ -4412,6 +4415,93 @@ class TestTransactions(AccountingTestCase):
('getSourceSectionTitle', 'Third Party'),
at.AccountingTransaction_getListBoxColumnList(source=False))
def test_AccountingTransaction_getListBoxColumnList_item_column(self):
item1 = self.portal.item_module.newContent(title='Item 1')
item2 = self.portal.item_module.newContent(title='Item 2')
aggregate_column_item = ('aggregate_title_list', 'Items')
for view_id, at in (
(
'view',
self._makeOne(
portal_type='Accounting Transaction',
source_section_value=self.section,
destination_section_value=self.organisation_module.client_1,
lines=(dict(id='line_with_aggregate',
source_value=self.account_module.goods_purchase,
source_debit=500),
dict(source_value=self.account_module.receivable,
source_credit=500))),
),
(
'SaleInvoiceTransaction_viewAccounting',
self._makeOne(
portal_type='Sale Invoice Transaction',
source_section_value=self.section,
destination_section_value=self.organisation_module.client_1,
lines=(dict(id='line_with_aggregate',
source_value=self.account_module.goods_purchase,
source_debit=500),
dict(source_value=self.account_module.receivable,
source_credit=500))),
),
(
'view',
self._makeOne(
portal_type='Payment Transaction',
source_section_value=self.section,
destination_section_value=self.organisation_module.client_1,
lines=(dict(id='line_with_aggregate',
source_value=self.account_module.goods_purchase,
source_debit=500),
dict(source_value=self.account_module.receivable,
source_credit=500))),
),
(
'PurchaseInvoiceTransaction_viewAccounting',
self._makeOne(
portal_type='Purchase Invoice Transaction',
destination_section_value=self.section,
source_section_value=self.organisation_module.supplier,
lines=(dict(id='line_with_aggregate',
source_value=self.account_module.goods_purchase,
source_debit=500),
dict(source_value=self.account_module.receivable,
source_credit=500))),
),
):
self.assertNotIn(
aggregate_column_item,
at.AccountingTransaction_getListBoxColumnList(source=True),
)
self.assertNotIn(
aggregate_column_item,
at.AccountingTransaction_getListBoxColumnList(source=False),
)
at.line_with_aggregate.setAggregateValueList((item1, item2))
html = getattr(at, view_id)()
tree = lxml.etree.parse(StringIO(html), lxml.etree.HTMLParser())
self.assertIn(
aggregate_column_item,
at.AccountingTransaction_getListBoxColumnList(source=True),
)
self.assertIn(
aggregate_column_item,
at.AccountingTransaction_getListBoxColumnList(source=False),
)
self.assertEqual(
tree.xpath(
'//table[contains(@class, "listbox-table")]/thead/tr/th/text()'),
[u'\xa0', 'ID', 'Account', 'Items', 'Debit', 'Credit'],
)
self.assertEqual(
tree.xpath(
'//table[contains(@class, "listbox-table")]/tbody/tr[1]/td[4]/a/div/text()'
),
['Item 1', 'Item 2'],
)
def test_AccountingTransaction_getSourcePaymentItemList(self):
# AccountingTransaction_getSourcePaymentItemList allows to select bank accounts
# from section
......
......@@ -8,6 +8,7 @@ erp5_project
erp5_ods_style
erp5_configurator_standard_trade_template
erp5_invoicing
erp5_item
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
erp5_simulation_test
......
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