Commit 10a15fb4 authored by Jérome Perrin's avatar Jérome Perrin

base: fix error printing deliveries with only \n in description

Default printout (used for order, packing lists, invoices etc) was raising
error for deliveries with cells when the resource descrption was only \n
parent 745ccbd7
...@@ -118,7 +118,7 @@ def unicodeDict(d): ...@@ -118,7 +118,7 @@ def unicodeDict(d):
for line in getSubLineList(context): for line in getSubLineList(context):
prod_desc = line.getResource() is not None and \ prod_desc = line.getResource() is not None and \
line.getResourceValue().getDescription() or ( getFieldAsString(line.getResourceValue().getDescription()) or (
request.get('international_form') and line.getResourceTitle() or line.getResourceTranslatedTitle() ) request.get('international_form') and line.getResourceTitle() or line.getResourceTranslatedTitle() )
if use_line_title: if use_line_title:
desc = (line.getTitle(), ) desc = (line.getTitle(), )
......
...@@ -2950,7 +2950,69 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -2950,7 +2950,69 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
if err_list: if err_list:
self.fail(''.join(err_list)) self.fail(''.join(err_list))
# TODO: test with cells ? def test_Order_viewAsODT_cell(self):
resource = self.portal.getDefaultModule(
self.resource_portal_type
).newContent(
portal_type=self.resource_portal_type,
title='Resource Title',
variation_base_category_list=['size']
)
client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client')
vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Vendor')
order = self.portal.getDefaultModule(self.order_portal_type).newContent(
portal_type=self.order_portal_type,
specialise=self.business_process,
title='Order',
start_date=self.datetime,
source_value=vendor,
source_section_value=vendor,
destination_value=client,
destination_section_value=client)
order_line = order.newContent(
portal_type=self.order_line_portal_type,
resource_value=resource,)
order_line.setVariationBaseCategoryList(('size', ))
order_line.setVariationCategoryList(['size/Child/32'])
order_cell = order_line.newCell(
'size/Child/32',
base_id='movement',)
order_cell.edit(
quantity=10,
price=3)
order.confirm()
self.tic()
# we use "${resource title} ${variation}" by for lines
self.assertEqual(
order.Order_getODTDataDict()['line_list'][-1]['description'],
('Resource Title 32',))
# unless resource has a description, then we use "${resource description} ${variation}"
resource.setDescription('Resource Description')
self.assertEqual(
order.Order_getODTDataDict()['line_list'][-1]['description'],
('Resource Description 32',))
# If the descrption is multi line, we use "," separated lines for ${resource description}
resource.setDescription('Resource\nDescription')
self.assertEqual(
order.Order_getODTDataDict()['line_list'][-1]['description'],
('Resource, Description 32',))
# There use to be an error when description is only \n. In that case it should only use title
resource.setDescription('\n')
self.assertEqual(
order.Order_getODTDataDict()['line_list'][-1]['description'],
('Resource Title 32',))
odt = order.Order_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator()
err_list = odf_validator.validate(odt)
if err_list:
self.fail(''.join(err_list))
def test_subcontent_reindexing(self): def test_subcontent_reindexing(self):
"""Tests, that modification on Order are propagated to lines and cells """Tests, that modification on Order are propagated to lines and cells
......
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