Skip to content

Commit

Permalink
[IMP]sale_input_barcode:add settings for sol management
Browse files Browse the repository at this point in the history
  • Loading branch information
SylweKra committed Jan 22, 2025
1 parent 8938809 commit a3fc16d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 8 deletions.
5 changes: 2 additions & 3 deletions sale_input_barcode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
"depends": [
"sale_management",
"barcode_action",
"barcode",
],
"data": [
"views/sale.xml",
],
"data": ["views/sale.xml", "views/sale_input_settings_view.xml"],
"demo": [],
}
1 change: 1 addition & 0 deletions sale_input_barcode/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import product_barcode_line_mixin
from . import sale_order
from . import res_config_settings
12 changes: 12 additions & 0 deletions sale_input_barcode/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import fields, models


class ResConfigSettings(models.TransientModel):

_inherit = "res.config.settings"

sale_sol_creation_settings = fields.Boolean(
string="Increase quantity instead of creating a new line",
config_parameter="sale_input_barcode.sale_sol_creation_settings",
default=False,
)
11 changes: 10 additions & 1 deletion sale_input_barcode/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_sol_creation_settings = (
self.env["ir.config_parameter"]
.sudo()
.get_param(
"sale_input_barcode.sale_sol_creation_settings",
)
)

if product_order_line and sale_sol_creation_settings:
product_order_line.product_uom_qty += 1
else:
product_order_line = self.env["sale.order.line"].new(line_vals)
Expand Down
11 changes: 7 additions & 4 deletions sale_input_barcode/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -422,7 +423,9 @@ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
23 changes: 23 additions & 0 deletions sale_input_barcode/views/sale_input_settings_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<odoo>
<record id="view_res_config_settings_sale_input_barcode" model="ir.ui.view">
<field name="name">res.config.settings.sale.input.barcode</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='no_edit_order']" position="inside">
<div class="o_setting_left_pane">
<field name="sale_sol_creation_settings" />
</div>
<div class="o_setting_right_pane">
<label for="sale_sol_creation_settings" />
<div class="text-muted">
Instead of creating a new sale order line it increases the quantity for each barcode scan
</div>
</div>



</xpath>
</field>
</record>
</odoo>

0 comments on commit a3fc16d

Please sign in to comment.