From d1bef11d8976cf32f6a9a494f6ffe76a535e0950 Mon Sep 17 00:00:00 2001 From: SoSylwe Date: Wed, 22 Jan 2025 14:54:11 +0100 Subject: [PATCH] [IMP]sale_input_barcode:add settings for sol management --- sale_input_barcode/README.rst | 5 +++++ sale_input_barcode/__manifest__.py | 4 +--- sale_input_barcode/models/__init__.py | 1 + .../models/res_config_settings.py | 12 +++++++++++ sale_input_barcode/models/sale_order.py | 11 +++++++++- sale_input_barcode/readme/USAGE.rst | 5 +++++ .../static/description/index.html | 15 ++++++++++---- .../views/sale_input_settings_view.xml | 20 +++++++++++++++++++ 8 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 sale_input_barcode/models/res_config_settings.py create mode 100644 sale_input_barcode/views/sale_input_settings_view.xml diff --git a/sale_input_barcode/README.rst b/sale_input_barcode/README.rst index 7044126d151f..7ac5e29fcdac 100644 --- a/sale_input_barcode/README.rst +++ b/sale_input_barcode/README.rst @@ -58,6 +58,11 @@ a new line with that product will be added to the Sales Order. If a product is already inside the sale order lines, the quantity will be updated. +So as not to duplicate the same product, +#. Navigate through the salt settings. +#. mark the check mark as active of “Increase quantity instead of creating a new line” +#. save + Bug Tracker =========== diff --git a/sale_input_barcode/__manifest__.py b/sale_input_barcode/__manifest__.py index 7e19210b2bbc..b1fec52c9842 100644 --- a/sale_input_barcode/__manifest__.py +++ b/sale_input_barcode/__manifest__.py @@ -15,8 +15,6 @@ "sale_management", "barcode_action", ], - "data": [ - "views/sale.xml", - ], + "data": ["views/sale.xml", "views/sale_input_settings_view.xml"], "demo": [], } diff --git a/sale_input_barcode/models/__init__.py b/sale_input_barcode/models/__init__.py index 8e4dc36757b1..0c4236223931 100644 --- a/sale_input_barcode/models/__init__.py +++ b/sale_input_barcode/models/__init__.py @@ -1,2 +1,3 @@ from . import product_barcode_line_mixin from . import sale_order +from . import res_config_settings diff --git a/sale_input_barcode/models/res_config_settings.py b/sale_input_barcode/models/res_config_settings.py new file mode 100644 index 000000000000..56f529240ca4 --- /dev/null +++ b/sale_input_barcode/models/res_config_settings.py @@ -0,0 +1,12 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + + _inherit = "res.config.settings" + + sale_barcode_update_existing_line = fields.Boolean( + string="Increase quantity instead of creating a new line", + config_parameter="sale_input_barcode.sale_barcode_update_existing_line", + default=False, + ) diff --git a/sale_input_barcode/models/sale_order.py b/sale_input_barcode/models/sale_order.py index 6806790171f0..f9852451a89e 100644 --- a/sale_input_barcode/models/sale_order.py +++ b/sale_input_barcode/models/sale_order.py @@ -31,7 +31,16 @@ def process_barcode(self, barcode): product_order_line = self.order_line.filtered( lambda x: x.product_id.id == line_vals.get("product_id") )[:1] - if product_order_line: + + sale_barcode_update_existing_line = ( + self.env["ir.config_parameter"] + .sudo() + .get_param( + "sale_input_barcode.sale_barcode_update_existing_line", + ) + ) + + if product_order_line and sale_barcode_update_existing_line: product_order_line.product_uom_qty += 1 else: product_order_line = self.env["sale.order.line"].new(line_vals) diff --git a/sale_input_barcode/readme/USAGE.rst b/sale_input_barcode/readme/USAGE.rst index 614338b0e13a..3f68edc322c2 100644 --- a/sale_input_barcode/readme/USAGE.rst +++ b/sale_input_barcode/readme/USAGE.rst @@ -12,3 +12,8 @@ a new line with that product will be added to the Sales Order. If a product is already inside the sale order lines, the quantity will be updated. + +So as not to duplicate the same product, +#. Navigate through the salt settings. +#. mark the check mark as active of “Increase quantity instead of creating a new line” +#. save diff --git a/sale_input_barcode/static/description/index.html b/sale_input_barcode/static/description/index.html index 9e300637687a..72afaa60c8e9 100644 --- a/sale_input_barcode/static/description/index.html +++ b/sale_input_barcode/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -402,6 +403,10 @@

Usage

a new line with that product will be added to the Sales Order.

If a product is already inside the sale order lines, the quantity will be updated.

+

So as not to duplicate the same product, +#. Navigate through the salt settings. +#. mark the check mark as active of “Increase quantity instead of creating a new line” +#. save

Bug Tracker

@@ -422,7 +427,9 @@

Authors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +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.

diff --git a/sale_input_barcode/views/sale_input_settings_view.xml b/sale_input_barcode/views/sale_input_settings_view.xml new file mode 100644 index 000000000000..0979201b9f33 --- /dev/null +++ b/sale_input_barcode/views/sale_input_settings_view.xml @@ -0,0 +1,20 @@ + + + res.config.settings.sale.input.barcode + res.config.settings + + + +
+ +
+
+
+
+
+
+