[ADD] Folio report (#59)

* [IMP] Pms: Improve folio report

* [IMP] Pms: Add show detail check in board_service and folio report

* [IMP] Pms: Show currency in all monetary fields

* [IMP] Pms: fix price_unit in folio_report

* [IMP] Pms: add discounts in board_service price

* [IMP] Pms: fix discount calculation

* Pre-commit and rebase done
This commit is contained in:
Sara
2021-03-02 10:59:21 +01:00
committed by GitHub
parent fb45a08171
commit 865f075d1f
3 changed files with 254 additions and 273 deletions

View File

@@ -28,7 +28,9 @@ class PmsBoardService(models.Model):
"Amount", digits=("Product Price"), compute="_compute_board_amount", store=True
)
show_detail_report = fields.Boolean(string="Show Detail Report")
# Compute and Search methods
@api.depends("board_service_line_ids.amount")
def _compute_board_amount(self):
for record in self:

View File

@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_folio_document">
<t t-call="web.external_layout">
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
<div class="page">
<div class="oe_structure" />
<div class="row">
<template id="report_folio_document">
<t t-call="web.external_layout">
<t t-set="doc" t-value="doc.with_context(lang=doc.partner_id.lang)" />
<t t-set="address">
<div class="row">
<div class="col-xs-6">
<t t-if="doc.partner_invoice_id != doc.partner_id">
<div
@@ -25,308 +24,286 @@
<span t-field="doc.partner_id.vat" />
</p>
</div>
</div>
</t>
<div class="page">
<div class="oe_structure" />
<h2 class="mt16">
<span t-if="doc.state not in ['draft','sent']">Order #</span>
<span t-if="doc.state in ['draft','sent']">Quotation #</span>
<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>
<h2>
<span t-if="doc.state not in ['draft','sent']">Order #</span>
<span t-if="doc.state in ['draft','sent']">Quotation #</span>
<span t-field="doc.name" />
</h2>
<div class="row mt32 mb32" id="informations">
<div t-if="doc.client_order_ref" class="col-xs-3">
<strong>Your Reference:</strong>
<p t-field="doc.client_order_ref" />
</div>
<div
t-if="doc.confirmation_date and doc.state not in ['draft','sent']"
class="col-xs-3"
<div
t-if="doc.date_order and doc.state not in ['draft','sent']"
class="col-auto col-3 mw-100 mb-2"
>
<strong>Date Ordered:</strong>
<p t-field="doc.confirmation_date" />
</div>
<div
<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-xs-3"
class="col-auto col-3 mw-100 mb-2"
>
<strong>Quotation Date:</strong>
<p t-field="doc.date_order" />
</div>
<div t-if="doc.user_id.name" class="col-xs-3">
<strong>Salesperson:</strong>
<p t-field="doc.user_id" />
</div>
<div
name="payment_term"
t-if="doc.payment_term_id"
class="col-xs-3"
>
<strong>Payment Terms:</strong>
<p t-field="doc.payment_term_id" />
</div>
<strong>Quotation Date:</strong>
<p
class="m-0"
t-field="doc.date_order"
t-options='{"widget": "date"}'
/>
</div>
<!-- Is there a discount on at least one line? -->
<t
<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.reservation_ids])"
t-value="any(l.discount for l in doc.sale_line_ids)"
/>
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="text-right">Quantity</th>
<th
<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="sale.group_discount_per_so_line"
>
Disc.(%)
</th>
<th class="text-right">Taxes</th>
<th
class="text-right"
groups="sale.group_show_price_subtotal"
<span>Disc.%</span>
</th>
<th name="th_taxes" class="text-right">Taxes</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.sale_line_ids" 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 ''"
>
Amount
</th>
<th
class="text-right price_tax_included"
groups="sale.group_show_price_total"
>
Total Price
</th>
</tr>
</thead>
<tbody class="sale_tbody">
<!-- Lines associated -->
<t t-foreach="doc.reservation_ids" t-as="l">
<t t-if="l.price_total > 0">
<tr>
<td>
<span t-field="l.name" />
</td>
<td class="text-right">
<span t-field="l.nights" />
</td>
<td
t-if="display_discount"
class="text-right"
groups="sale.group_discount_per_so_line"
>
<span t-field="l.discount" />
</td>
<td class="text-right">
<span
t-esc="', '.join(map(lambda x: (x.description or x.name), l.tax_ids))"
<t t-if="not line.display_type">
<t t-set="price" t-value="line.price_unit" />
<t t-if="line.reservation_id">
<t
t-set="print_board_service"
t-value="line.reservation_id.board_service_room_id.pms_board_service_id.show_detail_report"
/>
</td>
<td
class="text-right"
groups="sale.group_show_price_subtotal"
>
<span
t-field="l.price_subtotal"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
<td
class="text-right"
groups="sale.group_show_price_total"
>
<span
t-field="l.price_total"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</tr>
</t>
</t>
<t t-foreach="doc.service_ids" t-as="l">
<t t-if="l.price_total > 0">
<tr>
<td>
<span t-field="l.name" />
</td>
<td class="text-right">
<span t-field="l.product_qty" />
</td>
<td
t-if="display_discount"
class="text-right"
groups="sale.group_discount_per_so_line"
>
<span t-field="l.discount" />
</td>
<td class="text-right">
<span
t-esc="', '.join(map(lambda x: (x.description or x.name), l.tax_ids))"
/>
</td>
<td
class="text-right"
groups="sale.group_show_price_subtotal"
>
<span
t-field="l.price_subtotal"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
<td
class="text-right"
groups="sale.group_show_price_total"
>
<span
t-field="l.price_total"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</tr>
</t>
</t>
</tbody>
</table>
<div class="clearfix">
<div class="row" name="total">
<div class="col-xs-4 pull-right">
<table
class="table table-condensed"
style="min-width: 200px;max-width: 350px;"
>
<tr
class="border-black"
style="border-bottom:1px solid #dddddd;"
>
<td>
<strong>Subtotal</strong>
</td>
<td class="text-right">
<span
t-field="doc.amount_untaxed"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</tr>
-
<t t-if="not print_board_service">
<t
t-foreach="line.reservation_id.service_ids"
t-as="service"
>
<t t-if="service.is_board_service">
<t
t-set="price"
t-value="service.product_qty/line.product_uom_qty*service.price_unit*(1-(service.discount or 0.0)*0.01) + price"
/>
</t>
</t>
</t>
</t>
<t
t-if="not(not print_board_service and line.service_id.is_board_service)"
>
<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"
groups="uom.group_uom"
/>
</td>
<td name="td_priceunit" class="text-right">
<span
t-esc="price"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
<td t-if="display_discount" class="text-right">
<span t-field="line.discount" />
</td>
<td name="td_taxes" class="text-right">
<span
t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))"
/>
</td>
<td
name="td_subtotal"
class="text-right o_price_total"
>
<span
t-esc="price*(1-(line.discount or 0.0)*0.01)* line.product_uom_qty"
groups="account.group_show_line_subtotals_tax_excluded"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
<span
t-esc="price *(1-(line.discount or 0.0)*0.01)* line.product_uom_qty"
groups="account.group_show_line_subtotals_tax_included"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</t>
</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.sale_line_ids[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-4' if report_type != 'html' else 'col-sm-7 col-md-5'} ml-auto"
>
<table class="table table-sm">
<tr class="border-black o_subtotal" style="">
<td name="td_amount_untaxed_label"><strong
>Subtotal</strong></td>
<td name="td_amount_untaxed" class="text-right">
<span t-field="doc.amount_untaxed" />
</td>
</tr>
<t
t-foreach="doc._get_tax_amount_by_group()"
t-as="amount_by_group"
>
<tr style="border-bottom:1px solid #dddddd;">
<t
<tr style="">
<t
t-if="amount_by_group[3] == 1 and doc.amount_untaxed == amount_by_group[2]"
>
<td>
<span t-esc="amount_by_group[0]" />
<span>&amp;nbsp;<span>
on
</span>&amp;nbsp;<t
<td name="td_amount_by_group_label_3">
<span t-esc="amount_by_group[0]" />
<span>&amp;nbsp;<span>on</span>&amp;nbsp;<t
t-esc="amount_by_group[2]"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/></span>
</td>
<td class="text-right">
<span
</td>
<td
name="td_amount_by_group_3"
class="text-right o_price_total"
>
<span
t-esc="amount_by_group[1]"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</t>
<t t-else="">
<td>
<span t-esc="amount_by_group[0]" />
</td>
<td class="text-right">
<span
</td>
</t>
<t t-else="">
<td name="td_amount_by_group_label">
<span t-esc="amount_by_group[0]" />
</td>
<td
name="td_amount_by_group"
class="text-right o_price_total"
>
<span
t-esc="amount_by_group[1]"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</t>
</tr>
</t>
<tr class="border-black">
<td>
<strong>Total</strong>
</td>
<td class="text-right">
<span
t-field="doc.amount_total"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</td>
</t>
</tr>
<tr class="border-black">
<td>
<strong>Pending Payment</strong>
</td>
<td class="text-right">
<span
t-field="doc.pending_amount"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</tr>
</table>
</div>
</t>
<tr class="border-black o_total">
<td name="td_amount_total_label"><strong
>Total</strong></td>
<td name="td_amount_total" class="text-right">
<span t-field="doc.amount_total" />
</td>
</tr>
</table>
</div>
</div>
<div>
<!-- <span t-if="doc.payment_ids">
<table style="width:80%;">
<thead>
<tr>
<th>Payment Ref.</th>
<th>Payment Date</th>
<th>Payment Method</th>
<th>Paid Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="doc.payment_ids" t-as="l">
<td t-esc="l.name" />
<td t-esc="l.payment_date" />
<td t-esc="l.journal_id.name" />
<td t-esc="l.amount" />
</tr>
</tbody>
</table>
</span> -->
<!-- <span t-if="doc.return_ids">
<table style="width:80%;">
<thead>
<tr>
<th>Return Ref.</th>
<th>Return Date</th>
<th>Return Method</th>
<th>Return Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="doc.return_ids" t-as="r">
<td t-esc="r.name" />
<td t-esc="r.date" />
<td t-esc="r.journal_id.name" />
<t
t-set="total_amount"
t-value="sum(l.amount for l in r.line_ids)"
/>
<td t-esc="total_amount" />
</tr>
</tbody>
</table>
</span> -->
</div>
<p t-field="doc.note" />
<p t-if="doc.payment_term_id.note">
<span t-field="doc.payment_term_id.note" />
</p>
<div class="oe_structure" />
</div>
</t>
</template>
<template id="report_folio">
<div class="oe_structure" />
<p t-field="doc.note" />
<p t-if="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 doc.fiscal_position_id.sudo().note"
>
<strong>Fiscal Position Remark:</strong>
<span t-field="doc.fiscal_position_id.sudo().note" />
</p>
</div>
</t>
</template>
<template id="report_folio">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="pms.report_folio_document" t-lang="doc.partner_id.lang" />
</t>
</t>
</template>
</odoo>

View File

@@ -19,6 +19,7 @@
<field name="amount" />
</tree>
</field>
<field name="show_detail_report" />
</group>
</form>
</field>
@@ -30,6 +31,7 @@
<tree string="Board Services">
<field name="name" />
<field name="amount" />
<field name="show_detail_report" />
</tree>
</field>
</record>