diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 69e34556ddc..f5f7ffb008a 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1082,6 +1082,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 diff --git a/addons/l10n_be_intrastat/wizard/xml_decl.py b/addons/l10n_be_intrastat/wizard/xml_decl.py index 25f587f3980..8cadb3d094d 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: diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index f0a8e3abbb9..74f779667f1 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -534,6 +534,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 diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index e29256f0c37..5a500879bdb 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -461,7 +461,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