From 739dc78e70c0a23d7d3a9bba0aa8b96e1ee98239 Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Tue, 17 Dec 2019 07:48:37 +0000 Subject: [PATCH] :zap: implemted printing invoice lines in receipts and fixed some errors --- pos_invoice_pay/__manifest__.py | 2 +- pos_invoice_pay/doc/changelog.rst | 7 +++ pos_invoice_pay/models.py | 24 ++++------ pos_invoice_pay/report/report.py | 28 ++++++------ pos_invoice_pay/static/src/xml/pos.xml | 61 +++++++++++++++++++++++--- pos_invoice_pay/view.xml | 4 ++ 6 files changed, 91 insertions(+), 35 deletions(-) diff --git a/pos_invoice_pay/__manifest__.py b/pos_invoice_pay/__manifest__.py index dfdb477be9..d3b6dc745f 100644 --- a/pos_invoice_pay/__manifest__.py +++ b/pos_invoice_pay/__manifest__.py @@ -7,7 +7,7 @@ "category": "Point of Sale", # "live_test_url": "http://apps.it-projects.info/shop/product/pos-invoice-pay?version=11.0", "images": ["images/pos_invoice_pay_main.png"], - "version": "11.0.1.2.3", + "version": "11.0.1.3.0", "application": False, "author": "IT-Projects LLC, Artyom Losev", "support": "pos@it-projects.info", diff --git a/pos_invoice_pay/doc/changelog.rst b/pos_invoice_pay/doc/changelog.rst index cc774ae8f7..7a8e5f51ec 100644 --- a/pos_invoice_pay/doc/changelog.rst +++ b/pos_invoice_pay/doc/changelog.rst @@ -1,3 +1,10 @@ +`1.3.0` +------- + +**New:** Implement printing invoice lines in receipts +**Fix:** Fixed field properties typo in sale_order_cashier_selection and invoice_cashier_selection +**Fix:** Fixed "'bool' object has no attribute 'mapped'" error in get_sale_details + `1.2.3` ------- diff --git a/pos_invoice_pay/models.py b/pos_invoice_pay/models.py index 42dad264bf..8f32767de5 100644 --- a/pos_invoice_pay/models.py +++ b/pos_invoice_pay/models.py @@ -158,23 +158,15 @@ def _get_default_writeoff_account(self): return acc if acc else False show_invoices = fields.Boolean(help="Show invoices in POS", default=True) + show_invoice_lines_in_receipt = fields.Boolean(help="Show invoice lines in receipt", default=False) show_sale_orders = fields.Boolean(help="Show sale orders in POS", default=True) - pos_invoice_pay_writeoff_account_id = fields.Many2one( - "account.account", - string="Difference Account", - help="The account is used for the difference between due and paid amount", - default=_get_default_writeoff_account, - ) - invoice_cashier_selection = fields.Boolean( - string="Select Invoice Cashier", - help="Ask for a cashier when fetch invoices", - defaul=True, - ) - sale_order_cashier_selection = fields.Boolean( - string="Select Sale Order Cashier", - help="Ask for a cashier when fetch orders", - defaul=True, - ) + pos_invoice_pay_writeoff_account_id = fields.Many2one('account.account', string="Difference Account", + help="The account is used for the difference between due and paid amount", + default=_get_default_writeoff_account) + invoice_cashier_selection = fields.Boolean(string='Select Invoice Cashier', + help='Ask for a cashier when fetch invoices', default=True) + sale_order_cashier_selection = fields.Boolean(string='Select Sale Order Cashier', + help='Ask for a cashier when fetch orders', default=True) class PosSession(models.Model): diff --git a/pos_invoice_pay/report/report.py b/pos_invoice_pay/report/report.py index 3be6a22290..f89e2254f7 100644 --- a/pos_invoice_pay/report/report.py +++ b/pos_invoice_pay/report/report.py @@ -1,5 +1,6 @@ # Copyright 2018 Artyom Losev # Copyright 2018 Kolushov Alexandr +# Copyright 2019 Eugene Molotov # License MIT (https://opensource.org/licenses/MIT). from odoo import api, models @@ -11,19 +12,20 @@ class ReportSaleDetails(models.AbstractModel): @api.model def get_sale_details(self, date_start=False, date_stop=False, configs=False): - res = super(ReportSaleDetails, self).get_sale_details( - date_start, date_stop, configs - ) - - payments = self.env["account.payment"].search( - [ - ("datetime", ">=", date_start), - ("datetime", "<=", date_stop), - ("pos_session_id", "in", configs.mapped("session_ids").ids), - ] - ) - - res["invoices"] = [] + res = super(ReportSaleDetails, self).get_sale_details(date_start, date_stop, configs) + + # reference: + # https://github.com/odoo/odoo/blob/560dba5313c5ca5265190dacc3bce7cbe509d30a/addons/point_of_sale/models/pos_order.py#L1120-L1121 + if not configs: + configs = self.env['pos.config'].search([]) + + payments = self.env['account.payment'].search([ + ('datetime', '>=', date_start), + ('datetime', '<=', date_stop), + ('pos_session_id', 'in', configs.mapped('session_ids').ids) + ]) + + res['invoices'] = [] unique = [] res["total_invoices"] = res["total_invoices_cash"] = 0.0 for p in payments: diff --git a/pos_invoice_pay/static/src/xml/pos.xml b/pos_invoice_pay/static/src/xml/pos.xml index 5aba072473..227e01d71c 100644 --- a/pos_invoice_pay/static/src/xml/pos.xml +++ b/pos_invoice_pay/static/src/xml/pos.xml @@ -436,11 +436,32 @@
-
- Phone:
- User:
+ + + + + + + + + + + + + +
+ + + + + +
+
+
+ +
+ Phone:
+ User:

@@ -583,6 +604,36 @@

+ + + +
+ + + + + + + + + + + + x + + + + + + + + + + + +
+
+
Subtotal: diff --git a/pos_invoice_pay/view.xml b/pos_invoice_pay/view.xml index bc286ff229..ffecdac383 100644 --- a/pos_invoice_pay/view.xml +++ b/pos_invoice_pay/view.xml @@ -39,6 +39,10 @@
+
+