From 06d149a3b1c59594d776e418658e7b5db043a7d2 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 9 Jul 2019 13:03:45 +0000 Subject: [PATCH 1/5] [FIX] l10n_be_intrastat, _2019: support rounding to 2 decimals Before this commit, values were rounded to the unit, which was part of the former specs of the Intrastat report After this commit, we make the intrastat 2019 comply with the new spec, which is to round value, price and weight to two decimals See the spec here: https://www.nbb.be/doc/dq/f_pdf_ex/nieuwsbriefintrastat_n28_2018_fr.pdf OPW 2031682 closes odoo/odoo#34700 Signed-off-by: Lucas Perais (lpe) --- addons/l10n_be_intrastat/wizard/xml_decl.py | 19 +++++++++++++++---- .../models/account_intrastat_report.py | 9 +++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/addons/l10n_be_intrastat/wizard/xml_decl.py b/addons/l10n_be_intrastat/wizard/xml_decl.py index 6d07562acde..d6ca134aa97 100644 --- a/addons/l10n_be_intrastat/wizard/xml_decl.py +++ b/addons/l10n_be_intrastat/wizard/xml_decl.py @@ -4,8 +4,10 @@ import base64 import xml.etree.ElementTree as ET from collections import namedtuple +from functools import partial from odoo import api, exceptions, fields, models, _ +from odoo.tools import float_round, float_is_zero INTRASTAT_XMLNS = 'http://www.onegate.eu/2010-01-01' @@ -102,7 +104,16 @@ class XmlDeclaration(models.TransientModel): 'res_id': self.id, } + def _get_rounding_digits(self): + """A hook to not break behavior + Allows to programmatically set with what precision + the price, weight and values will be rounded""" + return 0 + def _build_intrastat_line(self, numlgn, item, linekey, amounts, dispatchmode, extendedmode): + round_digits = self._get_rounding_digits() + _round = partial(float_round, precision_digits=round_digits) + self._set_Dim(item, 'EXSEQCODE', unicode(numlgn)) self._set_Dim(item, 'EXTRF', unicode(linekey.EXTRF)) self._set_Dim(item, 'EXCNT', unicode(linekey.EXCNT)) @@ -112,9 +123,9 @@ class XmlDeclaration(models.TransientModel): if extendedmode: self._set_Dim(item, 'EXTPC', unicode(linekey.EXTPC)) self._set_Dim(item, 'EXDELTRM', unicode(linekey.EXDELTRM)) - self._set_Dim(item, 'EXTXVAL', unicode(round(amounts[0], 0)).replace(".", ",")) - self._set_Dim(item, 'EXWEIGHT', unicode(round(amounts[1], 0)).replace(".", ",")) - self._set_Dim(item, 'EXUNITS', unicode(round(amounts[2], 0)).replace(".", ",")) + self._set_Dim(item, 'EXTXVAL', unicode(_round(amounts[0])).replace(".", ",")) + self._set_Dim(item, 'EXWEIGHT', unicode(_round(amounts[1])).replace(".", ",")) + self._set_Dim(item, 'EXUNITS', unicode(_round(amounts[2])).replace(".", ",")) def _get_intrastat_linekey(self, declcode, inv_line, dispatchmode, extendedmode): IntrastatRegion = self.env['l10n_be_intrastat.region'] @@ -296,7 +307,7 @@ class XmlDeclaration(models.TransientModel): numlgn = 0 for linekey in entries: amounts = entries[linekey] - if round(amounts[0], 0) == 0: + if float_is_zero(amounts[0], precision_digits=self._get_rounding_digits()): continue numlgn += 1 item = ET.SubElement(datas, 'Item') diff --git a/addons/l10n_be_intrastat_2019/models/account_intrastat_report.py b/addons/l10n_be_intrastat_2019/models/account_intrastat_report.py index 2a091901a26..10bbf79494c 100644 --- a/addons/l10n_be_intrastat_2019/models/account_intrastat_report.py +++ b/addons/l10n_be_intrastat_2019/models/account_intrastat_report.py @@ -11,6 +11,15 @@ class XmlDeclaration(models.TransientModel): """ _inherit = "l10n_be_intrastat_xml.xml_decl" + def _get_rounding_digits(self): + """ + @override + + https://www.nbb.be/doc/dq/f_pdf_ex/nieuwsbriefintrastat_n28_2018_fr.pdf + Chapter 3 + """ + return 2 + def _build_intrastat_line(self, numlgn, item, linekey, amounts, dispatchmode, extendedmode): super(XmlDeclaration, self)._build_intrastat_line(numlgn, item, linekey, amounts, dispatchmode, extendedmode) if dispatchmode: From 3360f9313dc308e28ccdfa5c3d35f3ba9685a53d Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Wed, 10 Jul 2019 10:00:36 +0200 Subject: [PATCH 2/5] [FIX] website_payment: consider authorized transactions as done Forward port of a8dfc7fb731dd6c34f55401d099ca1f72d796e9e Before this commit, when a transaction has as status 'authorized', the transactions' confirm page gives an error : 'Oops! There was a problem with your payment.' Now, the page gives the same message as when the transaction has the status 'done' : 'Your payment was successful! It may take some time to be validated on our end.' opw-1984325 --- addons/website_payment/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_payment/controllers/main.py b/addons/website_payment/controllers/main.py index 31244b87cda..101f057cc47 100644 --- a/addons/website_payment/controllers/main.py +++ b/addons/website_payment/controllers/main.py @@ -78,7 +78,7 @@ class WebsitePayment(http.Controller): tx_id = request.session.pop('website_payment_tx_id', False) if tx_id: tx = request.env['payment.transaction'].browse(tx_id) - if tx.state == 'done': + if tx.state in ['done', 'authorized']: status = 'success' message = tx.acquirer_id.done_msg elif tx.state == 'pending': From d24c1963972d4efc78d510512ccbe74ef5eac5f4 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 10 Jul 2019 09:34:20 +0000 Subject: [PATCH 3/5] [FIX] website_sale: don't handle pl promo code if already applied MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a pl promo code is applied, the code is shown in the promo code input. Before this commit, if the user clicked on "Apply" (so with the same code) it would remove the pl as it would go in the `if` condition that is supposed to handle empty code modo to reset pl. Coming from #34633 closes odoo/odoo#34734 Signed-off-by: Jérémy Kersten (jke) --- addons/website_sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 97e6a09a7a5..b56d7e24702 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -456,7 +456,7 @@ class Website(models.Model): if code_pricelist: pricelist_id = code_pricelist.id update_pricelist = True - elif code is not None and sale_order.pricelist_id.code: + elif code is not None and sale_order.pricelist_id.code and code != sale_order.pricelist_id.code: # code is not None when user removes code and click on "Apply" pricelist_id = partner.property_product_pricelist.id update_pricelist = True From 01c34a512c9563c35a35e68c999ce992d87cc492 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 19 Apr 2019 08:00:25 +0000 Subject: [PATCH 4/5] [FIX] website, website_sale: correctly set company_id on address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During checkout, the user can create a new billing (only for public user as it will create a 'normal' `res.partner`), a new shipping, edit its billing (that will edit himself) or edit its shipping address. All those cases will go through the exact same methods, public user and logged in user included. This previously led to multiple issues and multiple fixes to correctly set `company_id` and `website_id` on the address (res.partner). See 44372471ef that fixed the `website_id` part. See 3a0f05f33 that fixed the multi-company behavior, but needed 2ba71140 to not modify the company of an already created partner, but was still incomplete as after that fix a logged in user would still have the admin (sudo) company instead of the website one as supposed. This commit will fix that bug and add some tests for all mentionned issues. Fixes #28853 Backport from odoo/odoo#34596 closes odoo/odoo#34689 Signed-off-by: Jérémy Kersten (jke) --- addons/website_sale/controllers/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index c3c3c41c43f..a9fbe8bbed8 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -536,6 +536,9 @@ class WebsiteSale(http.Controller): new_values['customer'] = True new_values['team_id'] = request.website.salesteam_id and request.website.salesteam_id.id + if mode[0] == 'new': + new_values['company_id'] = request.website.company_id.id + lang = request.lang if request.lang in request.website.mapped('language_ids.code') else None if lang: new_values['lang'] = lang From bb712ad7017db9c6477ceb40633e2460238b3317 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 9 Jul 2019 11:47:08 +0000 Subject: [PATCH 5/5] [FIX] account: Incorrect due date for credit notes Steps to reproduce the bug: - Create an invoice I - Set the invoice date in the past and add payment terms - Validate I - Create refund from I Bug: The invoice date is set as today but the due date was set in the past. opw:2033438 closes odoo/odoo#34748 Signed-off-by: Simon Goffin (sig) --- addons/account/models/account_invoice.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 7de331f7742..48c6aa8c711 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1076,6 +1076,8 @@ class AccountInvoice(models.Model): values['type'] = TYPE2REFUND[invoice['type']] values['date_invoice'] = date_invoice or fields.Date.context_today(invoice) + if values.get('date_due', False) and values['date_invoice'] > values['date_due']: + values['date_due'] = values['date_invoice'] values['state'] = 'draft' values['number'] = False values['origin'] = invoice.number