Skip to content

Commit e72b537

Browse files
meval1006huisitFelicious
committed
[IMP] sales: dynamic text in pdfs update
closes #17255 X-original-commit: 9a08f58 Signed-off-by: Megan Valenzuela (meval) <meval@odoo.com> Co-authored-by: Rex <11528309+huisit@users.noreply.github.com> Co-authored-by: Felicia Kuan <freakyotaku@gmail.com>
1 parent 39080e1 commit e72b537

7 files changed

Lines changed: 171 additions & 37 deletions

File tree

content/applications/sales/sales/sales_quotations/pdf_quote_builder/dynamic_text.rst

Lines changed: 171 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,172 @@
1-
====================
2-
Dynamic text in PDFs
3-
====================
1+
.. _Adobe: https://helpx.adobe.com/acrobat/desktop/work-with-pdf-forms/create-forms/convert-to-forms.html
42

5-
While creating custom PDFs for quotes, use *dynamic text* for Odoo to auto-fill the PDF content with
6-
information related to the quote from the Odoo database, like names, prices, etc.
3+
=====================================
4+
Configure dynamic form fields in PDFs
5+
=====================================
76

8-
Dynamic text values are form components (text inputs) that can be added in a PDF file, and Odoo
9-
automatically fills those values in with information related to the quote.
7+
When creating custom PDFs to import into the **Sales** app, use *dynamic form fields* to auto-fill
8+
the PDF content with relevant information from the Odoo database, including names and prices.
109

11-
Dynamic text values
12-
===================
10+
*Dynamic form fields* are configurable text fields that can be added to a PDF form, and Odoo
11+
automatically fills them with values from the sales order/product associated with the quote.
1312

14-
Below are common dynamic text values used in custom PDFs that are already mapped to the correct
15-
fields, and what they represent.
13+
Formatting tips
14+
===============
15+
16+
When designing the base PDF template for a quote’s header or footer, keep the placements of *dynamic
17+
form field* in mind. Use the following tips to avoid overlapping text and other formatting issues:
18+
19+
- **Leave whitespace**: Ensure there is enough room for dynamic data to expand without overlapping
20+
logos or borders.
21+
- **Add line breaks**: Place dynamic form fields, like *Customer Name*, on their own lines.
22+
Alternatively, put them at the end of phrases to avoid text breaking. Long names can push static
23+
text out of alignment.
24+
- **Leave whitespace**: Ensure there is enough room for dynamic data to expand without overlapping
25+
logos or borders.
26+
- **Add line breaks**: Place dynamic form fields, like *Customer Name*, on their own lines.
27+
Alternatively, put them at the end of phrases to avoid text breaking. Long names can push static
28+
text out of alignment. text appearance when adding or editing content.
29+
30+
Odoo recommends editing PDF forms with Adobe software. Form fields in header and footer templates
31+
are required to retrieve dynamic values in Odoo.
32+
33+
.. tip::
34+
If the PDF is too large to send as an email attachment, try using "system fonts" (e.g., Arial,
35+
Helvetica, Times New Roman) instead of custom fonts to reduce the file size.
36+
37+
Create dynamic form fields in PDF
38+
=================================
39+
40+
.. important::
41+
Odoo does not permit spaces in PDF field names. Only use letters, numbers, hyphens, or
42+
underscores.
43+
44+
To add dynamic form fields, use the preferred PDF editor, such as Adobe Acrobat Pro or Scribus.
45+
Refer to the following instructions to:
46+
47+
- Find :ref:`pdf_quote_builder/dynamic_text/common-dynamic-text-values`.
48+
- :ref:`pdf_quote_builder/dynamic_text/Odoo-field-path`.
49+
- :ref:`pdf_quote_builder/dynamic_text/custom-dynamic-form-fields` in Odoo after uploading the PDF.
50+
51+
Adobe Acrobat Pro
52+
-----------------
53+
54+
`Convert the PDF into a PDF form <Adobe_>`_, then add a *dynamic form field* at the location where
55+
the Odoo information should be inserted. Link the Odoo fields to the *dynamic form fields* by
56+
double-clicking on the field to open :guilabel:`Properties`.
57+
58+
In the :guilabel:`General tab`, enter the name of the Odoo field for the :guilabel:`Name`. Set the
59+
:guilabel:`Common Properties` to :guilabel:`Visible` unless the field needs to be hidden until data
60+
is populated.
61+
62+
Next, click the :guilabel:`Appearance` tab and select the :guilabel:`Font Size`, :guilabel:`Font
63+
Choice`, and :guilabel:`Text Color` to match the template's existing text or branding. Click the
64+
:guilabel:`Options` tab and set the text alignment to match the template’s design.
65+
66+
Generic PDF editor
67+
------------------
68+
69+
Open the PDF with the PDF editor, add a *dynamic form field* where the Odoo information is needed.
70+
Link the Odoo fields to the *dynamic form fields* by opening the field’s :guilabel:`Properties`
71+
window. Then, in the :guilabel:`Name` for that field, enter the name of the Odoo field.
72+
73+
If possible, configure the :guilabel:`Font Size`, :guilabel:`Font Choice`, and :guilabel:`Text
74+
Color` to match the template's existing text or branding. Click the :guilabel:`Options` tab and set
75+
the text alignment to match the template’s design.
76+
77+
Map PDF form fields to Odoo
78+
===========================
79+
80+
This step connects any *dynamic form field* in the PDF to the corresponding Odoo field by specifying
81+
the exact location of that information. Once the PDF file is ready, save the changes and upload it
82+
to Odoo via :menuselection:`Sales app --> Configuration --> Headers/Footers` and clicking
83+
:guilabel:`Upload`.
84+
85+
Odoo automatically detects *dynamic form fields* in the uploaded PDF and displays the
86+
:guilabel:`Configure dynamic fields` link. Click the :guilabel:`Configure dynamic fields` link to go
87+
to the :guilabel:`Form Fields` page.
88+
89+
The :guilabel:`Form Field Name` column is populated with the *dynamic form fields* from the PDF. The
90+
:guilabel:`Path` column specifies the path to the Odoo field corresponding to each *dynamic form
91+
field*.
92+
93+
.. image:: dynamic_text/form-fields-page.png
94+
:alt: Configured text form fields in the PDF quote builder.
95+
96+
To edit, click the :guilabel:`Path` cell of the desired form field row and enter the Odoo field
97+
name. Refer to the :ref:`pdf_quote_builder/dynamic_text/common-dynamic-text-values` section for
98+
typical field names. Refer to the :ref:`pdf_quote_builder/dynamic_text/Odoo-field-path` section for
99+
instructions on how to find Odoo field names and paths.
100+
101+
.. _pdf_quote_builder/dynamic_text/Odoo-field-path:
102+
103+
Find Odoo field names or paths
104+
------------------------------
105+
106+
Users can enable :ref:`developer-mode` in Odoo and hover over the desired field to see its technical
107+
name, which is the :guilabel:`Field` value in the pop-up window. Or, while in Developer Mode,
108+
navigate to the :menuselection:`Settings --> Technical --> Email Templates` menu. In the search bar,
109+
search for "Sales", then open a *Sales template* to see the :ref:`available dynamic form fields and
110+
their paths <email_template/dynamic-placeholders>`.
111+
112+
.. _pdf_quote_builder/dynamic_text/custom-dynamic-form-fields:
113+
114+
Configure custom dynamic form fields
115+
------------------------------------
116+
117+
To pull specific information from a sales order or a product that is not in the
118+
:ref:`pdf_quote_builder/dynamic_text/common-dynamic-text-values` section, add a *dynamic form field*
119+
to the PDF with a unique name, then configure the :guilabel:`Path` to point to the desired
120+
information in Odoo.
121+
122+
When configuring the :guilabel:`Path`, use the dot (`.`) notation to specify relationships between
123+
models. Headers and footers start from the current :guilabel:`sale_order` model. Product documents
124+
follow their path from :guilabel:`sale_order_line`.
125+
126+
.. example::
127+
A company wants to display the customer's country in its quotations. To display the customer's
128+
country in the quotation PDF, they used the dynamic form field name
129+
:guilabel:`invoice_partner_country` in the PDF template. After uploading the PDF to the **Sales**
130+
app, they set the :guilabel:`Path` of the :guilabel:`Form Field Name` to:
131+
132+
- For a header or footer document: :guilabel:`partner_invoice_id.country_id.name`
133+
134+
.. figure:: dynamic_text/example-country-quotation-path.png
135+
:alt: The customer's country form field pathing for a quotation.
136+
137+
Example of Odoo's Form Field Path for the customer's country from a quotation.
138+
139+
- For a product document: :guilabel:`order_id.partner_invoice_id.country_id.name`
140+
141+
.. figure:: dynamic_text/example-country-product-document-path.png
142+
:alt: The customer's country form field pathing from the product document.
143+
144+
Example of Odoo's Form Field Path for the customer's country from a product document.
145+
146+
Create a custom note form field
147+
-------------------------------
148+
149+
When uploading any PDF containing the form field :guilabel:`custom_note`, leaving the
150+
:guilabel:`Path` empty allows the seller to add any note to that form field in the document, which
151+
shown when the PDF is built.
152+
153+
.. figure:: dynamic_text/example-custom-note.png
154+
:alt: Custom note field name with an empty Path cell.
155+
156+
Leave the :guilabel:`Path` column cell empty for the :guilabel:`custom_note` row.
157+
158+
.. figure:: dynamic_text/example-pdf-empty-field.png
159+
:alt: Quote Builder tab with note field to customize.
160+
161+
The note field in the *Header* section in the :guilabel:`Quote Builder` tab on a quotation.
162+
163+
.. _pdf_quote_builder/dynamic_text/common-dynamic-text-values:
164+
165+
Common dynamic form fields
166+
==========================
167+
168+
Below are common dynamic form fields to use in custom PDFs that automatically map to the correct
169+
Odoo fields when uploaded to the **Sales** app, and what they represent.
16170

17171
For headers and footers PDF:
18172

@@ -38,36 +192,16 @@ For product PDF:
38192
- :guilabel:`tax_excl_price`: Tax Excluded Price
39193
- :guilabel:`tax_incl_price`: Tax Included Price
40194

41-
After uploading a PDF, you can then :guilabel:`Configure dynamic fields`. This will allow you to map
42-
any field name found in your PDF to the field you want to show by writing down any existing path.
43-
Headers and footers starts from the current :guilabel:`sale_order` model, whereas product document
44-
follows their path from their :guilabel:`sale_order_line`. Leaving that path empty allows you to
45-
fill a custom notes, directly from the specific quote that requires it.
46-
47195
.. example::
48-
When a PDF is built, it's best practice to use common dynamic text values (:guilabel:`name` and
49-
:guilabel:`partner_id_name`). When uploaded into the database, Odoo auto-populates those fields
50-
with the information from their respective fields.
196+
When creating a PDF, it's best practice to use common dynamic form fields
197+
(:guilabel:`user_id_name`, :guilabel:`partner_id_name`, and :guilabel:`name`). When uploaded into
198+
the database, Odoo auto-populates those fields with the information from their respective fields.
51199

52-
In this case, Odoo would auto-populate the Sales Order Reference in the :guilabel:`name` dynamic
53-
text field, and the Customer Name in the :guilabel:`partner_id_name` field.
200+
In this case, Odoo would auto-populate the Salesperson's name in the :guilabel:`user_id_name`
201+
dynamic text field, the Sales Order Reference in the :guilabel:`name` field, and the Customer
202+
Name in the :guilabel:`partner_id_name` field.
54203

55204
.. image:: dynamic_text/pdf-quote-builder-sample.png
56205
:align: center
57206
:alt: PDF quote being built using common dynamic placeholders.
58207

59-
Once the PDF file(s) are complete, save them to the computer's hard drive, and proceed to upload
60-
them to Odoo via :menuselection:`Sales app --> Configuration --> Headers/Footers`.
61-
62-
.. example::
63-
When uploading PDF containing the form field :guilabel:`invoice_partner_country`, which is an
64-
information available in the sales order, configure the :guilabel:`path` of the :guilabel:`Form
65-
Field Name` to:
66-
- :guilabel:`partner_invoice_id.country_id.name` for a header or footer document
67-
- :guilabel:`order_id.partner_invoice_id.country_id.name` for a product document fills the form
68-
with the invoice partner country's name when the PDF is built.
69-
70-
.. example::
71-
When uploading any PDF containing the form field :guilabel:`custom_note`, leaving the
72-
:guilabel:`path` empty allows the seller to write down any note where that form field is in that
73-
document and shown when the PDF is built.
4.56 KB
Loading
5.81 KB
Loading
6.05 KB
Loading
6.65 KB
Loading
7.63 KB
Loading
89.6 KB
Loading

0 commit comments

Comments
 (0)