-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3006][ADD] report_qweb_decimal_place #4
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,90 @@ | ||
========================= | ||
Report Qweb Decimal Place | ||
========================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-qrtl%2Ffal--custom-lightgray.png?logo=github | ||
:target: https://github.com/qrtl/fal-custom/tree/16.0/report_qweb_decimal_place | ||
:alt: qrtl/fal-custom | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This module intends to provide the base function for currencies to adjust the number of decimal places | ||
for the unit price in QWeb reports. | ||
Installing this module alone does not affect the presentation of existing QWeb reports. | ||
Individual adjustments need to be done in separate modules in a manner similar to the following: | ||
|
||
.. code-block:: xml | ||
|
||
<template | ||
id="report_saleorder_document_inherit" | ||
inherit_id="sale.report_saleorder_document" | ||
> | ||
<xpath expr="//td[@name='td_priceunit']/span" position="replace"> | ||
<t t-set="currency" t-value="doc.currency_id" /> | ||
<t t-set="price_unit" t-value="line.price_unit" /> | ||
<t t-call="report_qweb_decimal_place.price_unit_value_format" /> | ||
</xpath> | ||
</template> | ||
|
||
Background: | ||
~~~~~~~~~~~ | ||
|
||
Odoo default reports display price unit with the decimal accuracy of product price configuration. | ||
However, globally applying the decimal accuracy setting is sometimes not appropriate under multi-currency settings | ||
where how unit prices should be presented differs depending on the currency. | ||
|
||
For example, unit prices in JPY usually do not have decimals (with some exceptions depending on the industry), | ||
while those in USD may require up to 2-4 decimals. If we configure the decimal accuracy based on USD, the unit price | ||
presentation on PDF reports for JPY transactions may appear a bit unconventional. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To apply price unit format: | ||
|
||
#. Go to Invoicing --> Configuration --> Currencies | ||
#. Check apply_price_decimal_place field | ||
#. Define decimal place in price_decimal_place field | ||
|
||
Inherit this module in your xxx_report_qweb_decimal_place module and format the price unit in reports. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/qrtl/fal-custom/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/qrtl/fal-custom/issues/new?body=module:%20report_qweb_decimal_place%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Quartile Limited | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `qrtl/fal-custom <https://github.com/qrtl/fal-custom/tree/16.0/report_qweb_decimal_place>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
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 models |
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,16 @@ | ||
# Copyright 2022 Quartile Limited | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
{ | ||
"name": "Report Qweb Decimal Place", | ||
"category": "Reporting", | ||
"version": "16.0.1.0.0", | ||
"author": "Quartile Limited", | ||
"website": "https://www.quartile.co", | ||
"license": "LGPL-3", | ||
"depends": ["base"], | ||
"data": [ | ||
"reports/price_unit_value_format.xml", | ||
"views/res_currency_views.xml", | ||
], | ||
"installable": True, | ||
} |
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 res_currency |
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,16 @@ | ||
# Copyright 2022 Quartile Limited | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResCurrency(models.Model): | ||
_inherit = "res.currency" | ||
|
||
apply_price_decimal_place = fields.Boolean( | ||
help="Apply this decimal place to the unit price field of relevant PDF reports " | ||
"where appropriate customization is done." | ||
) | ||
price_decimal_places = fields.Integer( | ||
help="Define decimal places for the unit price field of relevant PDF reports" | ||
) |
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,7 @@ | ||
To apply price unit format: | ||
|
||
#. Go to Invoicing --> Configuration --> Currencies | ||
#. Check apply_price_decimal_place field | ||
#. Define decimal place in price_decimal_place field | ||
|
||
Inherit this module in your xxx_report_qweb_decimal_place module and format the price unit in reports. |
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,28 @@ | ||
This module intends to provide the base function for currencies to adjust the number of decimal places | ||
for the unit price in QWeb reports. | ||
Installing this module alone does not affect the presentation of existing QWeb reports. | ||
Individual adjustments need to be done in separate modules in a manner similar to the following: | ||
|
||
.. code-block:: xml | ||
|
||
<template | ||
id="report_saleorder_document_inherit" | ||
inherit_id="sale.report_saleorder_document" | ||
> | ||
<xpath expr="//td[@name='td_priceunit']/span" position="replace"> | ||
<t t-set="currency" t-value="doc.currency_id" /> | ||
<t t-set="price_unit" t-value="line.price_unit" /> | ||
<t t-call="report_qweb_decimal_place.price_unit_value_format" /> | ||
</xpath> | ||
</template> | ||
|
||
Background: | ||
~~~~~~~~~~~ | ||
|
||
Odoo default reports display price unit with the decimal accuracy of product price configuration. | ||
However, globally applying the decimal accuracy setting is sometimes not appropriate under multi-currency settings | ||
where how unit prices should be presented differs depending on the currency. | ||
|
||
For example, unit prices in JPY usually do not have decimals (with some exceptions depending on the industry), | ||
while those in USD may require up to 2-4 decimals. If we configure the decimal accuracy based on USD, the unit price | ||
presentation on PDF reports for JPY transactions may appear a bit unconventional. |
15 changes: 15 additions & 0 deletions
15
report_qweb_decimal_place/reports/price_unit_value_format.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,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<template id="price_unit_value_format"> | ||
<t t-if="currency.apply_price_decimal_place"> | ||
<span | ||
class="text-nowrap" | ||
t-esc="price_unit" | ||
t-options='{"widget": "float", "precision": currency.price_decimal_places}' | ||
/> | ||
</t> | ||
<t t-else=""> | ||
<span class="text-nowrap" t-field="line.price_unit" /> | ||
</t> | ||
</template> | ||
</odoo> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pay attention to the suggested blank line!