-
-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_invoice_mode_daily: Automated daily invoicing
- Loading branch information
1 parent
651f73e
commit 0f93e8f
Showing
20 changed files
with
905 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
========================== | ||
Account Invoice Mode Daily | ||
========================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:3bbf4cdd991e33640adf8017d21632e0cf73728914ca09e747f998ba0b483395 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/14.0/account_invoice_mode_daily | ||
: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-14-0/account-invoicing-14-0-account_invoice_mode_daily | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to select a daily invoicing mode for a customer. | ||
It is based on `account_invoice_base_invoicing_mode`. | ||
When this mode is selected for a customer, the customer will be automatically | ||
invoiced | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
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 to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_mode_daily%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* MT Software | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Michael Tietz (MT Software) <[email protected]> | ||
|
||
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. | ||
|
||
.. |maintainer-mt-software-de| image:: https://github.com/mt-software-de.png?size=40px | ||
:target: https://github.com/mt-software-de | ||
:alt: mt-software-de | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-mt-software-de| | ||
|
||
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/14.0/account_invoice_mode_daily>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2022 manaTec GmbH | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Account Invoice Mode Daily", | ||
"version": "14.0.1.0.0", | ||
"summary": "Create invoices automatically on a daily basis.", | ||
"author": "MT Software, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/account-invoicing", | ||
"license": "AGPL-3", | ||
"category": "Accounting & Finance", | ||
"depends": [ | ||
"account_invoice_base_invoicing_mode", | ||
], | ||
"data": [ | ||
"data/ir_cron.xml", | ||
"data/queue_job_data.xml", | ||
"views/res_config_settings_views.xml", | ||
], | ||
"maintainers": ["mt-software-de"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo noupdate="1"> | ||
<record forcecreate="True" id="ir_cron_generate_daily_invoice" model="ir.cron"> | ||
<field name="name">Generate Daily Invoices</field> | ||
<field eval="True" name="active" /> | ||
<field name="user_id" ref="base.user_root" /> | ||
<field name="interval_number">1</field> | ||
<field name="interval_type">days</field> | ||
<field name="numbercall">-1</field> | ||
<field eval="False" name="doall" /> | ||
<field name="model_id" ref="model_sale_order" /> | ||
<field name="code">model.cron_generate_daily_invoices()</field> | ||
<field | ||
name="nextcall" | ||
eval="(DateTime.now().replace(hour=1,minute=0).strftime('%Y-%m-%d %H:%M:%S'))" | ||
/> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<!-- Queue Job Channel --> | ||
<record id="invoice_daily" model="queue.job.channel"> | ||
<field name="name">invoice_daily</field> | ||
<field name="parent_id" ref="queue_job.channel_root" /> | ||
</record> | ||
|
||
<!-- Queue Job Function --> | ||
<record id="job_function_generate_invoices_by_partner" model="queue.job.function"> | ||
<field name="model_id" ref="sale.model_sale_order" /> | ||
<field name="method">_generate_invoices_by_partner</field> | ||
<field name="channel_id" ref="invoice_daily" /> | ||
</record> | ||
</odoo> |
103 changes: 103 additions & 0 deletions
103
account_invoice_mode_daily/i18n/account_invoice_mode_daily.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_mode_daily | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \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: account_invoice_mode_daily | ||
#: model_terms:ir.ui.view,arch_db:account_invoice_mode_daily.res_config_settings_view_form | ||
msgid "<span class=\"o_form_label\">daily Invoicing Options</span>" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model,name:account_invoice_mode_daily.model_res_company | ||
msgid "Companies" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model,name:account_invoice_mode_daily.model_res_config_settings | ||
msgid "Config Settings" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model,name:account_invoice_mode_daily.model_res_partner | ||
msgid "Contact" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_company__display_name | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_config_settings__display_name | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_partner__display_name | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_sale_order__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.actions.server,name:account_invoice_mode_daily.ir_cron_generate_daily_invoice_ir_actions_server | ||
#: model:ir.cron,cron_name:account_invoice_mode_daily.ir_cron_generate_daily_invoice | ||
#: model:ir.cron,name:account_invoice_mode_daily.ir_cron_generate_daily_invoice | ||
msgid "Generate daily Invoices" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_company__id | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_config_settings__id | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_partner__id | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_sale_order__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_partner__invoicing_mode | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_users__invoicing_mode | ||
msgid "Invoicing Mode" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model_terms:ir.ui.view,arch_db:account_invoice_mode_daily.res_config_settings_view_form | ||
msgid "Invoicing daily" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_company____last_update | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_config_settings____last_update | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_partner____last_update | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_sale_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model_terms:ir.ui.view,arch_db:account_invoice_mode_daily.res_config_settings_view_form | ||
msgid "Last executed on" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model.fields,help:account_invoice_mode_daily.field_res_company__invoicing_mode_daily_last_execution | ||
#: model:ir.model.fields,help:account_invoice_mode_daily.field_res_config_settings__invoicing_mode_daily_last_execution | ||
msgid "Last execution of daily invoicing." | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model,name:account_invoice_mode_daily.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model.fields.selection,name:account_invoice_mode_daily.selection__res_partner__invoicing_mode__daily | ||
msgid "Daily" | ||
msgstr "" | ||
|
||
#. module: account_invoice_mode_daily | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_company__invoicing_mode_daily_last_execution | ||
#: model:ir.model.fields,field_description:account_invoice_mode_daily.field_res_config_settings__invoicing_mode_daily_last_execution | ||
msgid "daily last execution" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from . import res_company | ||
from . import res_config_settings | ||
from . import res_partner | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
invoicing_mode_daily_last_execution = fields.Datetime( | ||
string="Daily last execution", | ||
help="Last execution of daily invoice/refunds creation.", | ||
readonly=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
invoicing_mode_daily_last_execution = fields.Datetime( | ||
related="company_id.invoicing_mode_daily_last_execution", | ||
readonly=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2022 manaTec GmbH | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
invoicing_mode = fields.Selection( | ||
selection_add=[("daily", "Daily")], | ||
ondelete={"daily": "set default"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
from datetime import datetime, timedelta | ||
|
||
from odoo import api, models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
@api.model | ||
def cron_generate_daily_invoices(self): | ||
"""Cron called daily to check if daily invoicing needs to be done.""" | ||
company_ids = self._company_daily_invoicing() | ||
if company_ids: | ||
self.generate_daily_invoices(company_ids) | ||
|
||
@api.model | ||
def generate_daily_invoices(self, company_ids): | ||
"""Generate daily invoices for customers who require that mode. | ||
Invoices will be generated by other jobs split for different customer | ||
and different payment term. | ||
""" | ||
return self.generate_invoices_by_invoice_mode( | ||
company_ids, | ||
"daily", | ||
self._get_groupby_fields_for_daily_invoicing(), | ||
"invoicing_mode_daily_last_execution", | ||
) | ||
|
||
@api.model | ||
def _company_daily_invoicing(self): | ||
"""Get company ids for which today is daily invoicing day.""" | ||
last_max_date = datetime.now() - timedelta(days=1) | ||
domain = [ | ||
"|", | ||
("invoicing_mode_daily_last_execution", "<=", last_max_date), | ||
("invoicing_mode_daily_last_execution", "=", False), | ||
] | ||
return self.env["res.company"].search(domain) | ||
|
||
@api.model | ||
def _get_groupby_fields_for_daily_invoicing(self): | ||
"""Returns the sale order fields used to group them into jobs.""" | ||
return ["partner_invoice_id", "payment_term_id"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Michael Tietz (MT Software) <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This module allows to select a daily invoicing mode for a customer. | ||
It is based on `account_invoice_base_invoicing_mode`. | ||
When this mode is selected for a customer, the customer will be automatically | ||
invoiced |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.