-
Notifications
You must be signed in to change notification settings - Fork 2
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 #76 from kmee/add-15.0-sale_order_pos_report_plain…
…_text [ADD] Addons:sale_order_pos_report_plain_text
- Loading branch information
Showing
15 changed files
with
333 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
**This file is going to be generated by oca-gen-addon-readme.** | ||
|
||
*Manual changes will be overwritten.* | ||
|
||
Please provide content in the ``readme`` directory: | ||
|
||
* **DESCRIPTION.rst** (required) | ||
* INSTALL.rst (optional) | ||
* CONFIGURE.rst (optional) | ||
* **USAGE.rst** (optional, highly recommended) | ||
* DEVELOP.rst (optional) | ||
* ROADMAP.rst (optional) | ||
* HISTORY.rst (optional, recommended) | ||
* **CONTRIBUTORS.rst** (optional, highly recommended) | ||
* CREDITS.rst (optional) | ||
|
||
Content of this README will also be drawn from the addon manifest, | ||
from keys such as name, authors, maintainers, development_status, | ||
and license. | ||
|
||
A good, one sentence summary in the manifest is also highly recommended. | ||
|
||
|
||
Automatic changelog generation | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_. | ||
|
||
Just put towncrier compatible changelog fragments into `readme/newsfragments` | ||
and the changelog file will be automatically generated and updated when a new fragment is added. | ||
|
||
Please refer to `towncrier` documentation to know more. | ||
|
||
NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. | ||
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_. |
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,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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2024 KMEE | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Sale Order Pos Report", | ||
"version": "15.0.1.0.0", | ||
"license": "LGPL-3", | ||
"author": "KMEE", | ||
"website": "https://github.com/KMEE/kmee-odoo-addons", | ||
"depends": [ | ||
"sale", | ||
], | ||
"data": [ | ||
"views/sale_order.xml", | ||
"views/res_config_settings.xml", | ||
"report/report_saleorder_compact.xml", | ||
"report/sale_report.xml", | ||
], | ||
"demo": [], | ||
} |
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 |
19 changes: 19 additions & 0 deletions
19
sale_order_pos_report_plain_text/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,19 @@ | ||
from odoo import http | ||
from odoo.http import request | ||
|
||
|
||
class SaleOrderPosController(http.Controller): | ||
@http.route( | ||
"/sale_order_pos_report_plain_text/<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_plain_text.action_report_saleorder_compact" | ||
)._render_qweb_pdf(sale_order.ids)[0] | ||
return request.make_response(pdf) |
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,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,11 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
|
||
_inherit = "res.company" | ||
|
||
logo_order_so_pos_report = fields.Binary(string="Company Logo") |
15 changes: 15 additions & 0 deletions
15
sale_order_pos_report_plain_text/models/res_config_settings.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,15 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
|
||
_inherit = "res.config.settings" | ||
|
||
logo_order_so_pos_report = fields.Binary( | ||
string="Company Logo", | ||
related="company_id.logo_order_so_pos_report", | ||
readonly=False, | ||
) |
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_plain_text/{self.id}", | ||
"target": "new", | ||
} |
98 changes: 98 additions & 0 deletions
98
sale_order_pos_report_plain_text/report/report_saleorder_compact.xml
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,98 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<template id="store_ticket_document_page"> | ||
<pre id="test"> | ||
========================================= | ||
<span t-esc="o.company_id.name" /> | ||
PEDIDO DE VENDA | ||
Data de Emissao: <span t-esc="o.date_order.strftime('%d/%m/%Y %H:%M')" /> | ||
Cliente : <span t-esc="o.partner_id.name" /> | ||
Endereco: OZ | ||
CNPJ: <span t-esc="o.partner_id.vat" /> | ||
Usuario : <span t-esc="o.user_id.name" /> | ||
Numero : <span t-esc="o.name.ljust(18, ' ')" /> Op : 01 | ||
<!-- Deposito : <span t-esc="o.warehouse_id.name"/> --> | ||
========================================= | ||
Qtd Preco Total | ||
----------------------------------------- | ||
<t t-foreach="o.order_line" t-as="line"> | ||
<span t-esc="line.product_id.default_code" /> <span t-esc="line.product_id.name" /> | ||
<span t-esc="str(line.product_uom_qty).ljust(13, ' ')" /> <span | ||
t-esc="str(line.price_unit).center(11,' ')" | ||
/> <span t-esc="str(line.price_subtotal).rjust(13, ' ')" /> | ||
</t> | ||
----------------------------------------- | ||
Total: <span | ||
t-esc="str(sum(o.order_line.mapped('product_uom_qty'))).ljust(12, ' ')" | ||
/> Items: <span t-esc="len(o.order_line)" /> | ||
----------------------------------------- | ||
Subtotal: <span t-esc="str(round(o.amount_undiscounted, 2)).rjust(9, ' ')" /> | ||
Total: <span t-esc="str(o.amount_total).rjust(12, ' ')" /> | ||
----------------------------------------- | ||
Pago : <span t-esc="str(o.payment_term_id.name).ljust(18, ' ')" /> | ||
========================================= | ||
### CONFIRA SUAS MERCADORIAS, NAO | ||
ACEITAMOS RECLAMACOES POSTERIORES ### | ||
Nota para simples controle de estoque, | ||
sem valor fiscal. | ||
</pre> | ||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | ||
</template> | ||
|
||
<template id="store_ticket_document"> | ||
<style> | ||
@media print | ||
{ | ||
pre {page-break-after:always} | ||
|
||
} | ||
pre { | ||
width: 222pt; | ||
white-space: -moz-pre-wrap; | ||
white-space: break-spaces; | ||
word-wrap: break-word; | ||
} | ||
|
||
</style> | ||
<main> | ||
<div id="ticketDiv"> | ||
<t | ||
t-call="sale_order_pos_report_plain_text.store_ticket_document_page" | ||
/> | ||
</div> | ||
<div id="ticketDiv2"> | ||
<t | ||
t-call="sale_order_pos_report_plain_text.store_ticket_document_page" | ||
/> | ||
</div> | ||
</main> | ||
<!-- Open print dialog when content loaded --> | ||
<script type="text/javascript"> | ||
|
||
let height = document.getElementById("test").offsetHeight; | ||
let width = document.getElementById("test").offsetWidth; | ||
|
||
const printPageMedia = ` | ||
@media print { | ||
@page { | ||
size: ${width}px ${height}px; | ||
margin: 0; | ||
} | ||
}`; | ||
|
||
document.querySelector('style').innerHTML += printPageMedia; | ||
|
||
window.onload = function() { | ||
window.print(); | ||
} | ||
</script> | ||
|
||
</template> | ||
|
||
<template id="store_ticket_report_template"> | ||
<t t-foreach="docs" t-as="o"> | ||
<t t-call="sale_order_pos_report_plain_text.store_ticket_document" /> | ||
</t> | ||
</template> | ||
|
||
</odoo> |
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,53 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
<record id="paperformat_compact" model="report.paperformat"> | ||
<field name="name">Thermal 80mm</field> | ||
<field name="default" eval="True" /> | ||
<field name="format">custom</field> | ||
<field name="page_height">300</field> | ||
<field name="page_width">80</field> | ||
<field name="orientation">Portrait</field> | ||
<field name="margin_top">3</field> | ||
<field name="margin_bottom">3</field> | ||
<field name="margin_left">3</field> | ||
<field name="margin_right">3</field> | ||
<field name="header_line" eval="False" /> | ||
<field name="header_spacing">3</field> | ||
<field name="dpi">90</field> | ||
</record> | ||
|
||
<record id="action_report_saleorder_compact" model="ir.actions.report"> | ||
<field name="name">Quotation / Order (80mm)</field> | ||
<field name="model">sale.order</field> | ||
<field name="report_type">qweb-pdf</field> | ||
<field | ||
name="report_name" | ||
>sale_order_pos_report_plain_text.store_ticket_report_template</field> | ||
<field | ||
name="report_file" | ||
>sale_order_pos_report_plain_text.store_ticket_report_template</field> | ||
<field | ||
name="print_report_name" | ||
>(object.state in ('draft', 'sent') and 'Quotation - %s' % (object.name)) or 'Order - %s' % (object.name)</field> | ||
<field name="binding_model_id" ref="sale.model_sale_order" /> | ||
<field name="binding_type">report</field> | ||
<field name="paperformat_id" ref="paperformat_compact" /> | ||
</record> | ||
|
||
<record id="store_ticket_report" model="ir.actions.report"> | ||
<field name="name">Store Ticket</field> | ||
<field name="model">sale.order</field> | ||
<field name="report_type">qweb-pdf</field> | ||
<field | ||
name="report_name" | ||
>sale_order_pos_report_plain_text.store_ticket_report_template</field> | ||
<field | ||
name="report_file" | ||
>sale_order_pos_report_plain_text.store_ticket_report_template</field> | ||
<field name="binding_model_id" ref="model_sale_order" /> | ||
<field name="binding_type">report</field> | ||
<field name="paperformat_id" ref="paperformat_compact" /> | ||
</record> | ||
|
||
|
||
</odoo> |
31 changes: 31 additions & 0 deletions
31
sale_order_pos_report_plain_text/views/res_config_settings.xml
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,31 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 KMEE | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="res_config_settings_form_view"> | ||
<field | ||
name="name" | ||
>res.config.settings.form (in sale_order_pos_report_plain_text)</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="sale.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr='//*[@id="proforma_configuration"]' position='after'> | ||
<div class="col-12 col-lg-6 o_setting_box" id="no_edit_order"> | ||
<div class="o_setting_left_pane"> | ||
<field name="logo_order_so_pos_report" widget="image" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="logo_order_so_pos_report" /> | ||
<div class="text-muted"> | ||
Logo that appears on the header of "Quotation / Order (80mm)" | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
|
||
|
||
</odoo> |
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_plain_text)</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> |
1 change: 1 addition & 0 deletions
1
setup/sale_order_pos_report_plain_text/odoo/addons/sale_order_pos_report_plain_text
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 @@ | ||
../../../../sale_order_pos_report_plain_text |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |