跳至内容
菜单
此问题已终结
2 回复
146 查看

I want to override parts of the invoice template. Neither Google, ChatGPT, Claude or the Odoo documentation can help me with this.

What I want to do is pretty simple. If the address is a contact under a company it's formatted this way:

[Company Name], [Name Contactperson]

But what I want is this:

[Company Name]
T.a.v. [Name Contactperson]

Who can help me with this or at least point me in the right direction?

I use Odoo 18 Online and I have access to Odoo Studio.

Cheers!

形象
丢弃

If you're struggling to find the template code responsible for generating template:
Go to any Invoice (Accounting/Invoicing App > Open Studio > Click on "Reports" > Choose "Invoice PDF" > happy coding).
Then you'll probably have to adjust template (not sure if Studio replaces the code, or just create new, inheriting QWeb Template, you'd need to find out), or use the solution suggested by @Marawan Ahmed.

Best Regards,
Dawid Gacek, Adapt IT (adapt-it.pl)

编写者 最佳答案

Thanks Dawid. The problem isn't finding the place where to change the code. It's completely unclear and undocumented what I have to change in which template. There is so much inheritance that I can't find where for instance the code is that formats the address.

形象
丢弃

So in the it is a call to other template named web.address_layout​. You can find web.address_layout​ code by going to Settings > Technical > Views (under User Interface), and search for address_layout​.

There is not much in web.address_layout​ template, but it is some lead. I think (not 100% sure), that <html> field company.company_details​ is used there, somehow. I agree that it is not the most obvious to find it, but good luck.

Best Regards,

Dawid Gacek, Adapt IT

最佳答案

You want the address format in Odoo 18 Online to look like this:

[Company Name] T.a.v. [Contact Name]

instead of the default:

[Company Name], [Contact Name]

Solution

Since you are on Odoo 18 Online (SaaS), you don’t have access to the backend code, but you do have Odoo Studio, which is enough to customize reports and fields.

Option 1: Customize Report Template in Studio

  1. Open any report (e.g., Quotation, Invoice).
  2. Click Edit with Studio.
  3. Locate the Address Block that prints the partner’s details.
  4. Replace the content with:

    ${object.parent_id.name or ''} ← Company Name T.a.v. ${object.name or ''} ← Contact Name

    parent_id = company, name = contact.

Option 2: Create a Custom Field with Computed Value

If you want this format as a field you can reuse:

  1. In Studio, create a new field (e.g., “Formatted Address”).
  2. Set it as a Computed Field with this formula:

    (record.parent_id.name or '') + '\nT.a.v. ' + (record.name or '')

形象
丢弃
相关帖文 回复 查看 活动
1
12月 24
3377
3
3月 25
1068
2
5月 24
1400
1
2月 24
1492
1
4月 25
136