Browse Source

Jun 19: [FIX] Bug Fixed 'total_quantity_pos'

pull/331/head
RisvanaCybro 12 months ago
parent
commit
719a7adb84
  1. 6
      total_quantity_pos/README.rst
  2. 1
      total_quantity_pos/__init__.py
  3. 16
      total_quantity_pos/__manifest__.py
  4. 2
      total_quantity_pos/doc/RELEASE_NOTES.md
  5. 23
      total_quantity_pos/models/__init__.py
  6. 38
      total_quantity_pos/models/pos_config.py
  7. 44
      total_quantity_pos/models/res_config_settings.py
  8. BIN
      total_quantity_pos/static/description/assets/screenshots.zip
  9. 32
      total_quantity_pos/static/description/index.html
  10. 17
      total_quantity_pos/static/src/overrides/components/order_receipt.xml
  11. 26
      total_quantity_pos/static/src/overrides/components/order_widget.js
  12. 29
      total_quantity_pos/static/src/overrides/components/order_widget.xml
  13. 18
      total_quantity_pos/static/src/overrides/models/models.js
  14. 1
      total_quantity_pos/static/src/xml/product_screen.xml
  15. 45
      total_quantity_pos/views/res_config_settings.views.xml

6
total_quantity_pos/README.rst

@ -1,5 +1,5 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
Total Items and Total Quantity in POS
@ -8,7 +8,7 @@ This module allows to show the total items and total quantities of products alon
Installation
============
- www.odoo.com/documentation/17.0/setup/install.html
- www.odoo.com/documentation/16.0/setup/install.html
- Install our custom addon
License

1
total_quantity_pos/__init__.py

@ -19,4 +19,3 @@
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from . import models

16
total_quantity_pos/__manifest__.py

@ -24,22 +24,24 @@
'version': '17.0.1.0.0',
'category': 'Point of Sale',
'summary': "To Show the Total Quantity and Total Items Ordered in POS",
'description': "This app will shows the number of products ordered and the"
" total quantity of products in the order summary in the pos"
" screen and bill.",
'description': "This app will shows the number of "
"products ordered and the total quantity"
" of products in the order summary in"
" the pos screen and bill.",
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'website': 'https://www.cybrosys.com',
'depends': ['point_of_sale'],
'data': [
'views/res_config_settings.views.xml'
],
'assets': {
'point_of_sale._assets_pos': [
'total_quantity_pos/static/src/xml/product_screen.xml',
'total_quantity_pos/static/src/xml/order_receipt.xml',
],
'total_quantity_pos/static/src/overrides/components/order_widget.xml',
'total_quantity_pos/static/src/overrides/components/order_receipt.xml',
'total_quantity_pos/static/src/overrides/components/order_widget.js',
'total_quantity_pos/static/src/overrides/models/models.js',
],
},
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3',

2
total_quantity_pos/doc/RELEASE_NOTES.md

@ -3,4 +3,4 @@
#### 15.05.2024
#### Version 17.0.1.0.0
#### ADD
- Initial Commit for Total Items and Total Quantity in POS.
Initial Commit for Total Items and Total Quantity in POS.

23
total_quantity_pos/models/__init__.py

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Subina P (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from . import pos_config
from . import res_config_settings

38
total_quantity_pos/models/pos_config.py

@ -1,38 +0,0 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Subina P (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from odoo import fields, models
class PosConfig(models.Model):
""" Class for adding the fields in the pos config"""
_inherit = "pos.config"
pos_total_items = fields.Boolean(string="Total Items",
help="The boolean field"
" in pos.config respective"
" to the total_items field"
" in res.config.settings")
pos_total_quantity = fields.Boolean(string="Total Quantity",
help="The boolean field"
" in pos.config respective"
" to the total_quantity field"
" in res.config.settings")

44
total_quantity_pos/models/res_config_settings.py

@ -1,44 +0,0 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Subina P (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from odoo import fields, models
class ConfigSettings(models.TransientModel):
"""Class for adding the fields in res.config.settings"""
_inherit = 'res.config.settings'
total_items = fields.Boolean(string="Enable Total Items",
related="pos_config_id.pos_total_items",
readonly=False, help="Enable this option "
"will show the total"
" number of items and"
" total quantities of"
" product in the "
"PoS screen.")
total_quantity = fields.Boolean(string="Enable Total Quantity",
related="pos_config_id.pos_total_quantity",
readonly=False, help="Enable this option "
"will show the total"
" number of items and"
" total quantities of"
" product in the"
" receipt.")

BIN
total_quantity_pos/static/description/assets/screenshots.zip

Binary file not shown.

32
total_quantity_pos/static/description/index.html

@ -138,38 +138,6 @@
</ul>
<div class="tab-content" style="background-color: rgba(121, 113, 119, 0.04);">
<div id="tab1" class="tab-pane fade in active show">
<div class="col-lg-12 py-2" style="padding: 1rem 4rem !important;">
<div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="row justify-content-center p-3 w-100 m-0">
<img src="assets/screenshots/pos1.png" class="img-responsive" width="100%" height="auto">
</div>
<div class="px-3">
<h4 class="mt-2"
style=" font-weight:600 !important; color:#282F33 !important; font-size:1.3rem !important">
Option to make the feature available in PoS screen.</h4>
<h6 class="mt-2"
style=" font-weight:300 !important; color:#282F33 !important; font-size:0.7rem !important">
</h6>
</div>
</div>
</div>
<div class="col-lg-12 py-2" style="padding: 1rem 4rem !important;">
<div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="row justify-content-center p-3 w-100 m-0">
<img src="assets/screenshots/pos2.png" class="img-responsive" width="100%" height="auto">
</div>
<div class="px-3">
<h4 class="mt-2"
style=" font-weight:600 !important; color:#282F33 !important; font-size:1.3rem !important">
Option to make the feature available in Bill.</h4>
<h6 class="mt-2"
style=" font-weight:300 !important; color:#282F33 !important; font-size:0.7rem !important">
</h6>
</div>
</div>
</div>
<div class="col-lg-12 py-2" style="padding: 1rem 4rem !important;">
<div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">

17
total_quantity_pos/static/src/overrides/components/order_receipt.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="total_quantity_pos.OrderReceipt"
t-inherit="point_of_sale.OrderReceipt" t-inherit-mode="extension">
<xpath expr="//t[@t-if='props.data.rounding_applied']" position="after">
<!-- Display the total number of items in the order -->
<div class="total_items pos-receipt-amount">Total Items:
<span class="pos-receipt-right-align"><t t-esc="props.data.ItemCount"/></span>
</div>
<!-- Display the total quantities (custom variable) -->
<div class="pos-receipt-amount">
Total Quantity:
<span class="pos-receipt-right-align"><t t-esc="props.data.TotalQuantity"/></span>
</div>
</xpath>
</t>
</templates>

26
total_quantity_pos/static/src/overrides/components/order_widget.js

@ -0,0 +1,26 @@
/** @odoo-module */
import { OrderWidget } from "@point_of_sale/app/generic_components/order_widget/order_widget";
import { patch } from "@web/core/utils/patch";
// Patch the OrderSummary to add custom properties
patch(OrderWidget.prototype, {
/**
* Get the total number of items in the order.
*
* @returns {number} The total number of items in the order.
*/
get ItemCount(){
return this.props.lines.length
},
/**
* Get the total quantity of items in the order.
*
* @returns {number} The total quantity of items in the order.
*/
get TotalQuantity(){
var totalQuantity = 0;
this.props.lines.forEach(line => totalQuantity += line.quantity);
return totalQuantity
}
});

29
total_quantity_pos/static/src/overrides/components/order_widget.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<!-- Extended OrderSummary Component Template -->
<t t-name="total_quantity_pos.OrderWidget"
t-inherit="point_of_sale.OrderWidget" t-inherit-mode="extension"
owl="1">
<!-- Insert additional content inside the summary section -->
<xpath expr="//div[hasclass('order-summary')]" position="inside">
<!-- Display the item count -->
<div class="line">
<div class="subentry fs-6 text-muted">
Item Count:
<span class="value">
<!-- Render the calculated item count -->
<t t-esc="ItemCount"/>
</span>
</div>
<!-- Display the total quantity -->
<div class="subentry fs-6 text-muted">
Total Quantity:
<span class="value">
<!-- Render the calculated total quantity -->
<t t-esc="TotalQuantity"/>
</span>
</div>
</div>
</xpath>
</t>
</templates>

18
total_quantity_pos/static/src/overrides/models/models.js

@ -0,0 +1,18 @@
/** @odoo-module */
import { Order } from "@point_of_sale/app/store/models";
import { patch } from "@web/core/utils/patch";
patch(Order.prototype, {
/**
* Extends the export_for_printing method to customize the printing data.
* Removes the 'removeLine' property from each order line.
* @returns {Object} The modified printing data.
*/
export_for_printing() {
const result = super.export_for_printing(...arguments);
result.TotalQuantity = this.orderlines.map(item => parseFloat(item["quantity"])).reduce((acc, value) => acc + value, 0);
result.ItemCount = this.orderlines.length;
return result;
},
});

1
total_quantity_pos/static/src/xml/product_screen.xml

@ -21,6 +21,7 @@
t-value="total_qty + line.quantity"/>
</t>
<t t-esc="total_qty"/>
<t t-log="total_qty,'total_qty'"/>
</span>
<br/>
<br/>

45
total_quantity_pos/views/res_config_settings.views.xml

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Views adding in the Configuration view of PoS settings -->
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.total.quantity.pos</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="//block[@id='pos_interface_section']"
position="after">
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="total_items"/>
</div>
<div class="o_setting_right_pane">
<label for="total_items" string="Enable Total Items"/>
<div class="text-muted">
Allow to show the total items and quantities in pos screen.
</div>
</div>
</div>
</div>
</xpath>
<xpath expr="//block[@id='pos_bills_and_receipts_section']"
position="after">
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="total_quantity"/>
</div>
<div class="o_setting_right_pane">
<label for="total_quantity" string="Enable Total Items"/>
<div class="text-muted">
Allow to add the total items and quantities in the bill.
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save