Skip to content

Commit

Permalink
[UPD] fiscal_epos_print: aggiornata PR OCA#3060
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Apr 10, 2024
1 parent 3d11ace commit f162521
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 231 deletions.
49 changes: 0 additions & 49 deletions fiscal_epos_print/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging

from odoo import api, fields, models
from odoo.tools import float_is_zero

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -49,54 +48,6 @@ def _order_fields(self, ui_order):
res["fiscal_operator_number"] = ui_order.get("fiscal_operator_number", False)
return res

@api.model
def create_from_ui(self, orders, draft=False):
if self.env.company.country_id.id == self.env.ref("base.it").id:
draft = True
order_ids = super().create_from_ui(orders, draft)
process_order_ids = []
for order in orders:
if order["data"].get("pricelist_id", False):
pricelist_id = self.env["product.pricelist"].browse(
order["data"]["pricelist_id"]
)
precision = pricelist_id.currency_id.decimal_places
else:
precision = self.env.company.currency_id.decimal_places
if (
order["data"].get("fiscal_receipt_number", False)
or order["data"].get("to_invoice", False)
or float_is_zero(order["data"].get("amount_total", 0), precision)
) and self.env.company.country_id.id == self.env.ref("base.it").id:
order_name = order["data"].get("name")
try:
existing_draft_orders = self.search(
[
("pos_reference", "=", order_name),
("state", "=", "draft"),
]
)
for existing_draft_order in existing_draft_orders:
process_order_ids.append(
self._process_order(order, False, existing_draft_order)
)
except Exception as e:
_logger.exception(
"An error occurred when processing the PoS order %s", order_name
)
pos_session = self.env["pos.session"].browse(
order["data"].get("pos_session_id", 0)
)
pos_session._handle_order_process_fail(order, e, draft)
raise
if process_order_ids:
order_ids = self.env["pos.order"].search_read(
domain=[("id", "in", process_order_ids)],
fields=["id", "pos_reference", "account_move"],
load=False,
)
return order_ids

def _export_for_ui(self, order):
result = super()._export_for_ui(order)
result.update(
Expand Down
25 changes: 14 additions & 11 deletions fiscal_epos_print/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
**Italiano**

- stampare la lista dei reparti della vostra stampante fiscale
- mappare le imposta di vendita di odoo con i gruppi di imposte - dipartimenti della
stampante fiscale, per ogni imposta di vendita in odoo, usando il campo "Reparto sulla
stampante fiscale 1~99"
- mappare le imposta di vendita di odoo con i gruppi di imposte -
dipartimenti della stampante fiscale, per ogni imposta di vendita in
odoo, usando il campo "Reparto sulla stampante fiscale 1~99"
- in odoo, utilizzare imposte incluse nel prezzo
- connettere la vostra stampante fiscale alla rete locale e recuperare l'IP
- aprire la configurazione POS e impostare l'indirizzo IP e il seriale della stampante
nella sezione "Stampante Fiscale"
- è tutto, alla validazione del pagamento nella sessione POS, il sistema stamperà lo
scontrino fiscale.
- connettere la vostra stampante fiscale alla rete locale e recuperare
l'IP
- aprire la configurazione POS e impostare l'indirizzo IP e il seriale
della stampante nella sezione "Stampante Fiscale"
- è tutto, alla validazione del pagamento nella sessione POS, il sistema
stamperà lo scontrino fiscale.

**English**

- print list departments of your fiscal printer
- map odoo sale taxes with taxes groups - departments of fiscal printer, for each sale
tax on odoo, using field "Department on fiscal printer 1~99"
- map odoo sale taxes with taxes groups - departments of fiscal printer,
for each sale tax on odoo, using field "Department on fiscal printer
1~99"
- in odoo, use taxes included in price
- connect your fiscal printer to local network and find IP
- open POS configuration and fill Printer IP Address field
- that's all, at validation of payment on POS session, system prints fiscal receipt.
- that's all, at validation of payment on POS session, system prints
fiscal receipt.
8 changes: 4 additions & 4 deletions fiscal_epos_print/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**Italiano**

Questo modulo permette di stampare gli scontrini del punto vendita, su stampanti fiscali
Epson, tramite protocollo EPos
Questo modulo permette di stampare gli scontrini del punto vendita, su
stampanti fiscali Epson, tramite protocollo EPos

Stampanti supportate:

Expand All @@ -10,8 +10,8 @@ Stampanti supportate:

**English**

This module allows to print receipt of point of sale, on fiscal printers Epson, via EPos
protocol.
This module allows to print receipt of point of sale, on fiscal printers
Epson, via EPos protocol.

Supported printers:

Expand Down
4 changes: 2 additions & 2 deletions fiscal_epos_print/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- Resi:
- Aggiungere controllo "rendibilità"
- Stampare sullo scontrino un barcode identificativo, in modo da generare il reso
facendone la scansione
- Stampare sullo scontrino un barcode identificativo, in modo da
generare il reso facendone la scansione
2 changes: 1 addition & 1 deletion fiscal_epos_print/static/src/css/pos.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
width: 236px;
font-size: 14px;

background: rgba(0, 0, 0, 0.82);
background: rgba(0, 0, 0, 0.82) !important;
color: white;
padding-bottom: 10px;
cursor: move;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ odoo.define("fiscal_epos_print.EpsonFP81IIComponent", function (require) {
body: _t("Close"),
});
if (confirmed) {
this.resetPrinter();
fp90.resetPrinter();
} else {
// TODO not exist
// this.chrome.loading_hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,31 @@ odoo.define("fiscal_epos_print.PaymentScreen", function (require) {
}
}

sendToFP90Printer(receipt, printer_options) {
var fp90 = new eposDriver(printer_options, this);
fp90.printFiscalReceipt(receipt);
// This line causes problems on bill split. What's the sense of deleting the actual pos context?!
// It regenerates orders wich are already partly paid using split function...
// this.env.pos.context = {};
}

async _finalizeValidation() {
// We need to get currentOrder before calling the _super()
// otherwise we will likely get a empty order when we want to skip
// the receipt preview
var currentOrder = this.currentOrder;
await super._finalizeValidation();
if (this.env.pos.config.printer_ip && !currentOrder.is_to_invoice()) {
async sendToFP90Printer(order) {
if (this.env.pos.config.printer_ip && !order.is_to_invoice()) {
// TODO self.chrome does not exists
// this.chrome.loading_show();
// this.chrome.loading_message(_t('Connecting to the fiscal printer'));
if (
currentOrder.has_refund &&
order.has_refund &&
this.env.pos.context &&
this.env.pos.context.refund_details
) {
currentOrder.refund_date = this.env.pos.context.refund_date;
currentOrder.refund_report = this.env.pos.context.refund_report;
currentOrder.refund_doc_num =
this.env.pos.context.refund_doc_num;
currentOrder.refund_cash_fiscal_serial =
order.refund_date = this.env.pos.context.refund_date;
order.refund_report = this.env.pos.context.refund_report;
order.refund_doc_num = this.env.pos.context.refund_doc_num;
order.refund_cash_fiscal_serial =
this.env.pos.context.refund_cash_fiscal_serial;
}

var printer_options = currentOrder.getPrinterOptions();
printer_options.order = currentOrder;
var receipt = currentOrder.export_for_printing();
this.sendToFP90Printer(receipt, printer_options);
var printer_options = order.getPrinterOptions();
printer_options.order = order;
var receipt = order.export_for_printing();
var fp90 = new eposDriver(printer_options, this);
fp90.printFiscalReceipt(receipt);
// This line causes problems on bill split. What's the sense of deleting the actual pos context?!
// It regenerates orders wich are already partly paid using split function...
// this.env.pos.context = {};
}
}

Expand Down
4 changes: 2 additions & 2 deletions fiscal_epos_print/static/src/js/epson_epos_print.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
JSON.stringify(tag_list_names) +
"\n" +
JSON.stringify(add_info);
sender.env.pos.push_single_order(order);
// Sender.env.pos.push_single_order(order);
}
if (tagStatus.length > 0) {
info = add_info[tagStatus[0]];
Expand Down Expand Up @@ -244,7 +244,7 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
sender.env.pos.config.fiscal_printer_serial;
// Sender.env.pos.db.add_order(order.export_as_JSON());
// Try to save the order
sender.env.pos.push_single_order(order);
// sender.env.pos.push_single_order(order);
}
if (sender.env.pos.config.fiscal_cashdrawer) {
self.printOpenCashDrawer();
Expand Down
8 changes: 0 additions & 8 deletions fiscal_epos_print/static/src/xml/lottery.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="lottery_template" xml:space="preserve">

<!-- Moved inside SetLotteryCodeButton.xml -->
<!-- <t t-name="SetLotteryCodeButton">
<div id="lottery_code_button" class='control-button'>
<i class='fa fa-pencil-square-o'/>
Lottery Code
</div>
</t> -->

<t t-name="LotteryCodePopupWidget">
<div class="modal-dialog">
<div class="popup popup-text">
Expand Down
128 changes: 0 additions & 128 deletions fiscal_epos_print/static/src/xml/pos.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">

<!-- Moved inside EpostonEPOSButton.xml -->
<!-- <t t-name="EpsonEPOSWidget">
<div class="header-button">
<img src="/fiscal_epos_print/static/src/img/epos.svg" alt="Epson ePOS" title="Epson ePOS Operation" />
</div>
</t> -->

<t t-extend="PosTicket">
<t t-jquery="div[class='pos-sale-ticket']" t-operation="after">
<div class="button disabled receipt-sent" t-if="!order.is_to_invoice()">
Expand All @@ -31,125 +24,4 @@
</t>
</t>

<!-- Moved inside SetRefundInfoButton.xml -->
<!-- <t t-name="SetRefundInfoButton">
<div id="refund_info_button" class='control-button'>
<i class='fa fa-pencil-square-o'/>
Refund Data
</div>
</t> -->

<!-- MOVED INSIDE RefundInfoPopup -->
<!-- <t t-name="RefundInfoPopupWidget">
<div class="modal-dialog">
<div class="popup popup-text">
<p class="title">
<t t-esc=" widget.options.title || '' "/>
</p>
<div class='client-detail'>
<div class='label'>Closing Seq.</div>
<input id="refund_report" class="detail refund_report"
type='text' t-att-value="widget.options.refund_report || ''" placeholder="Max 4 numbers"/>
</div>
<div class='client-detail'>
<div class='label'>Receipt Num.</div>
<input id="refund_doc_num" class="detail refund_doc_num"
type='text' t-att-value="widget.options.refund_doc_num || ''" placeholder="Max 4 numbers"/>
</div>
<div class='client-detail'>
<div class='label'>Receipt Date</div>
<input id="refund_date" class="detail refund_date" type='text'
t-att-value="widget.options.refund_date || ''"
placeholder="YYYY-MM-DD"/>
</div>
<div class='client-detail'>
<div class='label'>RT Serial</div>
<input id="refund_cash_fiscal_serial" class="detail refund_cash_fiscal_serial" type='text'
t-att-value="widget.options.refund_cash_fiscal_serial || ''" placeholder="RT Serial"/>
</div>
<div class="footer">
<div class="button confirm">
Apply
</div>
<div class="button cancel">
Cancel
</div>
<div id="error-message-dialog"
style="color: red; font-weight: bold; font-size: 18px; font-style: italic; display: none;">
Some fields are empty.
</div>
</div>
</div>
</div>
</t> -->

<!-- Moved inside EpostonFP81IIComponent.xml -->
<!-- <t t-name="EpsonFP81IIWidget">
<div class="epson-fp81ii-widget oe_hidden">
<h1>Epson ePOS</h1>
<div class="toggle"><i class='fa fa-times'/></div>
<div class="content">
<p class="category">Operations</p>
<ul name="epos_operations">
<li>
<div class="button open_cashdrawer" style="padding-top:5px">
<span>
<img src="/fiscal_epos_print/static/src/img/cashdrawer.svg" alt="Open CashDrawer" title="Open CashDrawer"/>
</span>
<span class="category-label">
Open CashDrawer
</span>
</div>
</li>
<li>
<div class="button reprint_last_receipt" style="padding-top:5px">
<span>
<img src="/fiscal_epos_print/static/src/img/reprint.svg" alt="Reprint Last Receipt" title="Reprint last receipt"/>
</span>
<span class="category-label">
Reprint Last Receipt
</span>
</div>
</li>
</ul>
<p class="category">Reports</p>
<ul name="epos_reports">
<li>
<div class="button show_ade_status" style="padding-top:5px">
<span>
<img src="/fiscal_epos_print/static/src/img/ade-logo.svg" alt="IRA status" title="Status of files to be sent to IRA"/>
</span>
<span class="category-label">
IRA status
</span>
</div>
</li>
<li>
<div class="button fiscal_closing" style="padding-top:5px">
<span>
<img src="/fiscal_epos_print/static/src/img/Z.svg" alt="Fiscal closure" title="Send fiscal closure command to the fiscal printer"/>
</span>
<span class="category-label">
Closure Report Z (Fiscal)
</span>
</div>
</li>
<li>
<div class="button fiscal_xreport" style="padding-top:5px">
<span>
<img src="/fiscal_epos_print/static/src/img/X.svg" alt="Fiscal closure" title="Send fiscal X report to the fiscal printer"/>
</span>
<span class="category-label">
Financial Report X
</span>
</div>
</li>
</ul>
</div>
</div>
</t> -->

</templates>

0 comments on commit f162521

Please sign in to comment.