diff --git a/sale_auto_remove_zero_quantity_lines/README.rst b/sale_auto_remove_zero_quantity_lines/README.rst new file mode 100644 index 00000000000..dddb4ccca5d --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/README.rst @@ -0,0 +1,85 @@ +==================================== +Sale auto remove zero quantity lines +==================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:44c9dc66fe6506de2565dc530812f900b17292efb9d3bfbc30a5d3b7f6e947e6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/18.0/sale_auto_remove_zero_quantity_lines + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_auto_remove_zero_quantity_lines + :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/sale-workflow&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Upon confirming a sales order remove any sales order lines that have +zero quantities. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To enable this feature you need to: + +1. Go to *Sale > Settings > Quotation & Orders*. +2. Check Automatic Removal of Zero Quantity Lines + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- Telmo Santos + +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/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_auto_remove_zero_quantity_lines/__init__.py b/sale_auto_remove_zero_quantity_lines/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_auto_remove_zero_quantity_lines/__manifest__.py b/sale_auto_remove_zero_quantity_lines/__manifest__.py new file mode 100644 index 00000000000..19741edb2df --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Camptocamp (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +{ + "name": "Sale auto remove zero quantity lines", + "version": "18.0.1.0.0", + "author": "Camptocamp, Odoo Community Association (OCA)", + "summary": "On sale confirmation remove lines with zero quantities", + "website": "https://github.com/OCA/sale-workflow", + "license": "AGPL-3", + "depends": ["sale"], + "category": "Sales/Sales", + "data": [ + "views/res_config_settings_views.xml", + ], + "installable": True, + "development_status": "Beta", +} diff --git a/sale_auto_remove_zero_quantity_lines/i18n/de.po b/sale_auto_remove_zero_quantity_lines/i18n/de.po new file mode 100644 index 00000000000..608aa68977b --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/i18n/de.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_auto_remove_zero_quantity_lines +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-01-23 08:30+0000\n" +"PO-Revision-Date: 2024-04-09 22:38+0000\n" +"Last-Translator: jappi00 \n" +"Language-Team: \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,help:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +#: model_terms:ir.ui.view,arch_db:sale_auto_remove_zero_quantity_lines.res_config_settings_view_form_sale +msgid "Auto remove sale order lines with zero quantity upon confirmation." +msgstr "" +"Automatische Entfernung von Verkaufsauftragszeilen mit Nullmenge bei " +"Bestätigung." + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +msgid "Automatic Removal of Zero Quantity Lines" +msgstr "Automatische Entfernung von Nullmengen-Linien" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_company +msgid "Companies" +msgstr "Unternehmen" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_config_settings +msgid "Config Settings" +msgstr "Konfigurationseinstellungen" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_company__sale_auto_remove_zero_quantity_lines +msgid "Sale Auto Remove Zero Quantity Lines" +msgstr "Automatisches entfernen von Nullmengenzeilen im Verkauf" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_sale_order +msgid "Sales Order" +msgstr "Verkaufsaufträge" + +#. module: sale_auto_remove_zero_quantity_lines +#. odoo-python +#: code:addons/sale_auto_remove_zero_quantity_lines/models/sale_order.py:0 +#, python-format +msgid "" +"Some lines with zero quantities or empty notes were removed upon " +"confirmation." +msgstr "" + +#, python-format +#~ msgid "" +#~ "Some sale order lines with zero quantities were removed upon confirmation." +#~ msgstr "" +#~ "Einige Verkaufsauftragszeilen mit Nullmengen wurden bei der Bestätigung " +#~ "entfernt." diff --git a/sale_auto_remove_zero_quantity_lines/i18n/fr.po b/sale_auto_remove_zero_quantity_lines/i18n/fr.po new file mode 100644 index 00000000000..9447d71cff7 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/i18n/fr.po @@ -0,0 +1,66 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_auto_remove_zero_quantity_lines +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-01-23 08:30+0000\n" +"PO-Revision-Date: 2024-01-23 08:30+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,help:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +#: model_terms:ir.ui.view,arch_db:sale_auto_remove_zero_quantity_lines.res_config_settings_view_form_sale +msgid "Auto remove sale order lines with zero quantity upon confirmation." +msgstr "" +"Suppression automatique des lignes d'ordre de vente avec une quantité nulle " +"lors de la confirmation." + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +msgid "Automatic Removal of Zero Quantity Lines" +msgstr "Suppression automatique des lignes de quantité zéro" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_company +msgid "Companies" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_company__sale_auto_remove_zero_quantity_lines +msgid "Sale Auto Remove Zero Quantity Lines" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#. odoo-python +#: code:addons/sale_auto_remove_zero_quantity_lines/models/sale_order.py:0 +#, python-format +msgid "" +"Some lines with zero quantities or empty notes were removed upon " +"confirmation." +msgstr "" + +#, python-format +#~ msgid "" +#~ "Some sale order lines with zero quantities were removed upon confirmation." +#~ msgstr "" +#~ "Certaines lignes d'ordre de vente avec des quantités nulles ont été " +#~ "supprimées lors de la confirmation." diff --git a/sale_auto_remove_zero_quantity_lines/i18n/hr.po b/sale_auto_remove_zero_quantity_lines/i18n/hr.po new file mode 100644 index 00000000000..fe66a4dea29 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/i18n/hr.po @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_auto_remove_zero_quantity_lines +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-06-21 12:16+0000\n" +"Last-Translator: Bole \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 4.17\n" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,help:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +#: model_terms:ir.ui.view,arch_db:sale_auto_remove_zero_quantity_lines.res_config_settings_view_form_sale +msgid "Auto remove sale order lines with zero quantity upon confirmation." +msgstr "Automatski ukloni stavke ponude sa količinama 0 nakon potvrđivanja." + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +msgid "Automatic Removal of Zero Quantity Lines" +msgstr "Automatsko uklanjanje Stavaka sa količinom nula" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_company +msgid "Companies" +msgstr "Tvrtke" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_config_settings +msgid "Config Settings" +msgstr "Konfiguracijske postavke" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_company__sale_auto_remove_zero_quantity_lines +msgid "Sale Auto Remove Zero Quantity Lines" +msgstr "Automatski ukloni stavke bez količine u prodaji" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_sale_order +msgid "Sales Order" +msgstr "Prodajni nalog" + +#. module: sale_auto_remove_zero_quantity_lines +#. odoo-python +#: code:addons/sale_auto_remove_zero_quantity_lines/models/sale_order.py:0 +#, python-format +msgid "" +"Some lines with zero quantities or empty notes were removed upon " +"confirmation." +msgstr "" +"Neke stavke bez količine ili prazne napomene su uklonjene nakon potvrđivanja." diff --git a/sale_auto_remove_zero_quantity_lines/i18n/it.po b/sale_auto_remove_zero_quantity_lines/i18n/it.po new file mode 100644 index 00000000000..7acdfd066e7 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/i18n/it.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_auto_remove_zero_quantity_lines +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-29 08:41+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,help:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +#: model_terms:ir.ui.view,arch_db:sale_auto_remove_zero_quantity_lines.res_config_settings_view_form_sale +msgid "Auto remove sale order lines with zero quantity upon confirmation." +msgstr "" +"Rimuovi automaticamente alla conferma le righe ordine di vendita con " +"quantità a zero." + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +msgid "Automatic Removal of Zero Quantity Lines" +msgstr "Rimozione automatica righe a quantità zero" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_company +msgid "Companies" +msgstr "Aziende" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_company__sale_auto_remove_zero_quantity_lines +msgid "Sale Auto Remove Zero Quantity Lines" +msgstr "Rimozione automatica righe vendita a quantità zero" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: sale_auto_remove_zero_quantity_lines +#. odoo-python +#: code:addons/sale_auto_remove_zero_quantity_lines/models/sale_order.py:0 +#, python-format +msgid "" +"Some lines with zero quantities or empty notes were removed upon " +"confirmation." +msgstr "" +"Alcune righe con quantità zero o note vuote sono state eliminate alla " +"conferma." + +#, python-format +#~ msgid "" +#~ "Some sale order lines with zero quantities were removed upon confirmation." +#~ msgstr "" +#~ "Alcune righe ordine con quantità a zero sono state rimosse alla conferma." diff --git a/sale_auto_remove_zero_quantity_lines/i18n/sale_auto_remove_zero_quantity_lines.pot b/sale_auto_remove_zero_quantity_lines/i18n/sale_auto_remove_zero_quantity_lines.pot new file mode 100644 index 00000000000..656a2068792 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/i18n/sale_auto_remove_zero_quantity_lines.pot @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_auto_remove_zero_quantity_lines +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,help:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +#: model_terms:ir.ui.view,arch_db:sale_auto_remove_zero_quantity_lines.res_config_settings_view_form_sale +msgid "Auto remove sale order lines with zero quantity upon confirmation." +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_config_settings__sale_auto_remove_zero_quantity_lines +msgid "Automatic Removal of Zero Quantity Lines" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_company +msgid "Companies" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model.fields,field_description:sale_auto_remove_zero_quantity_lines.field_res_company__sale_auto_remove_zero_quantity_lines +msgid "Sale Auto Remove Zero Quantity Lines" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#: model:ir.model,name:sale_auto_remove_zero_quantity_lines.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_auto_remove_zero_quantity_lines +#. odoo-python +#: code:addons/sale_auto_remove_zero_quantity_lines/models/sale_order.py:0 +#, python-format +msgid "" +"Some lines with zero quantities or empty notes were removed upon " +"confirmation." +msgstr "" diff --git a/sale_auto_remove_zero_quantity_lines/models/__init__.py b/sale_auto_remove_zero_quantity_lines/models/__init__.py new file mode 100644 index 00000000000..20972a4c7d2 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/models/__init__.py @@ -0,0 +1,3 @@ +from . import sale_order +from . import res_company +from . import res_config_settings diff --git a/sale_auto_remove_zero_quantity_lines/models/res_company.py b/sale_auto_remove_zero_quantity_lines/models/res_company.py new file mode 100644 index 00000000000..c373277a349 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/models/res_company.py @@ -0,0 +1,10 @@ +# Copyright 2024 Camptocamp (). +# 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" + + sale_auto_remove_zero_quantity_lines = fields.Boolean() diff --git a/sale_auto_remove_zero_quantity_lines/models/res_config_settings.py b/sale_auto_remove_zero_quantity_lines/models/res_config_settings.py new file mode 100644 index 00000000000..d75f5dbb861 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/models/res_config_settings.py @@ -0,0 +1,15 @@ +# Copyright 2024 Camptocamp (). +# 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" + + sale_auto_remove_zero_quantity_lines = fields.Boolean( + string="Automatic Removal of Zero Quantity Lines", + related="company_id.sale_auto_remove_zero_quantity_lines", + readonly=False, + help="Auto remove sale order lines with zero quantity upon confirmation.", + ) diff --git a/sale_auto_remove_zero_quantity_lines/models/sale_order.py b/sale_auto_remove_zero_quantity_lines/models/sale_order.py new file mode 100644 index 00000000000..15c5e06a5e6 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/models/sale_order.py @@ -0,0 +1,33 @@ +# Copyright 2024 Camptocamp (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def _should_auto_remove_zero_quantity_lines(self): + self.ensure_one() + return self.company_id.sale_auto_remove_zero_quantity_lines + + def action_confirm(self): + all_lines_to_unlink = self.env["sale.order.line"] + for order in self: + if order._should_auto_remove_zero_quantity_lines(): + zero_or_empty_lines = order.order_line.filtered( + lambda line: (line.product_id and line.product_uom_qty == 0) + or (line.display_type == "line_note" and not line.name.strip()) + ) + if zero_or_empty_lines: + body = self.env._( + "Some lines with zero quantities or empty notes were " + "removed upon confirmation." + ) + order.message_post(body=body) + all_lines_to_unlink |= zero_or_empty_lines + + if all_lines_to_unlink: + all_lines_to_unlink.unlink() + + return super().action_confirm() diff --git a/sale_auto_remove_zero_quantity_lines/pyproject.toml b/sale_auto_remove_zero_quantity_lines/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_auto_remove_zero_quantity_lines/readme/CONFIGURE.md b/sale_auto_remove_zero_quantity_lines/readme/CONFIGURE.md new file mode 100644 index 00000000000..11a9081f238 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To enable this feature you need to: + +1. Go to *Sale \> Settings \> Quotation & Orders*. +2. Check Automatic Removal of Zero Quantity Lines diff --git a/sale_auto_remove_zero_quantity_lines/readme/CONTRIBUTORS.md b/sale_auto_remove_zero_quantity_lines/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..08b9f3e73d4 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Telmo Santos \ diff --git a/sale_auto_remove_zero_quantity_lines/readme/DESCRIPTION.md b/sale_auto_remove_zero_quantity_lines/readme/DESCRIPTION.md new file mode 100644 index 00000000000..d5508f5ff2c --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +Upon confirming a sales order remove any sales order lines that have +zero quantities. diff --git a/sale_auto_remove_zero_quantity_lines/static/description/icon.png b/sale_auto_remove_zero_quantity_lines/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_auto_remove_zero_quantity_lines/static/description/icon.png differ diff --git a/sale_auto_remove_zero_quantity_lines/static/description/index.html b/sale_auto_remove_zero_quantity_lines/static/description/index.html new file mode 100644 index 00000000000..b736ee1518d --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +Sale auto remove zero quantity lines + + + +
+

Sale auto remove zero quantity lines

+ + +

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

+

Upon confirming a sales order remove any sales order lines that have +zero quantities.

+

Table of contents

+ +
+

Configuration

+

To enable this feature you need to:

+
    +
  1. Go to Sale > Settings > Quotation & Orders.
  2. +
  3. Check Automatic Removal of Zero Quantity Lines
  4. +
+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/sale-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/sale_auto_remove_zero_quantity_lines/tests/__init__.py b/sale_auto_remove_zero_quantity_lines/tests/__init__.py new file mode 100644 index 00000000000..38023e3328d --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_auto_remove_zero_quantity_lines diff --git a/sale_auto_remove_zero_quantity_lines/tests/test_sale_auto_remove_zero_quantity_lines.py b/sale_auto_remove_zero_quantity_lines/tests/test_sale_auto_remove_zero_quantity_lines.py new file mode 100644 index 00000000000..2852f5754d5 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/tests/test_sale_auto_remove_zero_quantity_lines.py @@ -0,0 +1,80 @@ +# Copyright 2024 Camptocamp (). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import TransactionCase + +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + + +class TestSaleAutoRemoveZeroQuantityLines(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env["base"].with_context(**DISABLED_MAIL_CONTEXT).env + cls.public_pricelist = cls.env["product.pricelist"].create( + { + "name": "Test Public Pricelist", + "sequence": 1, + } + ) + + def test_sale_auto_remove_zero_quantity_lines(self): + self.env.user.company_id.sale_auto_remove_zero_quantity_lines = True + partner = self.env.ref("base.res_partner_1") + p = self.env.ref("product.product_product_6") + so = self.env["sale.order"].create( + { + "partner_id": partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": p.name, + "product_id": p.id, + "product_uom_qty": 2, + "product_uom": p.uom_id.id, + "price_unit": p.list_price, + }, + ), + ( + 0, + 0, + { + "name": p.name, + "product_id": p.id, + "product_uom_qty": 0, + "product_uom": p.uom_id.id, + "price_unit": p.list_price, + }, + ), + ( + 0, + 0, + { + "name": "Note test", + "display_type": "line_note", + }, + ), + ( + 0, + 0, + { + "name": " ", + "display_type": "line_note", + }, + ), + ( + 0, + 0, + { + "name": " ", + "display_type": "line_section", + }, + ), + ], + "pricelist_id": self.public_pricelist.id, + } + ) + so.action_confirm() + self.assertEqual(len(so.order_line), 3) diff --git a/sale_auto_remove_zero_quantity_lines/views/res_config_settings_views.xml b/sale_auto_remove_zero_quantity_lines/views/res_config_settings_views.xml new file mode 100644 index 00000000000..3070ddc10c8 --- /dev/null +++ b/sale_auto_remove_zero_quantity_lines/views/res_config_settings_views.xml @@ -0,0 +1,18 @@ + + + + res.config.settings + + + + + + + + + +