Skip to content

Commit

Permalink
[MERGE] Forward port of saas-15 to 11.0 up to 1d9f64c
Browse files Browse the repository at this point in the history
closes odoo#34868

Signed-off-by: Martin Trigaux (mat) <[email protected]>
  • Loading branch information
mart-e committed Jul 15, 2019
2 parents 2c896f8 + 1d9f64c commit d5dd136
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions addons/account/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,8 @@ def _prepare_refund(self, invoice, date_invoice=None, date=None, description=Non

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
Expand Down
19 changes: 15 additions & 4 deletions addons/l10n_be_intrastat/wizard/xml_decl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import base64
from xml.etree import ElementTree as ET
from collections import namedtuple
from functools import partial

from odoo import api, exceptions, fields, models, _
from odoo.tools.pycompat import text_type
from odoo.tools import float_round, float_is_zero

INTRASTAT_XMLNS = 'http://www.onegate.eu/2010-01-01'

Expand Down Expand Up @@ -103,7 +105,16 @@ def create_xml(self):
'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', text_type(numlgn))
self._set_Dim(item, 'EXTRF', text_type(linekey.EXTRF))
self._set_Dim(item, 'EXCNT', text_type(linekey.EXCNT))
Expand All @@ -113,9 +124,9 @@ def _build_intrastat_line(self, numlgn, item, linekey, amounts, dispatchmode, ex
if extendedmode:
self._set_Dim(item, 'EXTPC', text_type(linekey.EXTPC))
self._set_Dim(item, 'EXDELTRM', text_type(linekey.EXDELTRM))
self._set_Dim(item, 'EXTXVAL', text_type(round(amounts[0], 0)).replace(".", ","))
self._set_Dim(item, 'EXWEIGHT', text_type(round(amounts[1], 0)).replace(".", ","))
self._set_Dim(item, 'EXUNITS', text_type(round(amounts[2], 0)).replace(".", ","))
self._set_Dim(item, 'EXTXVAL', text_type(_round(amounts[0], 0)).replace(".", ","))
self._set_Dim(item, 'EXWEIGHT', text_type(_round(amounts[1], 0)).replace(".", ","))
self._set_Dim(item, 'EXUNITS', text_type(_round(amounts[2], 0)).replace(".", ","))

def _get_intrastat_linekey(self, declcode, inv_line, dispatchmode, extendedmode):
IntrastatRegion = self.env['l10n_be_intrastat.region']
Expand Down Expand Up @@ -297,7 +308,7 @@ def _get_lines(self, dispatchmode=False, extendedmode=False):
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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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:
Expand Down
2 changes: 1 addition & 1 deletion addons/payment/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def confirm(self, **kw):
tx_id = int(kw.get('tx_id', 0)) or request.session.pop('website_payment_tx_id', 0)
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':
Expand Down
3 changes: 3 additions & 0 deletions addons/website_sale/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ def values_postprocess(self, order, mode, values, errors, error_msg):
new_values['team_id'] = request.website.salesteam_id and request.website.salesteam_id.id
new_values['user_id'] = request.website.salesperson_id and request.website.salesperson_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
Expand Down
2 changes: 1 addition & 1 deletion addons/website_sale/models/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def sale_get_order(self, force_create=False, code=None, update_pricelist=False,
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
Expand Down

0 comments on commit d5dd136

Please sign in to comment.