From 32900a491f33afb30557469586151300e6737e34 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Wed, 30 Oct 2024 16:41:18 +0100 Subject: [PATCH] [IMP] add invoice by default pos setting --- pos_auto_invoice/README.rst | 12 ++++++- pos_auto_invoice/__init__.py | 5 +++ pos_auto_invoice/__manifest__.py | 6 ++-- pos_auto_invoice/models/__init__.py | 6 ++++ pos_auto_invoice/models/pos_config.py | 11 +++++++ .../models/res_config_settings.py | 14 +++++++++ pos_auto_invoice/readme/CONFIGURE.rst | 5 +++ pos_auto_invoice/readme/CONTRIBUTORS.rst | 1 + pos_auto_invoice/readme/DESCRIPTION.rst | 2 +- .../static/description/index.html | 31 ++++++++++++------- pos_auto_invoice/static/src/js/models.js | 4 ++- .../views/res_config_settings_view.xml | 30 ++++++++++++++++++ 12 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 pos_auto_invoice/models/__init__.py create mode 100644 pos_auto_invoice/models/pos_config.py create mode 100644 pos_auto_invoice/models/res_config_settings.py create mode 100644 pos_auto_invoice/readme/CONFIGURE.rst create mode 100644 pos_auto_invoice/views/res_config_settings_view.xml diff --git a/pos_auto_invoice/README.rst b/pos_auto_invoice/README.rst index 7705a283f8..232d6f71e6 100644 --- a/pos_auto_invoice/README.rst +++ b/pos_auto_invoice/README.rst @@ -28,13 +28,22 @@ Point of Sale Automatically Invoice |badge1| |badge2| |badge3| |badge4| |badge5| -In the POS, set orders as to-invoice by default. +Allow to set point-of-sale orders as to-invoice by default. **Table of contents** .. contents:: :local: +Configuration +============= + +This module adds an “Invoice By Default” option to the Accounting section of +the Point of Sale settings. + +To set orders as to-invoice by default, check the “Invoice By Default” +checkbox. + Bug Tracker =========== @@ -59,6 +68,7 @@ Contributors * `Coop IT Easy SC `_: * Carmen Bianca Bakker + * hugues de keyzer Maintainers ~~~~~~~~~~~ diff --git a/pos_auto_invoice/__init__.py b/pos_auto_invoice/__init__.py index e69de29bb2..3eb78877c5 100644 --- a/pos_auto_invoice/__init__.py +++ b/pos_auto_invoice/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import models diff --git a/pos_auto_invoice/__manifest__.py b/pos_auto_invoice/__manifest__.py index f3cafb7f6e..be570e1341 100644 --- a/pos_auto_invoice/__manifest__.py +++ b/pos_auto_invoice/__manifest__.py @@ -3,8 +3,7 @@ { "name": "Point of Sale Automatically Invoice", - "summary": """ - In the POS, set orders as to-invoice by default.""", + "summary": "Allow to set POS orders as to-invoice by default", "version": "16.0.1.0.0", "category": "Point of Sale", "website": "https://github.com/OCA/pos", @@ -13,6 +12,9 @@ "depends": [ "point_of_sale", ], + "data": [ + "views/res_config_settings_view.xml", + ], "assets": { "point_of_sale.assets": [ "pos_auto_invoice/static/src/js/*.js", diff --git a/pos_auto_invoice/models/__init__.py b/pos_auto_invoice/models/__init__.py new file mode 100644 index 0000000000..7133ebc21e --- /dev/null +++ b/pos_auto_invoice/models/__init__.py @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import pos_config +from . import res_config_settings diff --git a/pos_auto_invoice/models/pos_config.py b/pos_auto_invoice/models/pos_config.py new file mode 100644 index 0000000000..b69db852eb --- /dev/null +++ b/pos_auto_invoice/models/pos_config.py @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + invoice_by_default = fields.Boolean() diff --git a/pos_auto_invoice/models/res_config_settings.py b/pos_auto_invoice/models/res_config_settings.py new file mode 100644 index 0000000000..f0f8e611f6 --- /dev/null +++ b/pos_auto_invoice/models/res_config_settings.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_invoice_by_default = fields.Boolean( + related="pos_config_id.invoice_by_default", + readonly=False, + ) diff --git a/pos_auto_invoice/readme/CONFIGURE.rst b/pos_auto_invoice/readme/CONFIGURE.rst new file mode 100644 index 0000000000..03cf5260b3 --- /dev/null +++ b/pos_auto_invoice/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ +This module adds an “Invoice By Default” option to the Accounting section of +the Point of Sale settings. + +To set orders as to-invoice by default, check the “Invoice By Default” +checkbox. diff --git a/pos_auto_invoice/readme/CONTRIBUTORS.rst b/pos_auto_invoice/readme/CONTRIBUTORS.rst index d64451edcf..26771b9d22 100644 --- a/pos_auto_invoice/readme/CONTRIBUTORS.rst +++ b/pos_auto_invoice/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * `Coop IT Easy SC `_: * Carmen Bianca Bakker + * hugues de keyzer diff --git a/pos_auto_invoice/readme/DESCRIPTION.rst b/pos_auto_invoice/readme/DESCRIPTION.rst index d3aba973c5..448aad1f2a 100644 --- a/pos_auto_invoice/readme/DESCRIPTION.rst +++ b/pos_auto_invoice/readme/DESCRIPTION.rst @@ -1 +1 @@ -In the POS, set orders as to-invoice by default. +Allow to set point-of-sale orders as to-invoice by default. diff --git a/pos_auto_invoice/static/description/index.html b/pos_auto_invoice/static/description/index.html index 2990bd97d5..d66452506e 100644 --- a/pos_auto_invoice/static/description/index.html +++ b/pos_auto_invoice/static/description/index.html @@ -369,21 +369,29 @@

Point of Sale Automatically Invoice

!! source digest: sha256:2886f37cd3bd20fc08a85145afe135699467c5b843c9e82d99d523c3a34b5d6c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

-

In the POS, set orders as to-invoice by default.

+

Allow to set point-of-sale orders as to-invoice by default.

Table of contents

+
+

Configuration

+

This module adds an “Invoice By Default” option to the Accounting section of +the Point of Sale settings.

+

To set orders as to-invoice by default, check the “Invoice By Default” +checkbox.

+
-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub 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 @@ -391,24 +399,25 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Coop IT Easy SC
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose diff --git a/pos_auto_invoice/static/src/js/models.js b/pos_auto_invoice/static/src/js/models.js index 336eb01ad7..026d8718d4 100644 --- a/pos_auto_invoice/static/src/js/models.js +++ b/pos_auto_invoice/static/src/js/models.js @@ -10,7 +10,9 @@ odoo.define("pos_auto_invoice.models", function (require) { class AutoInvoiceOrder extends Order { constructor() { super(...arguments); - this.to_invoice = true; + if (this.pos.config.invoice_by_default) { + this.to_invoice = true; + } } }; diff --git a/pos_auto_invoice/views/res_config_settings_view.xml b/pos_auto_invoice/views/res_config_settings_view.xml new file mode 100644 index 0000000000..7b26e0b026 --- /dev/null +++ b/pos_auto_invoice/views/res_config_settings_view.xml @@ -0,0 +1,30 @@ + + + + + + res.config.settings.view.form + res.config.settings + + + +

+
+ +
+
+
+
+ + + + +