Skip to content

Commit

Permalink
[ADD] Addon: sale_order_pos_report
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Amaral authored and mileo committed May 23, 2024
1 parent 7eb1a49 commit df1c61e
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sale_order_pos_report/README.rst
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>`_.
Empty file.
18 changes: 18 additions & 0 deletions sale_order_pos_report/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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": [
"report/report_saleorder_compact.xml",
"report/sale_report.xml",
],
"demo": [],
}
291 changes: 291 additions & 0 deletions sale_order_pos_report/report/report_saleorder_compact.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<template id="report_saleorder_compact">
<t t-call="web.external_layout">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t
t-set="doc"
t-value="doc.with_context(lang=doc.partner_id.lang)"
/>
<t
t-set="forced_vat"
t-value="doc.fiscal_position_id.foreign_vat"
/> <!-- So that it appears in the footer of the report instead of the company VAT if it's set -->
<t t-set="address">
<div
t-field="doc.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'
/>
<p t-if="doc.partner_id.vat"><t
t-esc="doc.company_id.account_fiscal_country_id.vat_label or 'Tax ID'"
/>: <span t-field="doc.partner_id.vat" /></p>
</t>
<t
t-if="doc.partner_shipping_id == doc.partner_invoice_id
and doc.partner_invoice_id != doc.partner_id
or doc.partner_shipping_id != doc.partner_invoice_id"
>
<t t-set="information_block">
<strong
t-if="doc.partner_shipping_id == doc.partner_invoice_id"
>Invoicing and Shipping Address:</strong>
<strong
t-if="doc.partner_shipping_id != doc.partner_invoice_id"
>Invoicing Address:</strong>
<div
t-field="doc.partner_invoice_id"
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True, "phone_icons": True}'
/>
<t t-if="doc.partner_shipping_id != doc.partner_invoice_id">
<strong>Shipping Address:</strong>
<div
t-field="doc.partner_shipping_id"
t-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": True, "phone_icons": True}'
/>
</t>
</t>
</t>
<div class="page">
<div class="oe_structure" />
<h2 class="mt16">
<t
t-if="not (env.context.get('proforma', False) or is_pro_forma)"
>
<span
t-if="doc.state not in ['draft','sent']"
>Order # </span>
<span
t-if="doc.state in ['draft','sent']"
>Quotation # </span>
</t>
<t
t-if="env.context.get('proforma', False) or is_pro_forma"
>
<span>Pro-Forma Invoice # </span>
</t>
<span t-field="doc.name" />
</h2>

<div class="row mt32 mb32" id="informations">
<div
t-if="doc.client_order_ref"
class="col-auto col-3 mw-100 mb-2"
>
<strong>Your Reference:</strong>
<p class="m-0" t-field="doc.client_order_ref" />
</div>
<div
t-if="doc.date_order and doc.state not in ['draft','sent']"
class="col-auto col-3 mw-100 mb-2"
>
<strong>Order Date:</strong>
<p class="m-0" t-field="doc.date_order" />
</div>
<div
t-if="doc.date_order and doc.state in ['draft','sent']"
class="col-auto col-3 mw-100 mb-2"
>
<strong>Quotation Date:</strong>
<p
class="m-0"
t-field="doc.date_order"
t-options='{"widget": "date"}'
/>
</div>
<div
t-if="doc.validity_date and doc.state in ['draft', 'sent']"
class="col-auto col-3 mw-100 mb-2"
name="expiration_date"
>
<strong>Expiration:</strong>
<p class="m-0" t-field="doc.validity_date" />
</div>
<div
t-if="doc.user_id.name"
class="col-auto col-3 mw-100 mb-2"
>
<strong>Salesperson:</strong>
<p class="m-0" t-field="doc.user_id" />
</div>
</div>

<!-- Is there a discount on at least one line? -->
<t
t-set="display_discount"
t-value="any(l.discount for l in doc.order_line)"
/>

<table class="table table-sm o_main_table">
<!-- In case we want to repeat the header, remove "display: table-row-group" -->
<thead style="display: table-row-group">
<tr>
<th
name="th_description"
class="text-left"
>Description</th>
<th
name="th_quantity"
class="text-right"
>Quantity</th>
<th
name="th_priceunit"
class="text-right"
>Unit Price</th>
<th
name="th_discount"
t-if="display_discount"
class="text-right"
groups="product.group_discount_per_so_line"
>
<span>Disc.%</span>
</th>
<th name="th_subtotal" class="text-right">
<span
groups="account.group_show_line_subtotals_tax_excluded"
>Amount</span>
<span
groups="account.group_show_line_subtotals_tax_included"
>Total Price</span>
</th>
</tr>
</thead>
<tbody class="sale_tbody">

<t t-set="current_subtotal" t-value="0" />

<t t-foreach="doc.order_line" t-as="line">

<t
t-set="current_subtotal"
t-value="current_subtotal + line.price_subtotal"
groups="account.group_show_line_subtotals_tax_excluded"
/>
<t
t-set="current_subtotal"
t-value="current_subtotal + line.price_total"
groups="account.group_show_line_subtotals_tax_included"
/>

<tr
t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''"
>
<t t-if="not line.display_type">
<td name="td_name"><span
t-field="line.name"
/></td>
<td name="td_quantity" class="text-right">
<span t-field="line.product_uom_qty" />
<span t-field="line.product_uom" />
</td>
<td name="td_priceunit" class="text-right">
<span t-field="line.price_unit" />
</td>
<td
t-if="display_discount"
class="text-right"
groups="product.group_discount_per_so_line"
>
<span t-field="line.discount" />
</td>
<td
name="td_subtotal"
class="text-right o_price_total"
>
<span
t-field="line.price_subtotal"
groups="account.group_show_line_subtotals_tax_excluded"
/>
<span
t-field="line.price_total"
groups="account.group_show_line_subtotals_tax_included"
/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<td name="td_section_line" colspan="99">
<span t-field="line.name" />
</td>
<t t-set="current_section" t-value="line" />
<t t-set="current_subtotal" t-value="0" />
</t>
<t t-if="line.display_type == 'line_note'">
<td name="td_note_line" colspan="99">
<span t-field="line.name" />
</td>
</t>
</tr>

<t
t-if="current_section and (line_last or doc.order_line[line_index+1].display_type == 'line_section')"
>
<tr class="is-subtotal text-right">
<td name="td_section_subtotal" colspan="99">
<strong class="mr16">Subtotal</strong>
<span
t-esc="current_subtotal"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</tr>
</t>
</t>
</tbody>
</table>

<div class="clearfix" name="so_total_summary">
<div id="total" class="row" name="total">
<div
t-attf-class="#{'col-6' if report_type != 'html' else 'col-sm-7 col-md-6'} ml-auto"
>
<table class="table table-sm">
<!-- Tax totals -->
<t
t-set="tax_totals"
t-value="json.loads(doc.tax_totals_json)"
/>
<t t-call="account.document_tax_totals" />
</table>
</div>
</div>
</div>

<div
t-if="doc.signature"
class="mt32 ml64 mr4"
name="signature"
>
<div class="offset-8">
<strong>Signature</strong>
</div>
<div class="offset-8">
<img
t-att-src="image_data_uri(doc.signature)"
style="max-height: 4cm; max-width: 8cm;"
/>
</div>
<div class="offset-8 text-center">
<p t-field="doc.signed_by" />
</div>
</div>

<div class="oe_structure" />

<p t-field="doc.note" />
<p t-if="not is_html_empty(doc.payment_term_id.note)">
<span t-field="doc.payment_term_id.note" />
</p>
<p
id="fiscal_position_remark"
t-if="doc.fiscal_position_id and not is_html_empty(doc.fiscal_position_id.sudo().note)"
>
<strong>Fiscal Position Remark:</strong>
<span t-field="doc.fiscal_position_id.sudo().note" />
</p>
</div>
</t>
</t>
</t>
</template>
</odoo>
33 changes: 33 additions & 0 deletions sale_order_pos_report/report/sale_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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">80</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.report_saleorder_compact</field>
<field name="report_file">sale_order_pos_report.report_saleorder_compact</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="model_sale_order" />
<field name="binding_type">report</field>
<field name="paperformat_id" ref="paperformat_compact" />
</record>

</odoo>
6 changes: 6 additions & 0 deletions setup/sale_order_pos_report/setup.py
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,
)

0 comments on commit df1c61e

Please sign in to comment.