From 317884be6aa7445d65d67cd638d2d793ab3ff05c Mon Sep 17 00:00:00 2001 From: "Jose Suniaga [Vauxoo]" Date: Thu, 3 Jan 2019 19:10:59 +0000 Subject: [PATCH 1/4] [FIX] sale: Call the proper method in the test and not the partial one (continuation). In complement to issue reported in: https://github.com/odoo/odoo/pull/27316 closes odoo/odoo#29907 --- .../tests/test_sale_to_invoice_and_to_be_invoiced.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py b/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py index b5a28a435d3..c7df57978b9 100644 --- a/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py +++ b/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py @@ -77,7 +77,7 @@ class TestSaleOrderInvoicing(AccountingTestCase): self.assertEqual(sum(order.order_line.mapped('amt_invoiced')), 500.0, 'Sale: the Amount Invoiced for the sale order should be 500.0.') # Now I validate invoice_2. - invoice_2.invoice_validate() + invoice_2.action_invoice_open() self.assertEqual(sum(order.order_line.mapped('amt_to_invoice')), 0.0, 'Sale: the Amount To Invoice for the sale order should be 0.0.') self.assertEqual(sum(order.order_line.mapped('amt_invoiced')), 800.0, 'Sale: the Amount Invoiced for the sale order should be 800.0.') @@ -92,7 +92,7 @@ class TestSaleOrderInvoicing(AccountingTestCase): # I clicked on refund button. account_invoice_refund_1.with_context(context).invoice_refund() - invoice_1.refund_invoice_ids and invoice_1.refund_invoice_ids[0].invoice_validate() + invoice_1.refund_invoice_ids and invoice_1.refund_invoice_ids[0].action_invoice_open() self.assertEqual(sum(order.order_line.mapped('amt_to_invoice')), 0.0, 'Sale: the Amount To Invoice for the sale order should be 0.0.') self.assertEqual(sum(order.order_line.mapped('amt_invoiced')), 300.0, 'Sale: the Amount Invoiced for the sale order should be 300.0.') @@ -107,7 +107,7 @@ class TestSaleOrderInvoicing(AccountingTestCase): # I clicked on refund button. account_invoice_refund_2.with_context(context).invoice_refund() - invoice_2.refund_invoice_ids and invoice_2.refund_invoice_ids[0].invoice_validate() + invoice_2.refund_invoice_ids and invoice_2.refund_invoice_ids[0].action_invoice_open() self.assertEqual(sum(order.order_line.mapped('amt_to_invoice')), 0.0, 'Sale: the Amount To Invoice for the sale order should be 0.0.') self.assertEqual(sum(order.order_line.mapped('amt_invoiced')), 0.0, 'Sale: the Amount Invoiced for the sale order should be 0.0.') @@ -198,7 +198,7 @@ class TestSaleOrderInvoicing(AccountingTestCase): self.assertEqual(sale_line_ord.amt_invoiced, 0.0, 'Amount invoiced for ordered SO line should zero, there is no validated invoice at this moment') # validate invoice - invoice_1.invoice_validate() + invoice_1.action_invoice_open() self.assertEqual(sale_line_deli.amt_to_invoice, 0.0, 'Amount to invoice for delivered SO line is still zero, since its delivered quantity (on SO line) is zero') self.assertEqual(sale_line_deli.amt_invoiced, 0.0, 'Amount invoiced for delivered SO line is still zero, since its delivered quantity (on SO line) is zero, and there is no invoice at this moment') @@ -219,7 +219,7 @@ class TestSaleOrderInvoicing(AccountingTestCase): }) payment.with_context(invoice_context).create_invoices() invoice_2 = order.invoice_ids.sorted(key='id')[1] - invoice_2.invoice_validate() + invoice_2.action_invoice_open() self.assertEqual(sale_line_deli.amt_to_invoice, 0.0, 'Amount to invoice for delivered SO line is 0, since this is all invoiced') self.assertEqual(sale_line_deli.amt_invoiced, 1000.0, 'Amount invoiced for delivered SO line is now 1000, since the invoice for this product is validated') @@ -263,7 +263,7 @@ class TestSaleOrderInvoicing(AccountingTestCase): self.assertEqual(sale_line_ord.amt_invoiced, 40.0, 'Amount invoiced for ordered SO line should 40, there is a validated invoice at this moment') # validate third invoice - invoice_3.invoice_validate() + invoice_3.action_invoice_open() self.assertEqual(sale_line_deli.amt_to_invoice, 0.0, 'Amount to invoice for delivered SO line is now 0, since SO is cancel') self.assertEqual(sale_line_deli.amt_invoiced, 1300.0, 'Amount invoiced for delivered SO line is incremented, since the 3rd invoice for this product is validated') From 7eec6b3643999cb26216e56c001eb8aae65031ea Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Mon, 28 Jan 2019 14:54:09 +0000 Subject: [PATCH 2/4] [FIX] packaging: allow install on fedora29 Fedora 29 switched to python 3.7. It seems that there is no official way to build a RPM package that could works with 3.6 and 3.7. Building two different packages for each version could open the pandora box of packaging. With this commit an ugly hack is used: if python3.7 is found, the odoo directory is symlinked into its site-packages dir. fixes #30579 closes odoo/odoo#30618 --- setup.cfg | 2 +- setup/redhat/postinstall.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3994ef225f2..4cce04e18da 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,7 @@ requires = nodejs-less pychart pyparsing - python(abi) = 3.6 + python(abi) >= 3.6 python3-babel python3-decorator python3-docutils diff --git a/setup/redhat/postinstall.sh b/setup/redhat/postinstall.sh index 54b1b5cd56f..e6ee9106f7d 100644 --- a/setup/redhat/postinstall.sh +++ b/setup/redhat/postinstall.sh @@ -10,6 +10,12 @@ ODOO_LOG_DIR=/var/log/odoo ODOO_LOG_FILE=$ODOO_LOG_DIR/odoo-server.log ODOO_USER="odoo" +if [ -d /usr/lib/python3.7 ]; then + SITE_PACK_DIR37=/usr/lib/python3.7/site-packages + [[ ! -d ${SITE_PACK_DIR37} ]] && mkdir -p ${SITE_PACK_DIR37} + ln -s /usr/lib/python3.6/site-packages/odoo ${SITE_PACK_DIR37}/odoo +fi + if ! getent passwd | grep -q "^odoo:"; then groupadd $ODOO_GROUP adduser --system --no-create-home $ODOO_USER -g $ODOO_GROUP From 7e0603785bae59be9a829a247903f8c9806648e3 Mon Sep 17 00:00:00 2001 From: sbbaro Date: Wed, 30 Jan 2019 09:42:20 +0000 Subject: [PATCH 3/4] [FIX] base.ir_actions_report print ordered pdfs When printing multiple reports with the "Reload from Attachment" option selected, the order of the rendered pdfs was not respected. Using an ordered dictionary instead of a randomized one solves the problem. opw 1915685 closes odoo/odoo#30690 --- odoo/addons/base/ir/ir_actions_report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/ir/ir_actions_report.py b/odoo/addons/base/ir/ir_actions_report.py index 10a0b0b634e..4645eb9a31c 100644 --- a/odoo/addons/base/ir/ir_actions_report.py +++ b/odoo/addons/base/ir/ir_actions_report.py @@ -23,6 +23,7 @@ from contextlib import closing from distutils.version import LooseVersion from reportlab.graphics.barcode import createBarcodeDrawing from PyPDF2 import PdfFileWriter, PdfFileReader +from collections import OrderedDict _logger = logging.getLogger(__name__) @@ -601,7 +602,7 @@ class IrActionsReport(models.Model): if isinstance(self.env.cr, TestCursor): return self.with_context(context).render_qweb_html(res_ids, data=data)[0] - save_in_attachment = {} + save_in_attachment = OrderedDict() if res_ids: # Dispatch the records by ones having an attachment and ones requesting a call to # wkhtmltopdf. From 1dbe4ea0d7f63d299b48edd6e55accb15a3632d2 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 25 Jan 2019 08:56:53 +0000 Subject: [PATCH 4/4] [FIX] web: current date - Set the OS in a timezone such as the current day is different from the day in UTC (e.g. America/Nome before 10:00 AM or Australia/Melbourne after 3:00 PM) - Open any datepicker - The 'little triangle' indicating the current day is wrongly set (one day before or after) Knowing that Odoo always creates momentjs date and datetime with the `UTC` flag set to `true`, the `bootstrap-datetimepicker` does something which seems inconsistent. First, it retrieves the `viewDate`, and sets it to the beginning of the month and week in: https://github.com/odoo/odoo/blob/1c6c504215f3ef09e6336c92c9d350e87599eaa1/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js#L725 In this part, it is important to note that each `startOf` functions called sets the hours/minutes/seconds to zero. It means that the reference time is changed. Then, it iterates on this newly created date, and determines `today` by comparing it to `getMoment()` in: https://github.com/odoo/odoo/blob/1c6c504215f3ef09e6336c92c9d350e87599eaa1/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js#L748 However, `getMoment()` returns the current date and time, but with the `UTC` flag set to `false`. Therefore, we compare a UTC datetime on which the reference time has been changed to a non-UTC datetime, which fails to give the appropriate current day. There are two approaches to solve this. The first possibility is to change the way Odoo defines momentjs dates and datetimes, maybe by removing the `UTC` flag at creation. This sounds like a bad idea, since other widgets or views (such as the calendar or the pivot view) make use of them. This is likely to introduce a bunch of new issues with TZ in these views. The second approach is patching the library to fit our use. Although we usually don't do such a thing, this allows to specifically solve this use case, and in particular placing the 'small triangle' at the appropriate date without impacting any other part of the system or the library. It can be easily performed by comparing the dates and the months to make it work. opw-1915251 closes odoo/odoo#30538 --- .../src/js/bootstrap-datetimepicker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js b/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js index 19f261ff4fc..5acf922f59b 100644 --- a/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js +++ b/addons/web/static/lib/bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js @@ -723,6 +723,9 @@ } currentDate = viewDate.clone().startOf('M').startOf('w').startOf('d'); + // !! ODOO FIX START !! + var now = getMoment(); + // !! ODOO FIX END !! for (i = 0; i < 42; i++) { //always display 42 days (should show 6 weeks) if (currentDate.weekday() === 0) { @@ -745,7 +748,9 @@ if (!isValid(currentDate, 'd')) { clsNames.push('disabled'); } - if (currentDate.isSame(getMoment(), 'd')) { + // !! ODOO FIX START !! + if (currentDate.date() === now.date() && currentDate.month() === now.month() && currentDate.year() === now.year()) { + // !! ODOO FIX END !! clsNames.push('today'); } if (currentDate.day() === 0 || currentDate.day() === 6) {