diff --git a/nfu_ecommerce/README.rst b/nfu_ecommerce/README.rst index e4754b0..0de0aae 100644 --- a/nfu_ecommerce/README.rst +++ b/nfu_ecommerce/README.rst @@ -22,10 +22,17 @@ NFU eCommerce |badge1| |badge2| |badge3| -This module adds a maximum order quantity field to Website Sale Orders. It also adds -an ordered qantitiy field to store the original ordered quantity in case a manager -adjustes the uom quantitiy. In webshop checkout it adds the customer balance to before -and after the current order. +This module adds + +- a maximum order quantity field to Website Sale Orders +- ordered qantitiy field to store the original ordered quantity in case a manager + adjustes the uom quantitiy + +In webshop checkout it adds + +- the customer balance to before and after the current order +- a configuration to warn when credit is low +- a possibility to only use credit for ordering **Table of contents** @@ -44,6 +51,7 @@ Changelog :1.3.0: Adapt new Open Packages format and add indicators :1.3.1: Remove Max Qty from first page :1.3.2: Add decimal to ribbon +:1.4.0: Add credit warning and avoid debts option Bug Tracker =========== diff --git a/nfu_ecommerce/__manifest__.py b/nfu_ecommerce/__manifest__.py index cdb369e..7c57cdc 100644 --- a/nfu_ecommerce/__manifest__.py +++ b/nfu_ecommerce/__manifest__.py @@ -4,7 +4,7 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "website", - "version": "16.0.1.3.2", + "version": "16.0.1.4.0", "depends": [ "sale_product_configurator", "website_sale", @@ -12,11 +12,14 @@ "website_decimal_quantity", "nfu_product_bnn_attributes", ], - "data": ["views/product_template_views.xml", "views/templates.xml"], + "data": [ + "views/res_config_settings_views.xml", + "views/product_template_views.xml", + "views/templates.xml", + ], "assets": { "web.assets_frontend": [ - "nfu_ecommerce/static/src/js/website_sale.js", - "nfu_ecommerce/static/src/js/sale_product_configurator.js", + "nfu_ecommerce/static/src/js/*.js", ] }, "license": "LGPL-3", diff --git a/nfu_ecommerce/i18n/de.po b/nfu_ecommerce/i18n/de.po index d53d1a0..7dfacb6 100644 --- a/nfu_ecommerce/i18n/de.po +++ b/nfu_ecommerce/i18n/de.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-04 19:54+0000\n" -"PO-Revision-Date: 2024-10-04 19:54+0000\n" +"POT-Creation-Date: 2025-07-24 18:34+0000\n" +"PO-Revision-Date: 2025-07-24 18:34+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -22,6 +22,7 @@ msgstr "Max Menge" #. module: nfu_ecommerce #: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging +#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.product_max_quantity_config msgid "Add one" msgstr "Einen hinzufügen" @@ -31,6 +32,12 @@ msgstr "Einen hinzufügen" msgid "All Products" msgstr "Alle Produkte" +#. module: nfu_ecommerce +#: model:ir.model.fields,field_description:nfu_ecommerce.field_res_config_settings__website_avoid_depts +#: model:ir.model.fields,field_description:nfu_ecommerce.field_website__avoid_depts +msgid "Avoid depths" +msgstr "Schulden verhindern" + #. module: nfu_ecommerce #: model:ir.model.fields,field_description:nfu_ecommerce.field_sale_order__balance msgid "Balance" @@ -42,10 +49,22 @@ msgid "Balance:" msgstr "Aktuelles Guthaben:" #. module: nfu_ecommerce -#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging -#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_summary_packaging -msgid "Max Ordered Quantity:" -msgstr "Max Menge" +#: model:ir.model,name:nfu_ecommerce.model_res_config_settings +msgid "Config Settings" +msgstr "Konfigurationseinstellungen" + +#. module: nfu_ecommerce +#: model:ir.model.fields,field_description:nfu_ecommerce.field_res_config_settings__website_credit_warning_level +#: model:ir.model.fields,field_description:nfu_ecommerce.field_website__credit_warning_level +#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.res_config_settings_view_form +msgid "Credit Warning" +msgstr "Guthabenwarnung" + +#. module: nfu_ecommerce +#: model:ir.model.fields,field_description:nfu_ecommerce.field_product_product__is_published +#: model:ir.model.fields,field_description:nfu_ecommerce.field_product_template__is_published +msgid "Is Published" +msgstr "Ist veröffentlicht" #. module: nfu_ecommerce #: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_summary_packaging @@ -57,17 +76,6 @@ msgstr "Max Menge:" msgid "New balance:" msgstr "Neues Guthaben:" -#. module: nfu_ecommerce -#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging -msgid "No open package available" -msgstr "Keine offenen Gebinde" - -#. module: nfu_ecommerce -#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging -#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_summary_packaging -msgid "Open Package:" -msgstr "Offenes Gebinde:" - #. module: nfu_ecommerce #: model_terms:ir.ui.view,arch_db:nfu_ecommerce.o_wsale_offcanvas #: model_terms:ir.ui.view,arch_db:nfu_ecommerce.products_open_packaging @@ -75,9 +83,14 @@ msgid "Open Packagings" msgstr "Offene Gebinde" #. module: nfu_ecommerce -#: model:ir.model.fields,field_description:nfu_ecommerce.field_sale_order_line__open_qty -msgid "Open Qty" -msgstr "Offene Menge" +#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging +msgid "Packaging Size:" +msgstr "Verpackungsgröße:" + +#. module: nfu_ecommerce +#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.res_config_settings_view_form +msgid "Prevent Customers from Ordering more than their Credit." +msgstr "Verhindere das Kunden mehr Kaufen als mit ihrem Guthaben möglich" #. module: nfu_ecommerce #: model:ir.model,name:nfu_ecommerce.model_product_template @@ -91,19 +104,20 @@ msgstr "Veröffentlichen" #. module: nfu_ecommerce #: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging +#: model_terms:ir.ui.view,arch_db:nfu_ecommerce.product_max_quantity_config msgid "Remove one" msgstr "Eins entfernen" +#. module: nfu_ecommerce +#: model:ir.model,name:nfu_ecommerce.model_sale_order_batch_product +msgid "Sale Order Batch Product" +msgstr "" + #. module: nfu_ecommerce #: model:ir.model,name:nfu_ecommerce.model_sale_order msgid "Sales Order" msgstr "Verkaufsauftrag" -#. module: nfu_ecommerce -#: model:ir.model,name:nfu_ecommerce.model_sale_order_line -msgid "Sales Order Line" -msgstr "Verkaufsauftragszeile" - #. module: nfu_ecommerce #: model_terms:ir.ui.view,arch_db:nfu_ecommerce.product_template_tree_view msgid "Unpublish on Website" @@ -118,3 +132,25 @@ msgstr "Zukünftiges Guthaben" #: model_terms:ir.ui.view,arch_db:nfu_ecommerce.cart_lines_packaging msgid "Warning" msgstr "Warnung" + +#. module: nfu_ecommerce +#: model:ir.model,name:nfu_ecommerce.model_website +msgid "Website" +msgstr "" + +#. module: nfu_ecommerce +#: model:ir.model.fields,help:nfu_ecommerce.field_res_config_settings__website_credit_warning_level +#: model:ir.model.fields,help:nfu_ecommerce.field_website__credit_warning_level +msgid "" +"When the credit of a customer is lower than the warning level the credit is " +"shown in red on the website." +msgstr "" +"Wenn das Guthaben niedriger ist als die Guthabenswarnung wird das Guthaben " +"auf der website in rot angezeigt." + +#. module: nfu_ecommerce +#. odoo-python +#: code:addons/nfu_ecommerce/models/sale_order.py:0 +#, python-format +msgid "You don't have enough credit." +msgstr "Du hast nicht genug Guthaben." diff --git a/nfu_ecommerce/models/__init__.py b/nfu_ecommerce/models/__init__.py index 8cd19eb..52e4b11 100644 --- a/nfu_ecommerce/models/__init__.py +++ b/nfu_ecommerce/models/__init__.py @@ -1,3 +1,5 @@ from . import product_template +from . import res_config_settings from . import sale_order from . import sale_order_batch_product +from . import website diff --git a/nfu_ecommerce/models/res_config_settings.py b/nfu_ecommerce/models/res_config_settings.py new file mode 100644 index 0000000..2c543cc --- /dev/null +++ b/nfu_ecommerce/models/res_config_settings.py @@ -0,0 +1,12 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + website_credit_warning_level = fields.Monetary( + related="website_id.credit_warning_level", readonly=False + ) + website_avoid_depts = fields.Boolean( + related="website_id.avoid_depts", readonly=False + ) diff --git a/nfu_ecommerce/models/sale_order.py b/nfu_ecommerce/models/sale_order.py index 668a344..f3f63bc 100644 --- a/nfu_ecommerce/models/sale_order.py +++ b/nfu_ecommerce/models/sale_order.py @@ -1,4 +1,5 @@ -from odoo import api, fields, models +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError class SaleOrder(models.Model): @@ -18,6 +19,14 @@ class SaleOrder(models.Model): order.amount_total / order.currency_rate ) + @api.constrains("amount_total") + def _check_amount_total(self): + for order in self: + if order.state != "draft" or not order.website_id: + continue + if order.website_id.avoid_depts and order.updated_balance < 0: + raise ValidationError(_("You don't have enough credit.")) + def _prepare_order_line_values( self, product_id, diff --git a/nfu_ecommerce/models/website.py b/nfu_ecommerce/models/website.py new file mode 100644 index 0000000..3ed6649 --- /dev/null +++ b/nfu_ecommerce/models/website.py @@ -0,0 +1,12 @@ +from odoo import fields, models + + +class Website(models.Model): + _inherit = "website" + + credit_warning_level = fields.Monetary( + string="Credit Warning", + readonly=False, + help="When the credit of a customer is lower than the warning level the credit is shown in red on the website.", + ) + avoid_depts = fields.Boolean(string="Avoid depths") diff --git a/nfu_ecommerce/readme/DESCRIPTION.rst b/nfu_ecommerce/readme/DESCRIPTION.rst index 93d25c8..3f11f32 100644 --- a/nfu_ecommerce/readme/DESCRIPTION.rst +++ b/nfu_ecommerce/readme/DESCRIPTION.rst @@ -1,4 +1,11 @@ -This module adds a maximum order quantity field to Website Sale Orders. It also adds -an ordered qantitiy field to store the original ordered quantity in case a manager -adjustes the uom quantitiy. In webshop checkout it adds the customer balance to before -and after the current order. \ No newline at end of file +This module adds + +- a maximum order quantity field to Website Sale Orders +- ordered qantitiy field to store the original ordered quantity in case a manager + adjustes the uom quantitiy + +In webshop checkout it adds + +- the customer balance to before and after the current order +- a configuration to warn when credit is low +- a possibility to only use credit for ordering \ No newline at end of file diff --git a/nfu_ecommerce/readme/HISTORY.rst b/nfu_ecommerce/readme/HISTORY.rst index ed5ed78..6682056 100644 --- a/nfu_ecommerce/readme/HISTORY.rst +++ b/nfu_ecommerce/readme/HISTORY.rst @@ -6,4 +6,5 @@ :1.2.0: Add Open Packages to Product list :1.3.0: Adapt new Open Packages format and add indicators :1.3.1: Remove Max Qty from first page -:1.3.2: Add decimal to ribbon \ No newline at end of file +:1.3.2: Add decimal to ribbon +:1.4.0: Add credit warning and avoid debts option \ No newline at end of file diff --git a/nfu_ecommerce/static/description/index.html b/nfu_ecommerce/static/description/index.html index 3378c3d..7a80701 100644 --- a/nfu_ecommerce/static/description/index.html +++ b/nfu_ecommerce/static/description/index.html @@ -370,10 +370,18 @@ ul.auto-toc { !! source digest: sha256:4dfaea54e4d01502b433eb5c0dcca409a5fbe2c3f175e29382a19230343183c9 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: LGPL-3 bruecksen/nfu

-

This module adds a maximum order quantity field to Website Sale Orders. It also adds -an ordered qantitiy field to store the original ordered quantity in case a manager -adjustes the uom quantitiy. In webshop checkout it adds the customer balance to before -and after the current order.

+

This module adds

+ +

In webshop checkout it adds

+

Table of contents

diff --git a/nfu_ecommerce/views/res_config_settings_views.xml b/nfu_ecommerce/views/res_config_settings_views.xml new file mode 100644 index 0000000..33b835a --- /dev/null +++ b/nfu_ecommerce/views/res_config_settings_views.xml @@ -0,0 +1,37 @@ + + + + res.config.settings.view.form.inherit.nfu.eccommerce + res.config.settings + + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
diff --git a/nfu_ecommerce/views/templates.xml b/nfu_ecommerce/views/templates.xml index 6a6b661..7d356df 100644 --- a/nfu_ecommerce/views/templates.xml +++ b/nfu_ecommerce/views/templates.xml @@ -264,7 +264,7 @@ @@ -275,22 +275,12 @@ New balance: - - - - - - + diff --git a/website_decimal_quantity/README.rst b/website_decimal_quantity/README.rst index 76bd763..e68645f 100644 --- a/website_decimal_quantity/README.rst +++ b/website_decimal_quantity/README.rst @@ -16,9 +16,9 @@ Website Decimal Quantity .. |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-bruecksen%2Fife_nfu-lightgray.png?logo=github - :target: https://github.com/bruecksen/ife_nfu/tree/16.0/website_decimal_quantity - :alt: bruecksen/ife_nfu +.. |badge3| image:: https://img.shields.io/badge/github-bruecksen%2Fnfu-lightgray.png?logo=github + :target: https://github.com/bruecksen/nfu/tree/16.0/website_decimal_quantity + :alt: bruecksen/nfu |badge1| |badge2| |badge3| @@ -39,10 +39,10 @@ Changelog Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +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 -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -64,6 +64,6 @@ Contributors Maintainers ~~~~~~~~~~~ -This module is part of the `bruecksen/ife_nfu `_ project on GitHub. +This module is part of the `bruecksen/nfu `_ project on GitHub. You are welcome to contribute. diff --git a/website_decimal_quantity/models/sale_order.py b/website_decimal_quantity/models/sale_order.py index 8b58b25..7bb4a1c 100644 --- a/website_decimal_quantity/models/sale_order.py +++ b/website_decimal_quantity/models/sale_order.py @@ -89,12 +89,12 @@ class SaleOrder(models.Model): set_qty = 0 quantity = 0 if set_qty: - quantity = set_qty + quantity = int(set_qty) elif add_qty is not None: if order_line: - quantity = order_line.product_uom_qty + (add_qty or 0) + quantity = order_line.product_uom_qty + (int(add_qty) or 0) else: - quantity = add_qty or 0 + quantity = int(add_qty) or 0 if quantity > 0: quantity, warning = self._verify_updated_quantity( order_line, product_id, quantity, **kwargs