Skip to content

Commit

Permalink
[MIG] fiscal_epos_print: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Oct 5, 2023
1 parent a415e57 commit 35ac919
Show file tree
Hide file tree
Showing 30 changed files with 1,004 additions and 640 deletions.
15 changes: 8 additions & 7 deletions fiscal_epos_print/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ ITA - Driver per stampanti fiscali compatibili ePOS-Print XML
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-italy/tree/14.0/fiscal_epos_print
:target: https://github.com/OCA/l10n-italy/tree/16.0/fiscal_epos_print
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-fiscal_epos_print
:target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-fiscal_epos_print
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/122/14.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/l10n-italy&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Expand Down Expand Up @@ -83,7 +83,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
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
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20fiscal_epos_print%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20fiscal_epos_print%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand All @@ -109,6 +109,7 @@ Contributors

* Alessio Gerace
* Roberto Fichera
* Giuseppe Borruso <[email protected]>

Maintainers
~~~~~~~~~~~
Expand All @@ -131,6 +132,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-eLBati|

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/14.0/fiscal_epos_print>`_ project on GitHub.
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/16.0/fiscal_epos_print>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
54 changes: 39 additions & 15 deletions fiscal_epos_print/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"name": "ITA - Driver per stampanti fiscali compatibili ePOS-Print XML",
"version": "14.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Point Of Sale",
"summary": "ePOS-Print XML Fiscal Printer Driver - Stampanti Epson compatibili: "
"FP81II, FP90III",
Expand All @@ -25,21 +25,45 @@
"data": [
"views/account.xml",
"views/point_of_sale.xml",
"views/assets.xml",
],
"qweb": [
# Popups
"static/src/xml/Popups/RefundInfoPopup.xml",
# Others
"static/src/xml/Chrome.xml",
"static/src/xml/ChromeWidgets/EpsonEPOSButton.xml",
"static/src/xml/ChromeWidgets/EpsonFP81IIComponent.xml",
"static/src/xml/ChromeWidgets/SetLotteryCodeButton.xml",
"static/src/xml/ChromeWidgets/SetRefundInfoButton.xml",
# TODO To be converted with new components system
# 'static/src/xml/pos.xml',
# 'static/src/xml/lottery.xml',
],
"assets": {
"point_of_sale.assets": [
"fiscal_epos_print/static/lib/pikaday/pikaday.min.css",
"fiscal_epos_print/static/src/css/pos.css",
"fiscal_epos_print/static/lib/fiscalprint/fiscalprint.js",
"fiscal_epos_print/static/lib/pikaday/pikaday.min.js",
"fiscal_epos_print/static/src/js/epson_epos_print.js",
"fiscal_epos_print/static/src/js/models.js",
# TODO is this necessary?
# "fiscal_epos_print/static/src/js/popups.js",
# "fiscal_epos_print/static/src/js/pos_order_mgmt.js",
# ChromeWidgets
"fiscal_epos_print/static/src/js/ChromeWidgets/EpsonEPOSButton.js",
"fiscal_epos_print/static/src/js/ChromeWidgets/EpsonFP81IIComponent.js",
# TODO Unstable components that must be checked
# NOTE: New components SetLottery and SetRefund
"fiscal_epos_print/static/src/js/ChromeWidgets/SetLotteryCodeButton.js",
"fiscal_epos_print/static/src/js/ChromeWidgets/SetRefundInfoButton.js",
# Popups
"fiscal_epos_print/static/src/js/Popups/LotteryCodePopup.js",
"fiscal_epos_print/static/src/js/Popups/RefundInfoPopup.js",
# Screens
"fiscal_epos_print/static/src/js/Screens/PaymentScreen/PaymentScreen.js",
"fiscal_epos_print/static/src/js/Screens/ReceiptScreen/ReceiptScreen.js",
# Popups
"fiscal_epos_print/static/src/xml/Popups/LotteryCodePopup.xml",
"fiscal_epos_print/static/src/xml/Popups/RefundInfoPopup.xml",
# Others
"fiscal_epos_print/static/src/xml/Chrome.xml",
"fiscal_epos_print/static/src/xml/ChromeWidgets/EpsonEPOSButton.xml",
"fiscal_epos_print/static/src/xml/ChromeWidgets/EpsonFP81IIComponent.xml",
"fiscal_epos_print/static/src/xml/ChromeWidgets/SetLotteryCodeButton.xml",
"fiscal_epos_print/static/src/xml/ChromeWidgets/SetRefundInfoButton.xml",
# TODO To be converted with new components system
# "fiscal_epos_print/static/src/xml/pos.xml",
# "fiscal_epos_print/static/src/xml/lottery.xml",
],
},
"installable": True,
"auto_install": False,
}
4 changes: 4 additions & 0 deletions fiscal_epos_print/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from . import pos_payment
from . import pos_payment_method
from . import point_of_sale
from . import account
from . import account_journal
from . import pos_order
from . import pos_session
from . import res_config_settings
2 changes: 1 addition & 1 deletion fiscal_epos_print/models/point_of_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ class PosConfig(models.Model):
show_receipt_when_printing = fields.Boolean(
string="Show receipt on screen when printing", default=True
)
fiscal_printer_serial = fields.Char(string="Fiscal Printer Serial")
fiscal_printer_serial = fields.Char()

fiscal_cashdrawer = fields.Boolean(string="Fiscal Printer Open CashDrawer")
81 changes: 50 additions & 31 deletions fiscal_epos_print/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,48 @@ class PosOrder(models.Model):
fiscal_receipt_amount = fields.Float("Fiscal receipt amount")
fiscal_receipt_date = fields.Date("Fiscal receipt date")
fiscal_z_rep_number = fields.Integer("Fiscal closure number")
fiscal_printer_serial = fields.Char(string="Fiscal Printer Serial")
fiscal_printer_serial = fields.Char()
fiscal_printer_debug_info = fields.Text("Debug info", readonly=True)

# TODO allow to save code on customer and load customer, if present
lottery_code = fields.Char(string="Lottery Code")
lottery_code = fields.Char()

@api.model
def _order_fields(self, ui_order):
res = super(PosOrder, self)._order_fields(ui_order)
res["lottery_code"] = ui_order.get("lottery_code")
res["refund_date"] = ui_order["refund_date"] or False
res["refund_report"] = ui_order["refund_report"] or False
res["refund_doc_num"] = ui_order["refund_doc_num"] or False
res["refund_cash_fiscal_serial"] = (
ui_order["refund_cash_fiscal_serial"] or False
res["lottery_code"] = ui_order.get("lottery_code", "")
res["refund_date"] = ui_order.get("refund_date", False)
res["refund_report"] = ui_order.get("refund_report", False)
res["refund_doc_num"] = ui_order.get("refund_doc_num", False)
res["refund_cash_fiscal_serial"] = ui_order.get(

Check warning on line 31 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L26-L31

Added lines #L26 - L31 were not covered by tests
"refund_cash_fiscal_serial", False
)
res["fiscal_receipt_number"] = ui_order["fiscal_receipt_number"] or False
res["fiscal_receipt_amount"] = ui_order["fiscal_receipt_amount"] or False
res["fiscal_receipt_date"] = ui_order["fiscal_receipt_date"] or False
res["fiscal_z_rep_number"] = ui_order["fiscal_z_rep_number"] or False
res["fiscal_printer_serial"] = ui_order["fiscal_printer_serial"] or False
res["fiscal_printer_debug_info"] = (
ui_order["fiscal_printer_debug_info"] or False
res["fiscal_receipt_number"] = ui_order.get("fiscal_receipt_number", False)
res["fiscal_receipt_amount"] = ui_order.get("fiscal_receipt_amount", False)
res["fiscal_receipt_date"] = ui_order.get("fiscal_receipt_date", False)
res["fiscal_z_rep_number"] = ui_order.get("fiscal_z_rep_number", False)
res["fiscal_printer_serial"] = ui_order.get("fiscal_printer_serial", False)
res["fiscal_printer_debug_info"] = ui_order.get(

Check warning on line 39 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L34-L39

Added lines #L34 - L39 were not covered by tests
"fiscal_printer_debug_info", False
)
return res

Check warning on line 42 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L42

Added line #L42 was not covered by tests

# This is on pos_order_mgmt to send back the fields of already existing
# pos.order
def _prepare_done_order_for_pos(self):
res = super(PosOrder, self)._prepare_done_order_for_pos()
res["lottery_code"] = self.lottery_code
res["refund_date"] = self.refund_date
res["refund_report"] = self.refund_report
res["refund_doc_num"] = self.refund_doc_num
res["refund_cash_fiscal_serial"] = self.refund_cash_fiscal_serial
res["fiscal_receipt_number"] = self.fiscal_receipt_number
res["fiscal_receipt_amount"] = self.fiscal_receipt_amount
res["fiscal_receipt_date"] = self.fiscal_receipt_date
res["fiscal_z_rep_number"] = self.fiscal_z_rep_number
res["fiscal_printer_serial"] = self.fiscal_printer_serial
res["fiscal_printer_debug_info"] = self.fiscal_printer_debug_info
return res
# def _prepare_done_order_for_pos(self):
# res = super(PosOrder, self)._prepare_done_order_for_pos()
# res["lottery_code"] = self.lottery_code
# res["refund_date"] = self.refund_date
# res["refund_report"] = self.refund_report
# res["refund_doc_num"] = self.refund_doc_num
# res["refund_cash_fiscal_serial"] = self.refund_cash_fiscal_serial
# res["fiscal_receipt_number"] = self.fiscal_receipt_number
# res["fiscal_receipt_amount"] = self.fiscal_receipt_amount
# res["fiscal_receipt_date"] = self.fiscal_receipt_date
# res["fiscal_z_rep_number"] = self.fiscal_z_rep_number
# res["fiscal_printer_serial"] = self.fiscal_printer_serial
# res["fiscal_printer_debug_info"] = self.fiscal_printer_debug_info
# return res

@api.model
def update_fiscal_receipt_debug_info(self, pos_order):
Expand Down Expand Up @@ -95,10 +95,29 @@ def update_fiscal_receipt_values(self, pos_order):

@api.model
def create_from_ui(self, orders, draft=False):
res = super(PosOrder, self).create_from_ui(orders)
order_ids = super(PosOrder, self).create_from_ui(orders, draft)

Check warning on line 98 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L98

Added line #L98 was not covered by tests
for order in orders:
if order["data"].get("fiscal_receipt_number"):
self.update_fiscal_receipt_values(order["data"])

Check warning on line 101 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L101

Added line #L101 was not covered by tests
if order["data"].get("fiscal_printer_debug_info"):
self.update_fiscal_receipt_debug_info(order["data"])
return res
return order_ids

Check warning on line 104 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L103-L104

Added lines #L103 - L104 were not covered by tests

def _export_for_ui(self, order):
result = super(PosOrder, self)._export_for_ui(order)
result.update(

Check warning on line 108 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L107-L108

Added lines #L107 - L108 were not covered by tests
{
"lottery_code": order.lottery_code,
"refund_date": order.refund_date,
"refund_report": order.refund_report,
"refund_doc_num": order.refund_doc_num,
"refund_cash_fiscal_serial": order.refund_cash_fiscal_serial,
"fiscal_receipt_number": order.fiscal_receipt_number,
"fiscal_receipt_amount": order.fiscal_receipt_amount,
"fiscal_receipt_date": order.fiscal_receipt_date,
"fiscal_z_rep_number": order.fiscal_z_rep_number,
"fiscal_printer_serial": order.fiscal_printer_serial,
"fiscal_printer_debug_info": order.fiscal_printer_debug_info,
}
)
return result

Check warning on line 123 in fiscal_epos_print/models/pos_order.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_order.py#L123

Added line #L123 was not covered by tests
26 changes: 1 addition & 25 deletions fiscal_epos_print/models/pos_payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import fields, models
from odoo import models


class PosPayment(models.Model):
Expand All @@ -13,27 +13,3 @@ def _export_for_ui(self, payment):
"fiscalprinter_payment_index"
] = payment.payment_method_id.fiscalprinter_payment_index
return res

Check warning on line 15 in fiscal_epos_print/models/pos_payment.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_payment.py#L15

Added line #L15 was not covered by tests


class PosPaymentMethod(models.Model):
_inherit = "pos.payment.method"

fiscalprinter_payment_type = fields.Selection(
[
("0", "Cash"),
("1", "Cheque"),
("2", "Credit or Credit Card"),
("3", "Ticket"),
("4", "Ticket with number"),
("5", "No Paid"),
("6", "Discount on payment"),
],
"Payment type",
help="The payment type to send to the Fiscal Printer.",
default="0",
)

fiscalprinter_payment_index = fields.Integer(
string="Electronic Payment / Ticket Index",
help="Set the index of the given payment type to specify the detail.",
)
25 changes: 25 additions & 0 deletions fiscal_epos_print/models/pos_payment_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from odoo import fields, models


class PosPaymentMethod(models.Model):
_inherit = "pos.payment.method"

fiscalprinter_payment_type = fields.Selection(
[
("0", "Cash"),
("1", "Cheque"),
("2", "Credit or Credit Card"),
("3", "Ticket"),
("4", "Ticket with number"),
("5", "No Paid"),
("6", "Discount on payment"),
],
"Payment type",
help="The payment type to send to the Fiscal Printer.",
default="0",
)

fiscalprinter_payment_index = fields.Integer(
string="Electronic Payment / Ticket Index",
help="Set the index of the given payment type to specify the detail.",
)
20 changes: 20 additions & 0 deletions fiscal_epos_print/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 Dinamiche Aziendali srl
# @author: Giuseppe Borruso <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


class PosSession(models.Model):
_inherit = "pos.session"

def _loader_params_pos_payment_method(self):
result = super()._loader_params_pos_payment_method()
result["search_params"]["fields"].append("fiscalprinter_payment_type")
result["search_params"]["fields"].append("fiscalprinter_payment_index")
return result

Check warning on line 15 in fiscal_epos_print/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_session.py#L12-L15

Added lines #L12 - L15 were not covered by tests

def _loader_params_account_tax(self):
result = super()._loader_params_account_tax()
result["search_params"]["fields"].append("fpdeptax")
return result

Check warning on line 20 in fiscal_epos_print/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

fiscal_epos_print/models/pos_session.py#L18-L20

Added lines #L18 - L20 were not covered by tests
17 changes: 17 additions & 0 deletions fiscal_epos_print/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import fields, models


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

printer_ip = fields.Char(related="pos_config_id.printer_ip", readonly=False)
use_https = fields.Boolean(related="pos_config_id.use_https", readonly=False)
show_receipt_when_printing = fields.Boolean(
related="pos_config_id.show_receipt_when_printing", readonly=False
)
fiscal_printer_serial = fields.Char(
related="pos_config_id.fiscal_printer_serial", readonly=False
)
fiscal_cashdrawer = fields.Boolean(
related="pos_config_id.fiscal_cashdrawer", readonly=False
)
1 change: 1 addition & 0 deletions fiscal_epos_print/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

* Alessio Gerace
* Roberto Fichera
* Giuseppe Borruso <[email protected]>
Loading

0 comments on commit 35ac919

Please sign in to comment.