Skip to content

Commit

Permalink
[ADD] adding a pos.config parameter 'display_default_code' to enable/…
Browse files Browse the repository at this point in the history
…disable product's internal reference

* 'display_default_code' field view in PoS -> settings -> PoS Interface
[NEW] new files: contributors.rst, configure.rst
  • Loading branch information
suker committed Feb 15, 2023
1 parent 5cbedfe commit 2d12df4
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 19 deletions.
7 changes: 6 additions & 1 deletion pos_product_display_default_code/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
"version": "16.0.1.0.0",
"category": "Point of Sale",
"website": "https://github.com/OCA/pos",
"author": "Odoo Community Association (OCA), Akretion",
"author": "Odoo Community Association (OCA), Akretion, FactorLibre",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"point_of_sale",
],
"data": [
"views/res_config_settings_views.xml",
],
"demo": [],
"qweb": [],
}
43 changes: 43 additions & 0 deletions pos_product_display_default_code/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_product_display_default_code
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-14 15:18+0000\n"
"PO-Revision-Date: 2023-02-14 15:18+0000\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: pos_product_display_default_code
#: model:ir.model,name:pos_product_display_default_code.model_res_config_settings
msgid "Config Settings"
msgstr "Opciones de configuración"

#. module: pos_product_display_default_code
#: model:ir.model.fields,field_description:pos_product_display_default_code.field_pos_config__display_default_code
#: model:ir.model.fields,field_description:pos_product_display_default_code.field_res_config_settings__pos_display_default_code
#: model_terms:ir.ui.view,arch_db:pos_product_display_default_code.res_config_settings_default_code_view_form
msgid "Display Default Code"
msgstr "Mostrar referencia interna"

#. module: pos_product_display_default_code
#: model_terms:ir.ui.view,arch_db:pos_product_display_default_code.res_config_settings_default_code_view_form
msgid "Display products' internal reference in the PoS interface and tickets."
msgstr "Mostrar referencia interna del producto en la interfaz del TPV y tickets."

#. module: pos_product_display_default_code
#: model:ir.model,name:pos_product_display_default_code.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configuración del TPV"

#. module: pos_product_display_default_code
#: model:ir.model,name:pos_product_display_default_code.model_pos_session
msgid "Point of Sale Session"
msgstr "Sesión TPV"

This file was deleted.

2 changes: 2 additions & 0 deletions pos_product_display_default_code/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Copyright 2023 FactorLibre - Juan Carlos Bonilla
from . import pos_session
from . import pos_config
from . import res_config_settings
8 changes: 8 additions & 0 deletions pos_product_display_default_code/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2023 FactorLibre - Juan Carlos Bonilla
from odoo import fields, models


class PosConfig(models.Model):
_inherit = "pos.config"

display_default_code = fields.Boolean(default=False)
3 changes: 2 additions & 1 deletion pos_product_display_default_code/models/pos_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ class PosSession(models.Model):

def _loader_params_product_product(self):
result = super()._loader_params_product_product()
result["context"]["display_default_code"] = True
if self.config_id and self.config_id.display_default_code:
result["context"]["display_default_code"] = True
return result
10 changes: 10 additions & 0 deletions pos_product_display_default_code/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 FactorLibre - Juan Carlos Bonilla
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

pos_display_default_code = fields.Boolean(
related="pos_config_id.display_default_code", readonly=False
)
5 changes: 5 additions & 0 deletions pos_product_display_default_code/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* Go to Point Of Sale / Configuration / Settings
* Check the box 'Display Default Code' in PoS Interface section

.. image:: ../static/description/config.png
:width: 800 px
1 change: 1 addition & 0 deletions pos_product_display_default_code/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Juan Carlos Bonilla <[email protected]>
1 change: 0 additions & 1 deletion pos_product_display_default_code/readme/ROADMAP.rst

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">PoS Product Display Default Code</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_product_display_default_code"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_product_display_default_code"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/pos/tree/15.0/pos_product_display_default_code"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-15-0/pos-15-0-pos_product_display_default_code"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module makes Odoo show the internal reference of the product in the Point of Sale.</p>
<p>The reference will appear in the products list, in the orderlines and in the receipt.</p>
<p>example: Desk Organizer -&gt; [FURN_0001] Desk Organizer</p>
Expand All @@ -392,7 +392,7 @@ <h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_product_display_default_code%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_product_display_default_code%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -410,7 +410,7 @@ <h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<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>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_product_display_default_code">OCA/pos</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/15.0/pos_product_display_default_code">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions pos_product_display_default_code/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 FactorLibre - Juan Carlos Bonilla
from . import test_load_params_productqq
18 changes: 18 additions & 0 deletions pos_product_display_default_code/tests/test_load_params_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 FactorLibre - Juan Carlos Bonilla

import odoo

from odoo.addons.point_of_sale.tests.common import TestPoSCommon


@odoo.tests.tagged("post_install", "-at_install")
class TestPosDisplayDefaultCode(TestPoSCommon):
def setUp(self):
super(TestPosDisplayDefaultCode, self).setUp()
self.config = self.basic_config
self.config.display_default_code = True
self.pos_session = self.env["pos.session"].create({"config_id": self.config.id})

def test_load_params_products(self):
result = self.pos_session._loader_params_product_product()
self.assertTrue(result["context"]["display_default_code"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_default_code_view_form" model="ir.ui.view">
<field name="name">res.config.settings.default.code.view.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='pos_is_margins_costs_accessible_to_every_user']/../.."
position="after"
>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="pos_display_default_code" />
</div>
<div class="o_setting_right_pane">
<label
for="pos_display_default_code"
string="Display Default Code"
/>
<div class="text-muted">
Display products' internal reference in the PoS interface and tickets.
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 2d12df4

Please sign in to comment.