Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association
========================
Report Qweb Field Option
========================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6a839e0b8361541500cea7946ac9d7bfbcbe37ab2a102576061a2940c4343c5c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/18.0/report_qweb_field_option
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-report_qweb_field_option
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=18.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module allows administrators to define the decimal precision of
float fields and add option values to fields (e.g., adding a date widget
option to datetime fields) for QWeb report and view presentation.
**Table of contents**
.. contents::
:local:
Configuration
=============
Go to *Settings > Technical > Reporting > Qweb Field Options*, and
create records according to your needs.
For each record:
- Set **Model** and **Field** (required)
- Set **UoM** and **UoM Field**, or **Currency** and **Currency Field**
only for fields of float type (optional)
- Set **Company** (optional)
- Set **Options** as a string representation of a dictionary. E.g.,
``{"widget": "date"}``, ``{"widget": "monetary"}``, or
``{"widget": "contact", "fields": ["name", "phone"]}``
- Set **Digits** (only for float-type fields). The value is ignored if
Options is set
Usage
=====
Print a QWeb report (quotation, invoice, purchase order, etc.), and the
value presentation for fields like line quantity, price unit and date
order are adjusted according to the Qweb Field Options configuration.
Note that among matching configuration records, the one with the
strictest condition will be applied.
Known issues / Roadmap
======================
| #. QWeb field option settings only apply to fields rendered with
``t-field``.
| They dont work with ``t-esc`` or other expressions not using
``t-field``.
As a workaround, you could create a module that adds a computed field
holding the same value currently computed and displayed in the QWeb
report using ``t-esc``, and adjust the report template to display the
field value using ``t-field``. This would allow you to adjust the
decimal precision as needed.
#. Assigning Options in a QWeb Field Options record can cause UI issues
if a field is defined twice with different widgets in a view.
For example, adding ``{"widget": "date"}`` to the date_approve field in
a purchase order can result in two dates appearing under the
Confirmation Date column in the portal view. This occurs because the
field is defined twice with different widgets.
Reference:
https://github.com/odoo/odoo/blob/5eec379/addons/purchase/views/portal_templates.xml#L101-L102
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_qweb_field_option%0Aversion:%2018.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
Contributors
------------
- `Quartile <https://www.quartile.co>`__:
- Yoshi Tashiro
- Aung Ko Ko Lin
Maintainers
-----------
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/18.0/report_qweb_field_option>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,17 @@
# Copyright 2024-2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Report Qweb Field Option",
"version": "18.0.1.0.1",
"category": "Technical Settings",
"license": "AGPL-3",
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"depends": ["uom"],
"data": [
"security/ir.model.access.csv",
"security/qweb_field_options_security.xml",
"views/qweb_field_options_views.xml",
],
"installable": True,
}

View File

@@ -0,0 +1,167 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_qweb_field_option
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-03-30 21:06+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.10.2\n"
#. module: report_qweb_field_option
#: model:ir.model.fields,help:report_qweb_field_option.field_qweb_field_options__field_options
msgid ""
"A string representation of a dictionary to specify field formatting options. Examples:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}"
msgstr ""
"Una stringa che rappresenta un dizionario per indicare le opzioni di "
"formattazione dei campi. Esempi:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__company_id
msgid "Company"
msgstr "Azienda"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_uid
msgid "Created by"
msgstr "Creato da"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_date
msgid "Created on"
msgstr "Creato il"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_id
msgid "Currency"
msgstr "Valuta"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_field_id
msgid "Currency Field"
msgstr "Campo valuta"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__digits
msgid "Digits"
msgstr "Cifre"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__display_name
msgid "Display Name"
msgstr "Nome visualizzato"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_id
msgid "Field"
msgstr "Campo"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_name
msgid "Field Name"
msgstr "Nome campo"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_type
msgid "Field Type"
msgstr "Tipo campo"
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Group By"
msgstr "Raggruppa per"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__id
msgid "ID"
msgstr "ID"
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
#, python-format
msgid ""
"Invalid string for the Options field: %(field_options)s.\n"
"Error: %(error)s"
msgstr ""
"Stringa non valida per il campo opzioni: %(field_options)s.\n"
"Errore: %(error)s"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_uid
msgid "Last Updated by"
msgstr "Ultimo aggiornamento di"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_date
msgid "Last Updated on"
msgstr "Ultimo aggiornamento il"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_id
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Model"
msgstr "Modello"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_name
msgid "Model Name"
msgstr "Nome modello"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_options
msgid "Options"
msgstr "Opzioni"
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
#, python-format
msgid "Options must be a dictionary, but got %s"
msgstr "Le opzioni devono essere un dizionario, ma sono %s"
#. module: report_qweb_field_option
#: model:ir.model,name:report_qweb_field_option.model_ir_qweb
msgid "Qweb"
msgstr "Qweb"
#. module: report_qweb_field_option
#: model:ir.actions.act_window,name:report_qweb_field_option.action_qweb_field_options_view
#: model:ir.model,name:report_qweb_field_option.model_qweb_field_options
#: model:ir.ui.menu,name:report_qweb_field_option.menu_qweb_field_options
msgid "Qweb Field Options"
msgstr "Opzioni campo Qweb"
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Qweb Field Options Search"
msgstr "Ricerca opzioni campo Qweb"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_id
msgid "UoM"
msgstr "UdM"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_field_id
msgid "UoM Field"
msgstr "Campo UdM"

View File

@@ -0,0 +1,151 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_qweb_field_option
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. module: report_qweb_field_option
#: model:ir.model.fields,help:report_qweb_field_option.field_qweb_field_options__field_options
msgid ""
"A string representation of a dictionary to specify field formatting options. Examples:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__company_id
msgid "Company"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_uid
msgid "Created by"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_date
msgid "Created on"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_id
msgid "Currency"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_field_id
msgid "Currency Field"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__digits
msgid "Digits"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__display_name
msgid "Display Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_id
msgid "Field"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_name
msgid "Field Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_type
msgid "Field Type"
msgstr ""
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Group By"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__id
msgid "ID"
msgstr ""
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid ""
"Invalid string for the Options field: %(field_options)s.\n"
"Error: %(error)s"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_uid
msgid "Last Updated by"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_date
msgid "Last Updated on"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_id
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Model"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_name
msgid "Model Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_options
msgid "Options"
msgstr ""
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid "Options must be a dictionary, but got %s"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model,name:report_qweb_field_option.model_ir_qweb
msgid "Qweb"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.actions.act_window,name:report_qweb_field_option.action_qweb_field_options_view
#: model:ir.model,name:report_qweb_field_option.model_qweb_field_options
#: model:ir.ui.menu,name:report_qweb_field_option.menu_qweb_field_options
msgid "Qweb Field Options"
msgstr ""
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Qweb Field Options Search"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_id
msgid "UoM"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_field_id
msgid "UoM Field"
msgstr ""

View File

@@ -0,0 +1,151 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_qweb_field_option
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#. module: report_qweb_field_option
#: model:ir.model.fields,help:report_qweb_field_option.field_qweb_field_options__field_options
msgid ""
"A string representation of a dictionary to specify field formatting options. Examples:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__company_id
msgid "Company"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_uid
msgid "Created by"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_date
msgid "Created on"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_id
msgid "Currency"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_field_id
msgid "Currency Field"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__digits
msgid "Digits"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__display_name
msgid "Display Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_id
msgid "Field"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_name
msgid "Field Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_type
msgid "Field Type"
msgstr ""
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Group By"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__id
msgid "ID"
msgstr ""
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid ""
"Invalid string for the Options field: %(field_options)s.\n"
"Error: %(error)s"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_uid
msgid "Last Updated by"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_date
msgid "Last Updated on"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_id
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Model"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_name
msgid "Model Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_options
msgid "Options"
msgstr ""
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid "Options must be a dictionary, but got %s"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model,name:report_qweb_field_option.model_ir_qweb
msgid "Qweb"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.actions.act_window,name:report_qweb_field_option.action_qweb_field_options_view
#: model:ir.model,name:report_qweb_field_option.model_qweb_field_options
#: model:ir.ui.menu,name:report_qweb_field_option.menu_qweb_field_options
msgid "Qweb Field Options"
msgstr ""
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Qweb Field Options Search"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_id
msgid "UoM"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_field_id
msgid "UoM Field"
msgstr ""

View File

@@ -0,0 +1,160 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_qweb_field_option
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-09-11 09:42+0000\n"
"Last-Translator: Bosd <c5e2fd43-d292-4c90-9d1f-74ff3436329a@anonaddy.me>\n"
"Language-Team: none\n"
"Language: nl_NL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.10.4\n"
#. module: report_qweb_field_option
#: model:ir.model.fields,help:report_qweb_field_option.field_qweb_field_options__field_options
msgid ""
"A string representation of a dictionary to specify field formatting options. Examples:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}"
msgstr ""
"Een stringweergave van een woordenboek om veldopmaakopties te specificeren. "
"Voorbeelden:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__company_id
msgid "Company"
msgstr "Bedrijf"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_uid
msgid "Created by"
msgstr "Aangemaakt door"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_date
msgid "Created on"
msgstr "Aangemaakt op"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_id
msgid "Currency"
msgstr "Valuta"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_field_id
msgid "Currency Field"
msgstr "Valutaveld"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__digits
msgid "Digits"
msgstr "Cijfers"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__display_name
msgid "Display Name"
msgstr "Weergavenaam"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_id
msgid "Field"
msgstr "Veld"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_name
msgid "Field Name"
msgstr "Veldnaam"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_type
msgid "Field Type"
msgstr "Veldtype"
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Group By"
msgstr "Groeperen op"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__id
msgid "ID"
msgstr "ID"
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid ""
"Invalid string for the Options field: %(field_options)s.\n"
"Error: %(error)s"
msgstr ""
"Ongeldige string voor het veld Opties: %(field_options)s.\n"
"Fout: %(error)s"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_uid
msgid "Last Updated by"
msgstr "Laatst bijgewerkt door"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_date
msgid "Last Updated on"
msgstr "Laatst bijgewerkt op"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_id
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Model"
msgstr "Model"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_name
msgid "Model Name"
msgstr "Modelnaam"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_options
msgid "Options"
msgstr "Opties"
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid "Options must be a dictionary, but got %s"
msgstr "Opties moeten een woordenboek zijn, maar kregen %s"
#. module: report_qweb_field_option
#: model:ir.model,name:report_qweb_field_option.model_ir_qweb
msgid "Qweb"
msgstr "Qweb"
#. module: report_qweb_field_option
#: model:ir.actions.act_window,name:report_qweb_field_option.action_qweb_field_options_view
#: model:ir.model,name:report_qweb_field_option.model_qweb_field_options
#: model:ir.ui.menu,name:report_qweb_field_option.menu_qweb_field_options
msgid "Qweb Field Options"
msgstr "Qweb Veldopties"
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Qweb Field Options Search"
msgstr "Zoeken in Qweb Veldopties"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_id
msgid "UoM"
msgstr "Eenheid"
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_field_id
msgid "UoM Field"
msgstr "Eenheid Veld"

View File

@@ -0,0 +1,150 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_qweb_field_option
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: report_qweb_field_option
#: model:ir.model.fields,help:report_qweb_field_option.field_qweb_field_options__field_options
msgid ""
"A string representation of a dictionary to specify field formatting options. Examples:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__company_id
msgid "Company"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_uid
msgid "Created by"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__create_date
msgid "Created on"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_id
msgid "Currency"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__currency_field_id
msgid "Currency Field"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__digits
msgid "Digits"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__display_name
msgid "Display Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_id
msgid "Field"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_name
msgid "Field Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_type
msgid "Field Type"
msgstr ""
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Group By"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__id
msgid "ID"
msgstr ""
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid ""
"Invalid string for the Options field: %(field_options)s.\n"
"Error: %(error)s"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_uid
msgid "Last Updated by"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__write_date
msgid "Last Updated on"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_id
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Model"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__res_model_name
msgid "Model Name"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__field_options
msgid "Options"
msgstr ""
#. module: report_qweb_field_option
#. odoo-python
#: code:addons/report_qweb_field_option/models/qweb_field_options.py:0
msgid "Options must be a dictionary, but got %s"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model,name:report_qweb_field_option.model_ir_qweb
msgid "Qweb"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.actions.act_window,name:report_qweb_field_option.action_qweb_field_options_view
#: model:ir.model,name:report_qweb_field_option.model_qweb_field_options
#: model:ir.ui.menu,name:report_qweb_field_option.menu_qweb_field_options
msgid "Qweb Field Options"
msgstr ""
#. module: report_qweb_field_option
#: model_terms:ir.ui.view,arch_db:report_qweb_field_option.view_qweb_field_options_searh
msgid "Qweb Field Options Search"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_id
msgid "UoM"
msgstr ""
#. module: report_qweb_field_option
#: model:ir.model.fields,field_description:report_qweb_field_option.field_qweb_field_options__uom_field_id
msgid "UoM Field"
msgstr ""

View File

@@ -0,0 +1,2 @@
from . import ir_qweb
from . import qweb_field_options

View File

@@ -0,0 +1,33 @@
# Copyright 2024-2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
class IrQweb(models.AbstractModel):
_inherit = "ir.qweb"
@api.model
def _get_field(
self, record, field_name, expression, tagName, field_options, values
):
if values.get("report_type") == "pdf":
company = getattr(record, "company_id", False) or self.env.company
options_recs = self.env["qweb.field.options"].search(
[
("res_model_name", "=", record._name),
("field_name", "=", field_name),
"|",
("company_id", "=", company.id),
("company_id", "=", False),
]
)
options_recs = [r for r in options_recs if r._get_score(record) > 0]
if options_recs:
options_rec = max(
options_recs, default=None, key=lambda r: r._get_score(record)
)
field_options = options_rec._update_field_options(record, field_options)
return super()._get_field(
record, field_name, expression, tagName, field_options, values
)

View File

@@ -0,0 +1,116 @@
# Copyright 2024-2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import ast
import logging
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__)
class QwebFieldOptions(models.Model):
_name = "qweb.field.options"
_description = "Qweb Field Options"
_order = "res_model_id, field_id"
res_model_id = fields.Many2one(
"ir.model", string="Model", ondelete="cascade", required=True
)
res_model_name = fields.Char("Model Name", related="res_model_id.model", store=True)
field_id = fields.Many2one(
"ir.model.fields",
domain="[('model_id', '=', res_model_id)]",
string="Field",
ondelete="cascade",
required=True,
)
field_type = fields.Selection(related="field_id.ttype")
field_name = fields.Char("Field Name", related="field_id.name", store=True)
uom_id = fields.Many2one("uom.uom", string="UoM", ondelete="cascade")
uom_field_id = fields.Many2one(
"ir.model.fields",
domain="[('model_id', '=', res_model_id), ('relation', '=', 'uom.uom')]",
string="UoM Field",
ondelete="cascade",
)
currency_id = fields.Many2one("res.currency", string="Currency", ondelete="cascade")
currency_field_id = fields.Many2one(
"ir.model.fields",
domain="[('model_id', '=', res_model_id), ('relation', '=', 'res.currency')]",
string="Currency Field",
ondelete="cascade",
)
field_options = fields.Char(
"Options",
help="A string representation of a dictionary to specify field formatting "
"options. Examples:\n"
"{'widget': 'date'}\n"
"{'widget': 'monetary'}\n"
"{'widget': 'contact', 'fields': ['name', 'phone']}",
)
digits = fields.Integer()
company_id = fields.Many2one("res.company", string="Company")
@api.constrains("field_options")
def _check_field_options_format(self):
for rec in self:
if not rec.field_options:
continue
field_options = False
try:
field_options = ast.literal_eval(rec.field_options)
except Exception as e:
raise ValidationError(
_(
"Invalid string for the Options field: %(field_options)s.\n"
"Error: %(error)s"
)
% {"field_options": rec.field_options, "error": e}
) from e
if not isinstance(field_options, dict):
raise ValidationError(
_("Options must be a dictionary, but got %s") % type(field_options)
)
def _get_score(self, record):
self.ensure_one()
score = 1
# Just increment the score as the record already matches the company_id,
# which has been filtered prior to calling this method.
if self.company_id:
score += 1
if self.uom_id:
if record[self.uom_field_id.sudo().name] == self.uom_id:
score += 1
else:
return -1
if self.currency_id:
if record[self.currency_field_id.sudo().name] == self.currency_id:
score += 1
else:
return -1
return score
def _update_field_options(self, record, field_options):
self.ensure_one()
if self.field_options:
try:
extra_options = ast.literal_eval(self.field_options)
if extra_options.get("widget") == "monetary":
extra_options["display_currency"] = (
self.currency_id
or hasattr(record, "company_id")
and record.company_id.currency_id
or self.env.company.currency_id
)
field_options.update(extra_options)
except Exception as e:
_logger.error(
"Failed to parse field options as a dictionary: "
f"{self.field_options}. Error: {e}"
)
elif self.field_type == "float":
field_options["precision"] = self.digits
return field_options

View File

@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@@ -0,0 +1,14 @@
Go to *Settings \> Technical \> Reporting \> Qweb Field Options*, and
create records according to your needs.
For each record:
- Set **Model** and **Field** (required)
- Set **UoM** and **UoM Field**, or **Currency** and **Currency Field**
only for fields of float type (optional)
- Set **Company** (optional)
- Set **Options** as a string representation of a dictionary. E.g.,
`{"widget": "date"}`, `{"widget": "monetary"}`, or
`{"widget": "contact", "fields": ["name", "phone"]}`
- Set **Digits** (only for float-type fields). The value is ignored if
Options is set

View File

@@ -0,0 +1,3 @@
- [Quartile](https://www.quartile.co):
- Yoshi Tashiro
- Aung Ko Ko Lin

View File

@@ -0,0 +1,3 @@
This module allows administrators to define the decimal precision of
float fields and add option values to fields (e.g., adding a date widget
option to datetime fields) for QWeb report and view presentation.

View File

@@ -0,0 +1,17 @@
#. QWeb field option settings only apply to fields rendered with ``t-field``.
They dont work with ``t-esc`` or other expressions not using ``t-field``.
As a workaround, you could create a module that adds a computed field holding the
same value currently computed and displayed in the QWeb report using ``t-esc``, and
adjust the report template to display the field value using ``t-field``. This would
allow you to adjust the decimal precision as needed.
#. Assigning Options in a QWeb Field Options record can cause UI issues if a field is
defined twice with different widgets in a view.
For example, adding ``{"widget": "date"}`` to the date_approve field in a purchase
order can result in two dates appearing under the Confirmation Date column in the
portal view. This occurs because the field is defined twice with different widgets.
Reference: https://github.com/odoo/odoo/blob/5eec379/addons/purchase/views/portal_templates.xml#L101-L102

View File

@@ -0,0 +1,6 @@
Print a QWeb report (quotation, invoice, purchase order, etc.), and the
value presentation for fields like line quantity, price unit and date
order are adjusted according to the Qweb Field Options configuration.
Note that among matching configuration records, the one with the
strictest condition will be applied.

View File

@@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_qweb_field_options_public,access.qweb.field.options.public,model_qweb_field_options,base.group_public,1,0,0,0
access_qweb_field_options_portal,access.qweb.field.options.portal,model_qweb_field_options,base.group_portal,1,0,0,0
access_qweb_field_options_user,access.qweb.field.options.user,model_qweb_field_options,base.group_user,1,0,0,0
access_qweb_field_options_admin,access.qweb.field.options.admin,model_qweb_field_options,base.group_system,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_qweb_field_options_public access.qweb.field.options.public model_qweb_field_options base.group_public 1 0 0 0
3 access_qweb_field_options_portal access.qweb.field.options.portal model_qweb_field_options base.group_portal 1 0 0 0
4 access_qweb_field_options_user access.qweb.field.options.user model_qweb_field_options base.group_user 1 0 0 0
5 access_qweb_field_options_admin access.qweb.field.options.admin model_qweb_field_options base.group_system 1 1 1 1

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="qweb_field_options_company_rule" model="ir.rule">
<field name="name">Qweb Field Options Multi-company</field>
<field name="model_id" ref="model_qweb_field_options" />
<field
name="domain_force"
>['|', ('company_id', 'in', company_ids), ('company_id', '=', False)]</field>
</record>
</odoo>

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,485 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document">
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="report-qweb-field-option">
<h1>Report Qweb Field Option</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6a839e0b8361541500cea7946ac9d7bfbcbe37ab2a102576061a2940c4343c5c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/18.0/report_qweb_field_option"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-report_qweb_field_option"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows administrators to define the decimal precision of
float fields and add option values to fields (e.g., adding a date widget
option to datetime fields) for QWeb report and view presentation.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<p>Go to <em>Settings &gt; Technical &gt; Reporting &gt; Qweb Field Options</em>, and
create records according to your needs.</p>
<p>For each record:</p>
<ul class="simple">
<li>Set <strong>Model</strong> and <strong>Field</strong> (required)</li>
<li>Set <strong>UoM</strong> and <strong>UoM Field</strong>, or <strong>Currency</strong> and <strong>Currency Field</strong>
only for fields of float type (optional)</li>
<li>Set <strong>Company</strong> (optional)</li>
<li>Set <strong>Options</strong> as a string representation of a dictionary. E.g.,
<tt class="docutils literal">{&quot;widget&quot;: &quot;date&quot;}</tt>, <tt class="docutils literal">{&quot;widget&quot;: &quot;monetary&quot;}</tt>, or
<tt class="docutils literal">{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;name&quot;, <span class="pre">&quot;phone&quot;]}</span></tt></li>
<li>Set <strong>Digits</strong> (only for float-type fields). The value is ignored if
Options is set</li>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<p>Print a QWeb report (quotation, invoice, purchase order, etc.), and the
value presentation for fields like line quantity, price unit and date
order are adjusted according to the Qweb Field Options configuration.</p>
<p>Note that among matching configuration records, the one with the
strictest condition will be applied.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
<div class="line-block">
<div class="line">#. QWeb field option settings only apply to fields rendered with
<tt class="docutils literal"><span class="pre">t-field</span></tt>.</div>
<div class="line">They dont work with <tt class="docutils literal"><span class="pre">t-esc</span></tt> or other expressions not using
<tt class="docutils literal"><span class="pre">t-field</span></tt>.</div>
</div>
<p>As a workaround, you could create a module that adds a computed field
holding the same value currently computed and displayed in the QWeb
report using <tt class="docutils literal"><span class="pre">t-esc</span></tt>, and adjust the report template to display the
field value using <tt class="docutils literal"><span class="pre">t-field</span></tt>. This would allow you to adjust the
decimal precision as needed.</p>
<p>#. Assigning Options in a QWeb Field Options record can cause UI issues
if a field is defined twice with different widgets in a view.</p>
<p>For example, adding <tt class="docutils literal">{&quot;widget&quot;: &quot;date&quot;}</tt> to the date_approve field in
a purchase order can result in two dates appearing under the
Confirmation Date column in the portal view. This occurs because the
field is defined twice with different widgets.</p>
<p>Reference:
<a class="reference external" href="https://github.com/odoo/odoo/blob/5eec379/addons/purchase/views/portal_templates.xml#L101-L102">https://github.com/odoo/odoo/blob/5eec379/addons/purchase/views/portal_templates.xml#L101-L102</a></p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_qweb_field_option%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
<ul class="simple">
<li>Quartile</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
<ul class="simple">
<li><a class="reference external" href="https://www.quartile.co">Quartile</a>:<ul>
<li>Yoshi Tashiro</li>
<li>Aung Ko Ko Lin</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/18.0/report_qweb_field_option">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1 @@
from . import test_report_qweb_field_options

View File

@@ -0,0 +1,15 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class TestQwebFieldModel(models.Model):
_name = "test.qweb.field.options"
_description = "Test Qweb Field Options"
name = fields.Char()
quantity = fields.Float()
uom_id = fields.Many2one("uom.uom")
value = fields.Float(string="Rounding Factor")
currency_id = fields.Many2one("res.currency")
company_id = fields.Many2one("res.company")

View File

@@ -0,0 +1,155 @@
# Copyright 2024 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo_test_helper import FakeModelLoader
from odoo.exceptions import ValidationError
from odoo.tests.common import TransactionCase
class TestQwebFieldOptions(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.loader = FakeModelLoader(cls.env, cls.__module__)
cls.loader.backup_registry()
from .test_models import TestQwebFieldModel
cls.loader.update_registry((TestQwebFieldModel,))
cls.test_model = cls.env.ref(
"report_qweb_field_option.model_test_qweb_field_options"
)
cls.quantity_field = cls.env["ir.model.fields"]._get(
"test.qweb.field.options", "quantity"
)
cls.uom_field = cls.env["ir.model.fields"]._get(
"test.qweb.field.options", "uom_id"
)
cls.value_field = cls.env["ir.model.fields"]._get(
"test.qweb.field.options", "value"
)
cls.currency_field = cls.env["ir.model.fields"]._get(
"test.qweb.field.options", "currency_id"
)
cls.IrQweb = cls.env["ir.qweb"]
cls.test_currency = cls.env["res.currency"].create(
{"name": "Test Currency", "symbol": "$"}
)
cls.unit_uom = cls.env.ref("uom.product_uom_unit")
cls.test_record = cls.env["test.qweb.field.options"].create(
{
"name": "Test",
"quantity": 1.00,
"value": 1.00,
"currency_id": cls.test_currency.id,
"company_id": cls.env.company.id,
}
)
cls.qweb_options_rec = cls.env["qweb.field.options"].create(
{
"res_model_id": cls.test_model.id,
"field_id": cls.value_field.id,
"currency_id": cls.test_currency.id,
"currency_field_id": cls.currency_field.id,
"digits": 0,
}
)
cls.env["qweb.field.options"].create(
{
"res_model_id": cls.test_model.id,
"field_id": cls.quantity_field.id,
"uom_id": cls.unit_uom.id,
"uom_field_id": cls.uom_field.id,
"digits": 3,
}
)
@classmethod
def tearDownClass(cls):
cls.loader.restore_registry()
return super().tearDownClass()
def test_qweb_field_option(self):
values = {"report_type": "pdf"}
# Test with 0 digits
_, content, _ = self.IrQweb._get_field(
self.test_record, "value", False, False, {}, values
)
self.assertEqual(content, "1")
# Test with 2 digits
self.qweb_options_rec.digits = 2
_, content, _ = self.IrQweb._get_field(
self.test_record, "value", False, False, {}, values
)
self.assertEqual(content, "1.00")
# Test with 3 digits
self.qweb_options_rec.digits = 3
_, content, _ = self.IrQweb._get_field(
self.test_record, "value", False, False, {}, values
)
self.assertEqual(content, "1.000")
# Test with widget
self.qweb_options_rec.field_options = "{'widget': 'monetary'}"
_, content, _ = self.IrQweb._get_field(
self.test_record, "value", False, False, {}, values
)
self.assertIn("$", content)
# Test that an error is raised when the input value is incorrect.
with self.assertRaises(ValidationError):
self.qweb_options_rec.field_options = (
"{'widget': 'monetary', 'currency_field': self.test_record}"
)
with self.assertRaises(ValidationError):
self.qweb_options_rec.field_options = "'widget': 'monetary'"
def test_qweb_field_option_with_multiple_record(self):
values = {"report_type": "pdf"}
qweb_options_company_rec = self.env["qweb.field.options"].create(
{
"res_model_id": self.test_model.id,
"field_id": self.value_field.id,
"currency_id": self.test_currency.id,
"currency_field_id": self.currency_field.id,
"company_id": self.env.company.id,
"digits": 1,
}
)
# If there are two records, one with and one without a company,
# it should prioritize the record with the company_id
_, content, _ = self.IrQweb._get_field(
self.test_record, "value", False, False, {}, values
)
self.assertEqual(content, "1.0")
qweb_options_company_rec.field_options = "{'widget': 'monetary'}"
_, content, _ = self.IrQweb._get_field(
self.test_record, "value", False, False, {}, values
)
self.assertIn("$", content)
# Test after unlinking the options record
qweb_options_company_rec.unlink()
_, content, _ = self.IrQweb._get_field(
self.test_record, "value", False, False, {}, values
)
self.assertNotEqual(content, "1.0")
self.assertNotIn("$", content)
def test_qweb_field_option_with_uom(self):
values = {"report_type": "pdf"}
self.test_record.uom_id = self.unit_uom.id
_, content, _ = self.IrQweb._get_field(
self.test_record, "quantity", False, False, {}, values
)
self.assertEqual(content, "1.000")
self.test_record.uom_id = self.env.ref("uom.product_uom_dozen").id
_, content, _ = self.IrQweb._get_field(
self.test_record, "quantity", False, False, {}, values
)
self.assertEqual(content, "1.0")

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_qweb_field_options_tree" model="ir.ui.view">
<field name="name">qweb.field.options.list</field>
<field name="model">qweb.field.options</field>
<field name="type">list</field>
<field name="arch" type="xml">
<list create="1" editable="bottom">
<field name="res_model_id" />
<field name="field_id" readonly="res_model_id == False" />
<field name="field_type" column_invisible="True" />
<field
name="uom_id"
readonly="currency_id !=False or field_type != 'float'"
/>
<field
name="uom_field_id"
readonly="uom_id == False"
required="uom_id != False"
/>
<field
name="currency_id"
readonly="uom_id != False or field_type != 'float'"
/>
<field
name="currency_field_id"
readonly="currency_id == False"
required="currency_id != False"
/>
<field
name="company_id"
groups="base.group_multi_company"
optional="show"
/>
<field name="field_options" />
<field name="digits" readonly="field_type != 'float'" />
</list>
</field>
</record>
<record id="view_qweb_field_options_searh" model="ir.ui.view">
<field name="name">qweb.field.options.search</field>
<field name="model">qweb.field.options</field>
<field name="arch" type="xml">
<search string="Qweb Field Options Search">
<field name="res_model_id" />
<field name="field_id" />
<field name="uom_id" />
<field name="currency_id" />
<field name="company_id" />
<separator />
<group expand="1" string="Group By">
<filter
string="Model"
name="res_model_id"
context="{'group_by': 'res_model_id'}"
/>
</group>
</search>
</field>
</record>
<record id="action_qweb_field_options_view" model="ir.actions.act_window">
<field name="name">Qweb Field Options</field>
<field name="res_model">qweb.field.options</field>
<field name="view_mode">list</field>
<field name="view_id" ref="view_qweb_field_options_tree" />
</record>
<menuitem
id="menu_qweb_field_options"
parent="base.reporting_menuitem"
action="action_qweb_field_options_view"
sequence="10"
/>
</odoo>