Skip to content

Commit

Permalink
⚡ implemted printing invoice lines in receipts and fixed some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
em230418 authored and trojikman committed Jun 8, 2020
1 parent bded522 commit 739dc78
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pos_invoice_pay/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
Expand Down
7 changes: 7 additions & 0 deletions pos_invoice_pay/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -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`
-------

Expand Down
24 changes: 8 additions & 16 deletions pos_invoice_pay/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
28 changes: 15 additions & 13 deletions pos_invoice_pay/report/report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2018 Artyom Losev
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2019 Eugene Molotov <https://it-projects.info/team/em230418>
# License MIT (https://opensource.org/licenses/MIT).

from odoo import api, models
Expand All @@ -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:
Expand Down
61 changes: 56 additions & 5 deletions pos_invoice_pay/static/src/xml/pos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,32 @@
</div>
<br />

<t t-esc="widget.pos.company.name" /><br />
Phone: <t t-esc="widget.pos.company.phone || ''" /><br />
User: <t
t-esc="widget.pos.cashier ? widget.pos.cashier.name : widget.pos.user.name"
/><br />
<t t-if='widget.pos.config.show_invoice_lines_in_receipt'>
<!-- based on https://github.com/odoo/odoo/blob/5235a49a5cd0f79f5590c96afa26dce25465fe06/addons/point_of_sale/static/src/xml/pos.xml#L1466-L1489 -->
<table class='receipt-orderlines'>
<colgroup>
<col width='50%' />
<col width='25%' />
<col width='25%' />
</colgroup>
<tr t-foreach="order.invoice_to_pay.lines" t-as="orderline">
<td>
<t t-esc="orderline.name" />
</td>
<td class="pos-right-align">
<t t-esc="orderline.qty" />
</td>
<td class="pos-right-align">
<t t-esc="widget.format_currency(orderline.amount)" />
</td>
</tr>
</table>
<br />
</t>

<t t-esc="widget.pos.company.name"/><br />
Phone: <t t-esc="widget.pos.company.phone || ''"/><br />
User: <t t-esc="widget.pos.cashier ? widget.pos.cashier.name : widget.pos.user.name"/><br />
<br />
<t t-if="receipt.header">
<div style='text-align:center'>
Expand Down Expand Up @@ -583,6 +604,36 @@
</t>
</div>
<br />

<!-- Orderlines -->
<t t-if='widget.pos.config.show_invoice_lines_in_receipt'>
<div class='orderlines' line-ratio='0.6'>
<t t-foreach='order.invoice_to_pay.lines' t-as='line'>
<line line-ratio='1'>
<left>
<t t-esc="line.name" />
</left>
</line>
<line indent='1'>
<left>
<value value-autoint='on'>
<t t-esc='line.qty' />
</value>
x
<value value-autoint='on'>
<t t-esc='line.price_unit' />
</value>
</left>
<right>
<value>
<t t-esc='line.amount' />
</value>
</right>
</line>
</t>
</div>
</t>

<div>
<line>
<left>Subtotal:</left>
Expand Down
4 changes: 4 additions & 0 deletions pos_invoice_pay/view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<label for="invoice_cashier_selection" />
<field name="invoice_cashier_selection" />
</div>
<div attrs="{'invisible':[('show_invoices','=',False)]}">
<label for="show_invoice_lines_in_receipt"/>
<field name="show_invoice_lines_in_receipt"/>
</div>
</div>
</div>
<div id="show_sale_orders" class="col-xs-12 col-md-6 o_setting_box">
Expand Down

0 comments on commit 739dc78

Please sign in to comment.