[15.0][ADD] report_qweb_decimal_place#697
Conversation
| To apply price unit format: | ||
| - Go to Invoicing --> Configuration --> Currencies | ||
| - Check apply_price_unit_format field |
There was a problem hiding this comment.
Please move this to CONFIGURE.rst.
| "version": "15.0.1.0.0", | ||
| "author": "Quartile Limited, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/reporting-engine", | ||
| "license": "AGPL-3", |
| or | ||
| not currency.rounding >= 1" | ||
| > | ||
| <span t-esc="'{:,.2f}'.format(price_unit)" /> |
There was a problem hiding this comment.
Can we go a bit further than fixing it at the second decimal? Let's add price_decimal_place field in res.currency and take the value from there.
| <t | ||
| t-if="round(price_unit) != price_unit | ||
| or | ||
| not currency.rounding >= 1" | ||
| > |
There was a problem hiding this comment.
| <t | |
| t-if="round(price_unit) != price_unit | |
| or | |
| not currency.rounding >= 1" | |
| > |
Let's get rid of this condition.
| <t | ||
| t-if="round(price_unit) == price_unit | ||
| and | ||
| currency.rounding >= 1" | ||
| > | ||
| <span t-esc="'{:,.0f}'.format(price_unit)" /> | ||
| </t> |
There was a problem hiding this comment.
| <t | |
| t-if="round(price_unit) == price_unit | |
| and | |
| currency.rounding >= 1" | |
| > | |
| <span t-esc="'{:,.0f}'.format(price_unit)" /> | |
| </t> |
Let's get rid of this for simplicity.
| class ResCurrency(models.Model): | ||
| _inherit = "res.currency" | ||
|
|
||
| apply_price_unit_format = fields.Boolean() |
There was a problem hiding this comment.
| apply_price_unit_format = fields.Boolean() | |
| 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.") |
| This module does the following: | ||
|
|
||
| - Adds apply_price_unit_format in currency and the price_unit format of reports will depend on that field. |
There was a problem hiding this comment.
| This module does the following: | |
| - Adds apply_price_unit_format in currency and the price_unit format of reports will depend on that field. | |
| 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 | |
| <?xml version="1.0" encoding="utf-8" ?> | |
| <odoo> | |
| <template | |
| id="report_saleorder_document_inherit" | |
| inherit_id="sale.report_saleorder_document" | |
| > | |
| <xpath expr="//tbody[@class='sale_tbody']//tr//td[3]" position="replace"> | |
| <td name="td_priceunit" class="text-right"> | |
| <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" /> | |
| </td> | |
| </xpath> | |
| </template> | |
| </odoo> | |
| 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. |
8e05667 to
5113448
Compare
| </odoo> | ||
|
|
||
| Background: | ||
| -------------- |
There was a problem hiding this comment.
| -------------- | |
| ----------- | |
| --> | ||
| <t t-if="currency.apply_price_decimal_place"> | ||
| <span | ||
| class="text-nowrap" |
There was a problem hiding this comment.
Do we need this class assignment?
There was a problem hiding this comment.
Even we add this class or not, there is no huge impact. This just change a little spacing and I added this class because price_unit of sale_order_document don't use this class but others use this class like invoice(https://github.com/odoo/odoo/blob/23ef75f9250e6920e592b14a0cec2d1d9545824e/addons/account/views/report_invoice.xml#L85)
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <odoo> | ||
| <template | ||
| id="report_saleorder_document_inherit" | ||
| inherit_id="sale.report_saleorder_document" | ||
| > | ||
| <xpath expr="//tbody[@class='sale_tbody']//tr//td[3]" position="replace"> | ||
| <td name="td_priceunit" class="text-right"> | ||
| <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" /> | ||
| </td> | ||
| </xpath> | ||
| </template> | ||
| </odoo> |
There was a problem hiding this comment.
| <?xml version="1.0" encoding="utf-8" ?> | |
| <odoo> | |
| <template | |
| id="report_saleorder_document_inherit" | |
| inherit_id="sale.report_saleorder_document" | |
| > | |
| <xpath expr="//tbody[@class='sale_tbody']//tr//td[3]" position="replace"> | |
| <td name="td_priceunit" class="text-right"> | |
| <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" /> | |
| </td> | |
| </xpath> | |
| </template> | |
| </odoo> | |
| <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> |
Please double-check if this suggestion is valid.
There was a problem hiding this comment.
Yes. This suggestion is valid.
| <!-- | ||
| It should define the price_unit and currency value. | ||
| e.g. | ||
| <t t-set="price_unit" t-value="line.price_unit" /> | ||
| <t t-set="currency" t-value="o.currency_id" /> | ||
| --> |
There was a problem hiding this comment.
| <!-- | |
| It should define the price_unit and currency value. | |
| e.g. | |
| <t t-set="price_unit" t-value="line.price_unit" /> | |
| <t t-set="currency" t-value="o.currency_id" /> | |
| --> |
We can remove this as it's explained in readme.
| </template> | ||
|
|
||
| Background: | ||
| ----------- |
There was a problem hiding this comment.
| ----------- | |
| ~~~~~~~~~~~ | |
Pay attention to the blank line as well.
| To apply price unit format: | ||
| - Go to Invoicing --> Configuration --> Currencies | ||
| - Check apply_price_decimal_place field | ||
| - Define decimal place in price_decimal_place field |
There was a problem hiding this comment.
| To apply price unit format: | |
| - Go to Invoicing --> Configuration --> Currencies | |
| - Check apply_price_decimal_place field | |
| - Define decimal place in price_decimal_place field | |
| To apply price unit format: | |
| #. Go to Invoicing --> Configuration --> Currencies | |
| #. Check apply_price_decimal_place field | |
| #. Define decimal place in price_decimal_place field |
be9ae4f to
ffa22fd
Compare
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
This module intends to provide the base function for currencies to adjust the number of decimal places for the unit price in QWeb reports.
@qrtl