15 changed files with 104 additions and 194 deletions
@ -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 |
@ -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") |
@ -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.") |
Binary file not shown.
@ -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> |
@ -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 |
|||
} |
|||
}); |
@ -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> |
@ -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,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…
Reference in new issue