Substitution variables / extrafield

Hello everybody,

when I add an extrafield for invoices inserting e.g. the global substitution variable __YEAR__ it prints the year onto the generated pdf. When I do the same for the invoice line item, it does not print the year but the expression__YEAR__ on the generated pdf.

Does anyone have an idea how to resolve this? May it be a bug?

Thank you and merci :slight_smile:

Just try creating an extra-field defined under [Complementary attributes (lines) {YEAR}

thank you - I tried as you suggested {YEAR} but this does not work either. I think the syntax for the global substitution variables is like this: __YEAR__

( Variable substitution system - Dolibarr ERP CRM Wiki )

On the invoice header __YEAR__ works but not under complementary attributes (line) on the same document…

You need to create a Line extrafiled

__YEAR__

this is what I did but it does not work in the line extrafield. It only works for the invoice extrafield, but not on the invoice (line) extrafield. It prints __YEAR__instead of “2022” on the item line in the pdf…

actually, I typed {__YEAR__} Now, changed it to backslash { and seem to be displaying correct.

Just try that …

thanks
yesbee

no, {__YEAR__} doesn’t work either :thinking:

Hi,

I just modified one of my invoice odt:
a) opened a new column
b) just typed (repeat typed not copy pasted to avoid any hidden char) {__YEAR__}
c) saved and uploaded into setup
d) run the invoice using new template

Below is the result:

Basically, it works fine. Just try typing it straight on to your ODT no extra fields needed.

If this solves your issue, kindly send a thumbs up to dolibarr, which is a very nice software and @ksar and @eldy are great in creating this…

thanks
yesbee.

Hi yesbee,

THANK you for your effort and thank you to @ksar and @eldy for this great software!

Here are the steps I do:
create extra field (line):

then add product line into invoice:

create PDF invoice with the included template sponge → result:

Screenshot 2022-03-25 at 14-08-41 FA2203-0108 - FA2203-0108.pdf

I cannot use odt templates because it LO is not installed on my shared hosting.

Kind regards

Ok, try this …

Hello,

Should be out of the description.
Put it directly on the ODT

it is not in the description, it is an extra field (line) UNDER the description. It just looks as if it is in the description on my screenshot

the __YEAR__ is just an example for a substitution variable, so the code won’t help me.

I THINK the problem is not to load the extra field itsself, the problem is that on the line level the substitution variable’s content is not loaded within the extra field.

Doing the same on the invoice header works as expected (also with the substitution variable __YEAR__ behind it). This screenshot shows the web interface:

this one the result on the PDF (template sponge):
Screenshot 2022-03-25 at 20-48-46 FA2203-0109 - FA2203-0109.pdf

Hello @unrat
I’m late to the party, but do you still have the issue?
As I needed this myself, I investigated and came to realize that variables in invoice line items are only substituted when using the ODT templates, not the PDF template.
And the correct syntax is {object_date} for the date of the invoice.

1 Like