[FIX] l10n_sa_edi: fix discrepencies in invoice date checks
When trying to process invoices at a time close to Midnight, and the user is using the system from a location different from the hosting location of Odoo, the system tries to check that the date of the invoice is the same as the current date of the system. This creates problems when the hosting server's timezone is different than that of the user. For example: If the hosting location is in Middle East (India), and the user is using Odoo from Saudi Arabia, there is a difference of 2.5 hours due to the timezone, so when the system creates the Invoice at 11 PM and tries to check the date, the date of the server is actually 29th of February, 11 PM while the date on the user's machine is 1st of March, 01:30 AM, which triggers a UserError from the _check_move_configuration function. closes odoo/odoo#157144 X-original-commit: 601c8b8a0b4aff44811fd37f365cc62205cf96f0 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Florian Gilbert (flg) <flg@odoo.com> Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import json
|
||||
from hashlib import sha256
|
||||
from base64 import b64decode, b64encode
|
||||
from lxml import etree
|
||||
from datetime import date, datetime
|
||||
from datetime import datetime
|
||||
from odoo import models, fields, _, api
|
||||
from odoo.exceptions import UserError
|
||||
from cryptography.hazmat.primitives.serialization import load_pem_private_key
|
||||
@@ -435,7 +435,7 @@ class AccountEdiFormat(models.Model):
|
||||
errors.append(_set_missing_partner_fields(supplier_missing_info, _("Supplier")))
|
||||
if customer_missing_info:
|
||||
errors.append(_set_missing_partner_fields(customer_missing_info, _("Customer")))
|
||||
if invoice.invoice_date > date.today():
|
||||
if invoice.invoice_date > fields.Date.context_today(self.with_context(tz='Asia/Riyadh')):
|
||||
errors.append(_("- Please, make sure the invoice date is set to either the same as or before Today."))
|
||||
if invoice.move_type in ('in_refund', 'out_refund') and not invoice._l10n_sa_check_refund_reason():
|
||||
errors.append(
|
||||
|
||||
Reference in New Issue
Block a user