diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/Invoice_createCreditNoteInvoice.xml b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/Invoice_createCreditNoteInvoice.xml index 8c5309e63db80fc061386a0a0afa13c5b3356f02..fb20e19bf4b541627e64bdbadba83ed41e0e3fd0 100644 --- a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/Invoice_createCreditNoteInvoice.xml +++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/Invoice_createCreditNoteInvoice.xml @@ -54,6 +54,27 @@ This script is supposed to be the common denominator for invoice reversing operations.\n Instead of extending it, call it from project-specific script and edit returned document (or its lines).\n """\n +def recursiveCopyLine(to_document, from_document):\n + newContent = to_document.newContent\n + for line in from_document.objectValues(portal_type=\'Invoice Line\'):\n + reverse_line = newContent(\n + description=line.getDescription(),\n + int_index=line.getIntIndex(),\n + portal_type=line.getPortalType(),\n + price=line.getPrice(),\n + quantity=-line.getQuantity(), # Notice the "-" !\n + reference=line.getReference(),\n + category_list=line.getCategoryList(),\n + )\n + recursiveCopyLine(reverse_line, line)\n + newCell = reverse_line.newContent\n + for cell in line.objectValues(portal_type=\'Invoice Cell\'):\n + raise NotImplementedError\n + newCell(\n + # TODO: what properties ?\n + portal_type=cell.getPortalType(),\n + category_list=cell.getCategoryList(),\n + )\n \n portal = context.getPortalObject()\n reverse_invoice = context.getParentValue().newContent(\n @@ -70,18 +91,7 @@ reverse_invoice.edit(\n price_currency_list=context.getPriceCurrencyList(),\n resource_list=context.getResourceList(),\n )\n -newContent = reverse_invoice.newContent\n -for line in context.objectValues():\n - if not line.isGeneratedBySimulation():\n - newContent(\n - description=line.getDescription(),\n - int_index=line.getIntIndex(),\n - portal_type=line.getPortalType(),\n - price=line.getPrice(),\n - quantity=-line.getQuantity(), # Notice the "-" !\n - reference=line.getReference(),\n - category_list=line.getCategoryList(),\n - )\n +recursiveCopyLine(reverse_invoice, context)\n return reverse_invoice\n </string> </value> </item> diff --git a/bt5/erp5_invoicing/bt/revision b/bt5/erp5_invoicing/bt/revision index 116f2e3e6285b8735c29a9f35482b10406c806c0..c0db21d808434d1d2d318e959bc4c7c190a76dcf 100644 --- a/bt5/erp5_invoicing/bt/revision +++ b/bt5/erp5_invoicing/bt/revision @@ -1 +1 @@ -391 \ No newline at end of file +392 \ No newline at end of file