-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from kmee/feature/15.0-sale_order_pos_report
[IMP] sale_order_pos_report: add button to show pdf in another tab.
- Loading branch information
Showing
7 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import sale_order_pos_report |
20 changes: 20 additions & 0 deletions
20
sale_order_pos_report/controllers/sale_order_pos_report.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from odoo import http | ||
from odoo.http import request | ||
|
||
|
||
class SaleOrderPosController(http.Controller): | ||
@http.route("/sale_order_pos_report/<int:sale_order_id>", type="http", auth="user") | ||
def store_ticket_report(self, sale_order_id, **post): | ||
sale_order = request.env["sale.order"].browse(sale_order_id) | ||
if not sale_order.exists(): | ||
return request.not_found() | ||
|
||
pdf = request.env.ref( | ||
"sale_order_pos_report.action_report_saleorder_compact" | ||
)._render_qweb_pdf(sale_order.ids)[0] | ||
response = request.make_response(pdf) | ||
response.headers["Content-Type"] = "application/pdf" | ||
response.headers[ | ||
"Content-Disposition" | ||
] = f'inline; filename="sale_order_{sale_order_id}.pdf"' | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import res_config_settings | ||
from . import res_company | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
|
||
_inherit = "sale.order" | ||
|
||
def action_pos_report(self): | ||
self.ensure_one() | ||
return { | ||
"type": "ir.actions.act_url", | ||
"url": f"/sale_order_pos_report/{self.id}", | ||
"target": "new", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 KMEE | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record id="view_order_form" model="ir.ui.view"> | ||
<field name="name">sale.order.form (sale_order_pos_report)</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//header" position="inside"> | ||
<button | ||
name="action_pos_report" | ||
string="POS Print" | ||
type="object" | ||
class="oe_highlight" | ||
attrs="{'invisible': [('state', 'not in', ('sale', 'done'))]}" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |