Files
odoo_source/addons/sale/__init__.py
T
Thibault Francois 2daa9a1673 [FIX] sale: send invoice only when ready to be send
Issues
------

In the module sale, with the automatic invoicing configured.
Payment transaction generate, post and send the invoice when
they are post process.

In some country the invoice is not directly ready to be sent
due to some edi document

Solution
--------

use the mechanism introduce with https://github.com/odoo/odoo/commit/3a29371eb70309f46e3b8938434287fefc23b351
to delay the sending. Introduce a cron that check invoice to send

closes odoo/odoo#81526

X-original-commit: 97b74d8304337d901d9422418cbd0dcdcc46fcf5
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-12-22 14:02:37 +00:00

19 lines
608 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import controllers
from . import report
from . import wizard
from . import populate
from odoo.api import Environment, SUPERUSER_ID
def _synchronize_cron(cr, registry):
env = Environment(cr, SUPERUSER_ID, {'active_test': False})
send_invoice_cron = env.ref('sale.send_invoice_cron', raise_if_not_found=False)
if send_invoice_cron:
config = env['ir.config_parameter'].get_param('sale.automatic_invoice', False)
send_invoice_cron.active = bool(config)