Skip to content

Commit

Permalink
Merge 9b62c77 into 1734813
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Aug 29, 2019
2 parents 1734813 + 9b62c77 commit b5310c2
Show file tree
Hide file tree
Showing 23 changed files with 983 additions and 0 deletions.
1 change: 1 addition & 0 deletions oca_dependencies.txt
@@ -1 +1,2 @@
purchase-workflow
queue
112 changes: 112 additions & 0 deletions sale_order_invoicing_queued/README.rst
@@ -0,0 +1,112 @@
=============================
Enqueue sales order invoicing
=============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/11.0/sale_order_invoicing_queued
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-11-0/account-invoicing-11-0-sale_order_invoicing_queued
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/95/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to enqueue in several jobs the sales orders invoicing
process to be executed in paralell on background, that's it's normally done
serially and on foreground.

Jobs are split following the same criteria as standard Odoo: grouping by
order invoicing address and order currency.

**Table of contents**

.. contents::
:local:

Installation
============

This module depends on *queue_job* module that is hosted on
https://github.com/OCA/queue.

Configuration
=============

If you want to see queued jobs, you need "Job Queue / Job Queue Manager"
permission in your user.

Usage
=====

#. Go to *Sales > Invoicing > Orders to Invoice*.
#. Select sales orders whose invoicing you want to enqueue.
#. Click on *Action > Invoice Order*.
#. Click on "Enqueue Invoicing" button.
#. On that moment, jobs will be enqueued on foreground, but the control will
be returned to you after that.
#. Having the "Job Queue Manager" permissions, you can go to the sales order,
and see the tab "Invoicing Jobs". There a list with all the jobs related
to that sales order can be found.

Known issues / Roadmap
======================

* This module doesn't take into account any possible modification on grouping
criteria, like all the modules that uses
`sale_order_action_invoice_create_hook`.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20sale_order_invoicing_queued%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`__:

* Pedro M. Baeza

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/11.0/sale_order_invoicing_queued>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions sale_order_invoicing_queued/__init__.py
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import wizards
22 changes: 22 additions & 0 deletions sale_order_invoicing_queued/__manifest__.py
@@ -0,0 +1,22 @@
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Enqueue sales order invoicing',
'version': '11.0.1.0.0',
'category': 'Sales Management',
'license': 'AGPL-3',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/account-invoicing',
'depends': [
'sale',
'queue_job',
],
'data': [
'views/queue_job_views.xml',
'views/sale_order_views.xml',
'wizards/sale_advance_payment_inv_views.xml',
],
'installable': True,
}
58 changes: 58 additions & 0 deletions sale_order_invoicing_queued/i18n/es.po
@@ -0,0 +1,58 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_invoicing_queued
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-29 16:09+0000\n"
"PO-Revision-Date: 2019-08-29 16:09+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_order_invoicing_queued
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_queue_job_sale_order_invoicing
msgid "Cancel"
msgstr "Cancelar"

#. module: sale_order_invoicing_queued
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_sale_advance_payment_inv
msgid "Enqueue Invoicing"
msgstr "Encolar facturación"

#. module: sale_order_invoicing_queued
#: model:ir.model.fields,field_description:sale_order_invoicing_queued.field_sale_order_invoicing_job_ids
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_order_form
msgid "Invoicing Jobs"
msgstr "Trabajos de facturación"

#. module: sale_order_invoicing_queued
#: model:ir.model,name:sale_order_invoicing_queued.model_queue_job
msgid "Queue Job"
msgstr "Trabajo en cola"

#. module: sale_order_invoicing_queued
#: model:ir.model,name:sale_order_invoicing_queued.model_sale_order
msgid "Quotation"
msgstr "Presupuesto"

#. module: sale_order_invoicing_queued
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_queue_job_sale_order_invoicing
msgid "Requeue"
msgstr "Volver a poner en cola"

#. module: sale_order_invoicing_queued
#: model:ir.model,name:sale_order_invoicing_queued.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr "Ventas. Anticipo pago factura"

#. module: sale_order_invoicing_queued
#: code:addons/sale_order_invoicing_queued/wizards/sale_advance_payment_inv.py:26
#, python-format
msgid "There's already an enqueued job for invoicing the sales order %s. Please wait until it's finished or remove it from the selection."
msgstr "Ya existe un trabajo encolado para facturar el pedido de venta %s. Por favor espera hasta que haya terminado o elimine el pedido de la selección."
59 changes: 59 additions & 0 deletions sale_order_invoicing_queued/i18n/sale_order_invoicing_queued.pot
@@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_invoicing_queued
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-29 16:17+0000\n"
"PO-Revision-Date: 2019-08-29 16:17+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_order_invoicing_queued
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_queue_job_sale_order_invoicing
msgid "Cancel"
msgstr ""

#. module: sale_order_invoicing_queued
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_sale_advance_payment_inv
msgid "Enqueue Invoicing"
msgstr ""

#. module: sale_order_invoicing_queued
#: model:ir.model.fields,field_description:sale_order_invoicing_queued.field_sale_order_invoicing_job_ids
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_order_form
msgid "Invoicing Jobs"
msgstr ""

#. module: sale_order_invoicing_queued
#: model:ir.model,name:sale_order_invoicing_queued.model_queue_job
msgid "Queue Job"
msgstr ""

#. module: sale_order_invoicing_queued
#: model:ir.model,name:sale_order_invoicing_queued.model_sale_order
msgid "Quotation"
msgstr ""

#. module: sale_order_invoicing_queued
#: model:ir.ui.view,arch_db:sale_order_invoicing_queued.view_queue_job_sale_order_invoicing
msgid "Requeue"
msgstr ""

#. module: sale_order_invoicing_queued
#: model:ir.model,name:sale_order_invoicing_queued.model_sale_advance_payment_inv
msgid "Sales Advance Payment Invoice"
msgstr ""

#. module: sale_order_invoicing_queued
#: code:addons/sale_order_invoicing_queued/wizards/sale_advance_payment_inv.py:26
#, python-format
msgid "There's already an enqueued job for invoicing the sales order %s. Please wait until it's finished or remove it from the selection."
msgstr ""

4 changes: 4 additions & 0 deletions sale_order_invoicing_queued/models/__init__.py
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import queue_job
from . import sale_order
17 changes: 17 additions & 0 deletions sale_order_invoicing_queued/models/queue_job.py
@@ -0,0 +1,17 @@
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import models


class QueueJob(models.Model):
_inherit = 'queue.job'

def cancel_sudo(self):
self.sudo().filtered(
lambda x: x.state in ['pending', 'enqueued']
).unlink()

def requeue_sudo(self):
self.sudo().requeue()
32 changes: 32 additions & 0 deletions sale_order_invoicing_queued/models/sale_order.py
@@ -0,0 +1,32 @@
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models

try:
from odoo.addons.queue_job.job import job
except ImportError:
import logging
import functools

logging.getLogger().debug("Can't `import queue_job`.")

def empty_decorator_factory(*argv, **kwargs):
return functools.partial
job = empty_decorator_factory


class SaleOrder(models.Model):
_inherit = "sale.order"

invoicing_job_ids = fields.Many2many(
comodel_name='queue.job',
column1='invoice_id',
column2='job_id',
string="Invoicing Jobs",
copy=False,
)

@job(default_channel='root.sale_order_invoicing_queued')
def create_invoices_job(self, final):
self.action_invoice_create(final=final)
2 changes: 2 additions & 0 deletions sale_order_invoicing_queued/readme/CONFIGURE.rst
@@ -0,0 +1,2 @@
If you want to see queued jobs, you need "Job Queue / Job Queue Manager"
permission in your user.
3 changes: 3 additions & 0 deletions sale_order_invoicing_queued/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`__:

* Pedro M. Baeza
6 changes: 6 additions & 0 deletions sale_order_invoicing_queued/readme/DESCRIPTION.rst
@@ -0,0 +1,6 @@
This module allows to enqueue in several jobs the sales orders invoicing
process to be executed in paralell on background, that's it's normally done
serially and on foreground.

Jobs are split following the same criteria as standard Odoo: grouping by
order invoicing address and order currency.
2 changes: 2 additions & 0 deletions sale_order_invoicing_queued/readme/INSTALL.rst
@@ -0,0 +1,2 @@
This module depends on *queue_job* module that is hosted on
https://github.com/OCA/queue.
3 changes: 3 additions & 0 deletions sale_order_invoicing_queued/readme/ROADMAP.rst
@@ -0,0 +1,3 @@
* This module doesn't take into account any possible modification on grouping
criteria, like all the modules that uses
`sale_order_action_invoice_create_hook`.
9 changes: 9 additions & 0 deletions sale_order_invoicing_queued/readme/USAGE.rst
@@ -0,0 +1,9 @@
#. Go to *Sales > Invoicing > Orders to Invoice*.
#. Select sales orders whose invoicing you want to enqueue.
#. Click on *Action > Invoice Order*.
#. Click on "Enqueue Invoicing" button.
#. On that moment, jobs will be enqueued on foreground, but the control will
be returned to you after that.
#. Having the "Job Queue Manager" permissions, you can go to the sales order,
and see the tab "Invoicing Jobs". There a list with all the jobs related
to that sales order can be found.

0 comments on commit b5310c2

Please sign in to comment.