diff --git a/nfu_sale_product_min_max_qty/README.rst b/nfu_ecommerce/README.rst similarity index 74% rename from nfu_sale_product_min_max_qty/README.rst rename to nfu_ecommerce/README.rst index 925bc7c..6eca94c 100644 --- a/nfu_sale_product_min_max_qty/README.rst +++ b/nfu_ecommerce/README.rst @@ -1,6 +1,6 @@ -========================== -NFU Sale Min Max Quantitiy -========================== +============= +NFU eCommerce +============= .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -17,12 +17,15 @@ NFU Sale Min Max Quantitiy :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-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/nfu_sale_product_min_max_qty + :target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_ecommerce :alt: bruecksen/ife_nfu |badge1| |badge2| |badge3| -This module adds a minium and a maximum order quantity field to Sale Orders and adds it to checkout of the website shop. +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. **Table of contents** @@ -32,7 +35,7 @@ This module adds a minium and a maximum order quantity field to Sale Orders and Changelog ========= -:1.0.0: Initial module. +:0.0.1: Initial module. Bug Tracker =========== @@ -40,7 +43,7 @@ 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 -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -61,6 +64,6 @@ Contributors Maintainers ~~~~~~~~~~~ -This module is part of the `bruecksen/ife_nfu `_ project on GitHub. +This module is part of the `bruecksen/ife_nfu `_ project on GitHub. You are welcome to contribute. diff --git a/nfu_sale_product_min_max_qty/__init__.py b/nfu_ecommerce/__init__.py similarity index 69% rename from nfu_sale_product_min_max_qty/__init__.py rename to nfu_ecommerce/__init__.py index 48d9904..f7209b1 100644 --- a/nfu_sale_product_min_max_qty/__init__.py +++ b/nfu_ecommerce/__init__.py @@ -1,3 +1,2 @@ from . import models from . import controllers -from . import wizard diff --git a/nfu_ecommerce/__manifest__.py b/nfu_ecommerce/__manifest__.py new file mode 100644 index 0000000..74cfd89 --- /dev/null +++ b/nfu_ecommerce/__manifest__.py @@ -0,0 +1,12 @@ +{ + "name": "NFU eCommerce", + "summary": "Qty ranges, packagings and credit in webshop", + "author": "BAKEUP", + "website": "https://www.bakeup.org", + "category": "website", + "version": "16.0.0.0.1", + "depends": ["website_sale", "nfu_sale_order_batch_packaging"], + "data": ["views/templates.xml"], + "assets": {"web.assets_frontend": ["nfu_ecommerce/static/src/js/website_sale.js"]}, + "license": "LGPL-3", +} diff --git a/nfu_ecommerce/controllers/__init__.py b/nfu_ecommerce/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/nfu_ecommerce/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/nfu_ecommerce/controllers/main.py b/nfu_ecommerce/controllers/main.py new file mode 100644 index 0000000..6f80ec1 --- /dev/null +++ b/nfu_ecommerce/controllers/main.py @@ -0,0 +1,12 @@ +from odoo import fields, http + +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteSaleMinMax(WebsiteSale): + @http.route() + def cart_update(self, *args, ordered_qty=None, max_qty=None, **kw): + """Override to get ordered_qty and max_qty from the product.""" + product_uom_ordered_qty = fields.Float(ordered_qty) + product_uom_max_qty = fields.Float(max_qty) + return super().cart_update(*args, ordered_qty=product_uom_ordered_qty, max_qty=product_uom_max_qty, **kw) diff --git a/nfu_ecommerce/models/__init__.py b/nfu_ecommerce/models/__init__.py new file mode 100644 index 0000000..6aacb75 --- /dev/null +++ b/nfu_ecommerce/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/nfu_ecommerce/models/sale_order.py b/nfu_ecommerce/models/sale_order.py new file mode 100644 index 0000000..9a9e6cd --- /dev/null +++ b/nfu_ecommerce/models/sale_order.py @@ -0,0 +1,49 @@ +from odoo import api, fields, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + balance = fields.Monetary(compute="_compute_balance") + updated_balance = fields.Monetary(compute="_compute_updated_balance") + + def _compute_balance(self): + for order in self: + order.balance = -order.partner_id.commercial_partner_id.credit + + @api.depends("amount_total") + def _compute_updated_balance(self): + for order in self: + order.updated_balance = order.balance - (order.amount_total / order.currency_rate) + + def _prepare_order_line_values( + self, + product_id, + quantity, + linked_line_id=False, + no_variant_attribute_values=None, + product_custom_attribute_values=None, + **kwargs + ): + values = super()._prepare_order_line_values( + product_id, + quantity, + linked_line_id=linked_line_id, + no_variant_attribute_values=no_variant_attribute_values, + product_custom_attribute_values=product_custom_attribute_values, + **kwargs + ) + values.update({"product_uom_ordered_qty": quantity, "product_uom_max_qty": kwargs.get("max_qty", quantity)}) + return values + + def _prepare_order_line_update_values(self, order_line, quantity, linked_line_id=False, **kwargs): + values = super()._prepare_order_line_update_values( + order_line, quantity, linked_line_id=linked_line_id, **kwargs + ) + max_qty = kwargs.get("max_qty", quantity) + if quantity != order_line.product_uom_ordered_qty: + values["product_uom_ordered_qty"] = quantity + if max_qty and max_qty != order_line.product_uom_max_qty: + values["product_uom_max_qty"] = max_qty + + return values diff --git a/nfu_sale_order_packaging/readme/CONTRIBUTORS.rst b/nfu_ecommerce/readme/CONTRIBUTORS.rst similarity index 100% rename from nfu_sale_order_packaging/readme/CONTRIBUTORS.rst rename to nfu_ecommerce/readme/CONTRIBUTORS.rst diff --git a/nfu_ecommerce/readme/DESCRIPTION.rst b/nfu_ecommerce/readme/DESCRIPTION.rst new file mode 100644 index 0000000..93d25c8 --- /dev/null +++ b/nfu_ecommerce/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +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 diff --git a/nfu_ecommerce/readme/HISTORY.rst b/nfu_ecommerce/readme/HISTORY.rst new file mode 100644 index 0000000..e986fe7 --- /dev/null +++ b/nfu_ecommerce/readme/HISTORY.rst @@ -0,0 +1 @@ +:0.0.1: Initial module. \ No newline at end of file diff --git a/nfu_sale_order_packaging/static/description/icon.png b/nfu_ecommerce/static/description/icon.png similarity index 100% rename from nfu_sale_order_packaging/static/description/icon.png rename to nfu_ecommerce/static/description/icon.png diff --git a/nfu_sale_product_min_max_qty/static/description/index.html b/nfu_ecommerce/static/description/index.html similarity index 92% rename from nfu_sale_product_min_max_qty/static/description/index.html rename to nfu_ecommerce/static/description/index.html index 4ab2ef6..1beceae 100644 --- a/nfu_sale_product_min_max_qty/static/description/index.html +++ b/nfu_ecommerce/static/description/index.html @@ -3,7 +3,7 @@ -NFU Sale Min Max Quantitiy +NFU eCommerce -
-

NFU Sale Min Max Quantitiy

+
+

NFU eCommerce

-

Beta License: LGPL-3 bruecksen/ife_nfu

-

This module adds a minium and a maximum order quantity field to Sale Orders and adds it to checkout of the website shop.

+

Beta License: LGPL-3 bruecksen/ife_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.

Table of contents

    @@ -390,7 +393,7 @@ ul.auto-toc { -1.0.0:Initial module. +0.0.1:Initial module. @@ -400,7 +403,7 @@ ul.auto-toc {

    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.

@@ -420,7 +423,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

Maintainers

-

This module is part of the bruecksen/ife_nfu project on GitHub.

+

This module is part of the bruecksen/ife_nfu project on GitHub.

You are welcome to contribute.

diff --git a/nfu_sale_product_min_max_qty/static/src/js/website_sale.js b/nfu_ecommerce/static/src/js/website_sale.js similarity index 68% rename from nfu_sale_product_min_max_qty/static/src/js/website_sale.js rename to nfu_ecommerce/static/src/js/website_sale.js index bcb77dc..ed43992 100644 --- a/nfu_sale_product_min_max_qty/static/src/js/website_sale.js +++ b/nfu_ecommerce/static/src/js/website_sale.js @@ -1,36 +1,10 @@ -odoo.define("nfu_sale_product_min_max_qty.website_min_max_qty", function (require) { +odoo.define("nfu_ecommerce.website_max_qty", function (require) { "use strict"; var core = require("web.core"); - var _t = core._t; var wSaleUtils = require("website_sale.utils"); var publicWidget = require("web.public.widget"); require("website_sale.website_sale"); publicWidget.registry.WebsiteSale.include({ - onClickAddCartJSON: function (ev) { - ev.preventDefault(); - $(".css_quantity").popover("dispose"); - var $link = $(ev.currentTarget); - var $input = $link.closest(".input-group").find("input"); - var min = parseFloat($input.data("min") || 0); - var previousQty = parseFloat($input.val() || 0, 10); - var quantity = ($link.has(".fa-minus").length ? -1 : 1) + previousQty; - if (quantity < min) { - $input.closest(".css_quantity").popover({ - content: _t(`Minimum Quantity is ${min}.`), - title: _t("Warning"), - placement: "left", - trigger: "focus", - html: true, - }); - $input.closest(".css_quantity").popover("show"); - - setTimeout(function () { - $(".css_quantity").popover("dispose"); - }, 3000); - } - this._super(ev); - }, - /** * Adds the max qty to the POST request when adding a product to the cart. * @override diff --git a/nfu_ecommerce/views/templates.xml b/nfu_ecommerce/views/templates.xml new file mode 100644 index 0000000..16047a3 --- /dev/null +++ b/nfu_ecommerce/views/templates.xml @@ -0,0 +1,125 @@ + + + + + + diff --git a/nfu_sale_order_packaging/README.rst b/nfu_sale_order_batch_packaging/README.rst similarity index 80% rename from nfu_sale_order_packaging/README.rst rename to nfu_sale_order_batch_packaging/README.rst index c9230a0..08329e7 100644 --- a/nfu_sale_order_packaging/README.rst +++ b/nfu_sale_order_batch_packaging/README.rst @@ -1,6 +1,6 @@ -======================== -NFU Sale Order Packaging -======================== +============================== +NFU Sale Order Batch Packaging +============================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -17,7 +17,7 @@ NFU Sale Order Packaging :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-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/nfu_sale_order_packaging + :target: https://github.com/bruecksen/ife_nfu/tree/16.0/nfu_sale_order_batch_packaging :alt: bruecksen/ife_nfu |badge1| |badge2| |badge3| @@ -33,7 +33,8 @@ and adds a packaging default to sale order batch. Changelog ========= -:1.0.0: Initial module. +:0.0.1: Initial module. +:1.0.0: rename to nfu_sale_order_batch_packaging Bug Tracker =========== @@ -41,7 +42,7 @@ 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 -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -62,6 +63,6 @@ Contributors Maintainers ~~~~~~~~~~~ -This module is part of the `bruecksen/ife_nfu `_ project on GitHub. +This module is part of the `bruecksen/ife_nfu `_ project on GitHub. You are welcome to contribute. diff --git a/nfu_sale_order_packaging/__init__.py b/nfu_sale_order_batch_packaging/__init__.py similarity index 100% rename from nfu_sale_order_packaging/__init__.py rename to nfu_sale_order_batch_packaging/__init__.py diff --git a/nfu_sale_order_packaging/__manifest__.py b/nfu_sale_order_batch_packaging/__manifest__.py similarity index 75% rename from nfu_sale_order_packaging/__manifest__.py rename to nfu_sale_order_batch_packaging/__manifest__.py index 9449913..a2258d4 100644 --- a/nfu_sale_order_packaging/__manifest__.py +++ b/nfu_sale_order_batch_packaging/__manifest__.py @@ -1,10 +1,10 @@ { - "name": "NFU Sale Order Packaging", - "summary": "Add minimum and maximum order quantities to sale orders and use default packaging", + "name": "NFU Sale Order Batch Packaging", + "summary": "Add minimum and maximum order quantities to sale orders and batches and use default packaging", "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "Sale", - "version": "16.0.0.0.1", + "version": "16.0.1.0.0", "depends": ["sale", "sale_order_batch"], "data": [ "views/sale_order_views.xml", diff --git a/nfu_sale_order_packaging/models/__init__.py b/nfu_sale_order_batch_packaging/models/__init__.py similarity index 100% rename from nfu_sale_order_packaging/models/__init__.py rename to nfu_sale_order_batch_packaging/models/__init__.py diff --git a/nfu_sale_order_packaging/models/sale_order_batch_product.py b/nfu_sale_order_batch_packaging/models/sale_order_batch_product.py similarity index 100% rename from nfu_sale_order_packaging/models/sale_order_batch_product.py rename to nfu_sale_order_batch_packaging/models/sale_order_batch_product.py diff --git a/nfu_sale_order_packaging/models/sale_order_line.py b/nfu_sale_order_batch_packaging/models/sale_order_line.py similarity index 100% rename from nfu_sale_order_packaging/models/sale_order_line.py rename to nfu_sale_order_batch_packaging/models/sale_order_line.py diff --git a/nfu_sale_product_min_max_qty/readme/CONTRIBUTORS.rst b/nfu_sale_order_batch_packaging/readme/CONTRIBUTORS.rst similarity index 100% rename from nfu_sale_product_min_max_qty/readme/CONTRIBUTORS.rst rename to nfu_sale_order_batch_packaging/readme/CONTRIBUTORS.rst diff --git a/nfu_sale_order_packaging/readme/DESCRIPTION.rst b/nfu_sale_order_batch_packaging/readme/DESCRIPTION.rst similarity index 100% rename from nfu_sale_order_packaging/readme/DESCRIPTION.rst rename to nfu_sale_order_batch_packaging/readme/DESCRIPTION.rst diff --git a/nfu_sale_order_batch_packaging/readme/HISTORY.rst b/nfu_sale_order_batch_packaging/readme/HISTORY.rst new file mode 100644 index 0000000..ce67226 --- /dev/null +++ b/nfu_sale_order_batch_packaging/readme/HISTORY.rst @@ -0,0 +1,2 @@ +:0.0.1: Initial module. +:1.0.0: rename to nfu_sale_order_batch_packaging \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/static/description/icon.png b/nfu_sale_order_batch_packaging/static/description/icon.png similarity index 100% rename from nfu_sale_product_min_max_qty/static/description/icon.png rename to nfu_sale_order_batch_packaging/static/description/icon.png diff --git a/nfu_sale_order_packaging/static/description/index.html b/nfu_sale_order_batch_packaging/static/description/index.html similarity index 93% rename from nfu_sale_order_packaging/static/description/index.html rename to nfu_sale_order_batch_packaging/static/description/index.html index 36dab75..211bb0f 100644 --- a/nfu_sale_order_packaging/static/description/index.html +++ b/nfu_sale_order_batch_packaging/static/description/index.html @@ -3,7 +3,7 @@ -NFU Sale Order Packaging +NFU Sale Order Batch Packaging -
-

NFU Sale Order Packaging

+
+

NFU Sale Order Batch Packaging

-

Beta License: LGPL-3 bruecksen/ife_nfu

+

Beta License: LGPL-3 bruecksen/ife_nfu

This module adds a minium and a maximum order quantity field to Sale Orders and adds a packaging default to sale order batch.

Table of contents

@@ -391,7 +391,9 @@ and adds a packaging default to sale order batch.

-1.0.0:Initial module. +0.0.1:Initial module. + +1.0.0:rename to nfu_sale_order_batch_packaging @@ -401,7 +403,7 @@ and adds a packaging default to sale order batch.

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.

@@ -421,7 +423,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

Maintainers

-

This module is part of the bruecksen/ife_nfu project on GitHub.

+

This module is part of the bruecksen/ife_nfu project on GitHub.

You are welcome to contribute.

diff --git a/nfu_sale_order_packaging/views/sale_order_batch_product_views.xml b/nfu_sale_order_batch_packaging/views/sale_order_batch_product_views.xml similarity index 100% rename from nfu_sale_order_packaging/views/sale_order_batch_product_views.xml rename to nfu_sale_order_batch_packaging/views/sale_order_batch_product_views.xml diff --git a/nfu_sale_order_packaging/views/sale_order_batch_views.xml b/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml similarity index 100% rename from nfu_sale_order_packaging/views/sale_order_batch_views.xml rename to nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml diff --git a/nfu_sale_order_packaging/views/sale_order_views.xml b/nfu_sale_order_batch_packaging/views/sale_order_views.xml similarity index 100% rename from nfu_sale_order_packaging/views/sale_order_views.xml rename to nfu_sale_order_batch_packaging/views/sale_order_views.xml diff --git a/nfu_sale_order_packaging/readme/HISTORY.rst b/nfu_sale_order_packaging/readme/HISTORY.rst deleted file mode 100644 index 765ab9c..0000000 --- a/nfu_sale_order_packaging/readme/HISTORY.rst +++ /dev/null @@ -1 +0,0 @@ -:1.0.0: Initial module. \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/__manifest__.py b/nfu_sale_product_min_max_qty/__manifest__.py deleted file mode 100644 index 01a3732..0000000 --- a/nfu_sale_product_min_max_qty/__manifest__.py +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "NFU Sale Min Max Quantitiy", - "summary": "Add minimum and maximum order quantities to sale orders", - "author": "BAKEUP", - "website": "https://www.bakeup.org", - "category": "Stock", - "version": "16.0.0.0.1", - "depends": ["sale_management", "website_sale"], - "data": [ - "views/sale_order_views.xml", - "views/sale_order_line_views.xml", - "wizard/sale_max_qty_line_views.xml", - "wizard/sale_max_qty_chooser_views.xml", - "views/templates.xml", - "security/ir.model.access.csv", - ], - "assets": {"web.assets_frontend": ["nfu_sale_product_min_max_qty/static/src/js/website_sale.js"]}, - "license": "LGPL-3", -} diff --git a/nfu_sale_product_min_max_qty/controllers/__init__.py b/nfu_sale_product_min_max_qty/controllers/__init__.py deleted file mode 100644 index deec4a8..0000000 --- a/nfu_sale_product_min_max_qty/controllers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import main \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/controllers/main.py b/nfu_sale_product_min_max_qty/controllers/main.py deleted file mode 100644 index a8a56f5..0000000 --- a/nfu_sale_product_min_max_qty/controllers/main.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -from odoo.http import request -from odoo import fields, http - -from odoo.addons.website_sale.controllers.main import WebsiteSale - - -class WebsiteSaleMinMax(WebsiteSale): - - @http.route() - def cart_update(self, *args, min_qty=None, max_qty=None, **kw): - """ Override to get min_qty and max_qty from the product. - """ - product_uom_min_qty = fields.Float(min_qty) - product_uom_max_qty = fields.Float(max_qty) - return super().cart_update(*args, min_qty=product_uom_min_qty, max_qty=product_uom_max_qty, **kw) \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/models/__init__.py b/nfu_sale_product_min_max_qty/models/__init__.py deleted file mode 100644 index 91f1542..0000000 --- a/nfu_sale_product_min_max_qty/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import sale_order_line -from . import sale_order \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/models/sale_order.py b/nfu_sale_product_min_max_qty/models/sale_order.py deleted file mode 100644 index 5b0fe98..0000000 --- a/nfu_sale_product_min_max_qty/models/sale_order.py +++ /dev/null @@ -1,80 +0,0 @@ -from odoo import _, models - - -class SaleOrder(models.Model): - _inherit = "sale.order" - - def action_min_max_qty_wizard(self): - """ - Here you need to create the wizzard objects first and then call the wizzard with the newly created id - """ - sale_max_qty_chooser = self.env["sale.max.qty.chooser"].create({}) - draft_sale_orders = self.filtered(lambda x: x.state == "draft") - for sale_order in draft_sale_orders: - sale_max_qty_chooser.sale_order_ids += sale_order - for line in sale_order.order_line.filtered(lambda x: not x.display_type): - self.env["sale.max.qty.line"].create( - { - "sale_line_id": line.id, - "sale_max_qty_chooser": sale_max_qty_chooser.id, - "qty": line.product_uom_qty, - } - ) - - action = { - "name": _("Min max qty wizard"), - "type": "ir.actions.act_window", - "res_model": "sale.max.qty.line", - "view_mode": "tree", - "target": "current", - "editable": True, - "context": {"search_default_group_by_product": 1}, - "domain": [("id", "in", sale_max_qty_chooser.sale_max_qty_ids.ids)], - } - return action - - def action_sale_order_lines(self): - """ - Here you need to create the wizzard objects first and then call the wizzard with the newly created id - """ - return { - "name": _("Min max qty wizard"), - "type": "ir.actions.act_window", - "res_model": "sale.order.line", - "view_mode": "tree,form", - "target": "current", - "context": {"group_by": "product_id"}, - "domain": [("id", "in", self.order_line.ids)], - } - - def _prepare_order_line_values( - self, - product_id, - quantity, - linked_line_id=False, - no_variant_attribute_values=None, - product_custom_attribute_values=None, - **kwargs - ): - values = super()._prepare_order_line_values( - product_id, - quantity, - linked_line_id=linked_line_id, - no_variant_attribute_values=no_variant_attribute_values, - product_custom_attribute_values=product_custom_attribute_values, - **kwargs - ) - values.update({"product_uom_min_qty": quantity, "product_uom_max_qty": kwargs.get("max_qty", quantity)}) - return values - - def _prepare_order_line_update_values(self, order_line, quantity, linked_line_id=False, **kwargs): - values = super()._prepare_order_line_update_values( - order_line, quantity, linked_line_id=linked_line_id, **kwargs - ) - max_qty = kwargs.get("max_qty", quantity) - if quantity != order_line.product_uom_min_qty: - values["product_uom_min_qty"] = quantity - if max_qty and max_qty != order_line.product_uom_max_qty: - values["product_uom_max_qty"] = max_qty - - return values diff --git a/nfu_sale_product_min_max_qty/models/sale_order_line.py b/nfu_sale_product_min_max_qty/models/sale_order_line.py deleted file mode 100644 index b8d42a6..0000000 --- a/nfu_sale_product_min_max_qty/models/sale_order_line.py +++ /dev/null @@ -1,15 +0,0 @@ -from odoo import _, api, fields, models -from odoo.exceptions import UserError - - -class SaleOrderLine(models.Model): - _inherit = "sale.order.line" - - product_uom_min_qty = fields.Float(string="Min qty.", digits="Product Unit of Measure") - product_uom_max_qty = fields.Float(string="Max qty.", digits="Product Unit of Measure") - - @api.constrains("product_uom_qty", "product_uom_max_qty") - def _check_product_uom_qty(self): - for record in self: - if record.product_uom_max_qty != 0 and record.product_uom_qty > record.product_uom_max_qty: - raise UserError(_("The quantity must be less than or equal to the maximum quantity.")) diff --git a/nfu_sale_product_min_max_qty/readme/DESCRIPTION.rst b/nfu_sale_product_min_max_qty/readme/DESCRIPTION.rst deleted file mode 100644 index 754f3e6..0000000 --- a/nfu_sale_product_min_max_qty/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -This module adds a minium and a maximum order quantity field to Sale Orders and adds it to checkout of the website shop. \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/readme/HISTORY.rst b/nfu_sale_product_min_max_qty/readme/HISTORY.rst deleted file mode 100644 index 765ab9c..0000000 --- a/nfu_sale_product_min_max_qty/readme/HISTORY.rst +++ /dev/null @@ -1 +0,0 @@ -:1.0.0: Initial module. \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/security/ir.model.access.csv b/nfu_sale_product_min_max_qty/security/ir.model.access.csv deleted file mode 100644 index 04aeaf3..0000000 --- a/nfu_sale_product_min_max_qty/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_sale_max_qty_chooser,sale.max.qty.chooser,model_sale_max_qty_chooser,sales_team.group_sale_salesman,1,1,1,1 -access_sale_max_qty_line,sale.max.qty.line,model_sale_max_qty_line,sales_team.group_sale_salesman,1,1,1,1 diff --git a/nfu_sale_product_min_max_qty/views/sale_order_line_views.xml b/nfu_sale_product_min_max_qty/views/sale_order_line_views.xml deleted file mode 100644 index 0c93010..0000000 --- a/nfu_sale_product_min_max_qty/views/sale_order_line_views.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - sale.order.line.tree - sale.order.line - - - - - - - - - - - - - - - - - - - diff --git a/nfu_sale_product_min_max_qty/views/sale_order_views.xml b/nfu_sale_product_min_max_qty/views/sale_order_views.xml deleted file mode 100644 index 9380572..0000000 --- a/nfu_sale_product_min_max_qty/views/sale_order_views.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - sale.order.form.product.min_max_qty - sale.order - - - - - - - - - - sale.order.list.view.inherited - sale.order - - - -
-
-
-
-
-
diff --git a/nfu_sale_product_min_max_qty/views/templates.xml b/nfu_sale_product_min_max_qty/views/templates.xml deleted file mode 100644 index 611340f..0000000 --- a/nfu_sale_product_min_max_qty/views/templates.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - \ No newline at end of file diff --git a/nfu_sale_product_min_max_qty/wizard/__init__.py b/nfu_sale_product_min_max_qty/wizard/__init__.py deleted file mode 100644 index 236a111..0000000 --- a/nfu_sale_product_min_max_qty/wizard/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import sale_max_qty_chooser -from . import sale_max_qty_line diff --git a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_chooser.py b/nfu_sale_product_min_max_qty/wizard/sale_max_qty_chooser.py deleted file mode 100644 index 04c48a0..0000000 --- a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_chooser.py +++ /dev/null @@ -1,54 +0,0 @@ -from odoo import fields, models - - -class SaleMaxQtyChooser(models.TransientModel): - """Wizard to Allow user to adjust the sale order amout to fit to a packaging size""" - - _name = "sale.max.qty.chooser" - _description = "Sale Max Quantity Chhooser" - - # fill from init or compute from given sale order lines - sale_order_ids = fields.Many2many("sale.order") - sale_max_qty_ids = fields.One2many("sale.max.qty.line", "sale_max_qty_chooser") - - def update_and_confirm_sale_order(self): - """ - Confirm sale orders where the quantity is fine. Create new Sale Orders for SO Lines with reset to draft - Through user error when total order amount of a product is not equal to packaging size (first package in the - list or smalles package sale_order_line.product_id.product.packaging_ids.qty) - we can use write({'key':'value'}) to update all sale order lines and action_confirm() to validate all sale - orders - - Also see this methode on how to create new records. It creates a invoice with invoice lines. we need to do the - same for sale orders - - def action_sold(self): - res = super().action_sold() - self.env["account.move"].create( - { - "property_id": self.id, - "partner_id": self.buyer_id.id, - "move_type": "out_invoice", - "line_ids": [ - fields.Command.create( - { - "name": f"Property {self.name} - 10% Tax", - "quantity": 1, - "price_unit": self.selling_price * 1.1, - } - ), - fields.Command.create({"name": "Administration Fees", "quantity": 1, "price_unit": 1000}), - ], - } - ) - return res - """ - - for sale_order in self.sale_order_ids: - can_confirm = True - for line in self.sale_max_qty_ids.filtered(lambda line: line.sale_line_id.order_id == sale_order): - line.sale_line_id.write({"product_uom_qty": line.qty}) - if not line.quantity_fits_packaging: - can_confirm = False - if can_confirm: - sale_order.action_confirm() diff --git a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_chooser_views.xml b/nfu_sale_product_min_max_qty/wizard/sale_max_qty_chooser_views.xml deleted file mode 100644 index 0d4cd9e..0000000 --- a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_chooser_views.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - Sale Max Quantity Chhooser - sale.max.qty.chooser - -
-
-

Sale Orders

- -
- - - -
-
-
-
-
- - - Set Quantities - sale.max.qty.chooser - form - current - - { - 'search_default_group_by_product': 1, - } - - -
diff --git a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_line.py b/nfu_sale_product_min_max_qty/wizard/sale_max_qty_line.py deleted file mode 100644 index ab4ff6b..0000000 --- a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_line.py +++ /dev/null @@ -1,46 +0,0 @@ -from odoo import _, api, fields, models -from odoo.exceptions import UserError - - -class SaleMaxQtyLine(models.TransientModel): - """ - Lines to shown in Wizard - """ - - _name = "sale.max.qty.line" - _description = "Max qty Sale Order Lines" - - name = fields.Char() - sale_max_qty_chooser = fields.Many2one("sale.max.qty.chooser") - qty = fields.Float() - max_qty = fields.Float(related="sale_line_id.product_uom_max_qty") - packaging_size = fields.Float(compute="_compute_packaging_size") - quantity_fits_packaging = fields.Boolean(compute="_compute_quantity_fits_packaging") - total_quantity = fields.Float(compute="_compute_quantity_fits_packaging") - - sale_line_id = fields.Many2one("sale.order.line") - product_id = fields.Many2one(related="sale_line_id.product_id", store=True) - reset_to_draft = fields.Boolean() - - def _compute_packaging_size(self): - for max_qty_line in self: - max_qty_line.packaging_size = min( - max_qty_line.sale_line_id.product_id.packaging_ids.mapped("qty"), default=1.0 - ) - - @api.onchange("qty") - def _compute_quantity_fits_packaging(self): - for max_qty_line in self: - order_lines = max_qty_line.sale_max_qty_chooser.sale_max_qty_ids.filtered( - lambda line: line.sale_line_id.product_id == max_qty_line.product_id - ) - max_qty_line.total_quantity = sum(order_lines.mapped("qty")) - max_qty_line.quantity_fits_packaging = max_qty_line.total_quantity % max_qty_line.packaging_size == 0 - # for order_line in order_lines: - # order_line.quantity_fits_packaging = max_qty_line.quantity_fits_packaging - - @api.constrains("qty") - def _check_product_uom_qty(self): - for max_qty_line in self: - if max_qty_line.max_qty != 0 and max_qty_line.qty > max_qty_line.max_qty: - raise UserError(_("The quantity must be less than or equal to the maximum quantity.")) diff --git a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_line_views.xml b/nfu_sale_product_min_max_qty/wizard/sale_max_qty_line_views.xml deleted file mode 100644 index 67e32e6..0000000 --- a/nfu_sale_product_min_max_qty/wizard/sale_max_qty_line_views.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - sale.max.qty.line.search - sale.max.qty.line - - - - - - - - - sale.max.qty.line.tree - sale.max.qty.line - - - - - - - - - - - - -