Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
11068 Lượt xem

Hi all,

I'm new to Odoo but have robust programming skills. i would like to add a module to allow users to optionally associate an invoice template to their customers and use the associated invoice template as a replacement to the default invoice model.

To add a field on the customer form to record the template to use, I know how to do it. However I have no idea about how to catch the Print > Invoice event and exploit the defined value in the field and either apply a custom template or use the regular default one.

Could you please help me with this?


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Did anybody solve this? I have a framework agreement with a local community for the next 4 years. They want special texts in the invoice header and also some more text fields which 98% of my customers do not need. So an invoice template just for that client would be great. 

Ảnh đại diện
Huỷ bỏ

Stefan, In that case you can design the new invoice template and use according to the customers

Câu trả lời hay nhất

the printed standard xml templates from odoo are located in settings -> reports -> reports

there you have for example the invoice template. 


There you click on Qweb and then you have the xml of this printed report.


The report_invoice_document is the main file.

For more information check the odoo documentations: https://www.odoo.com/documentation/10.0/reference/reports.html


best regards


 



Ảnh đại diện
Huỷ bỏ
Tác giả

I know this. The idea is not to modify the same default invoice report for all our customers, but to be able to add a *per customer* template to address our needs. For example, use a special invoice template for customers in the USA, another one for our customers in Europe, etc.

you can handle this by adding a new .xml template to your module and then to add it to the print button. you can work with translations or with language querys ..

Tác giả

That's not I want to do. I don't want sales users to be able to chose the kind of document to print. And want this to be configured once and for all into the client's information and automatically used by Odoo when using the regular "Print > Invoice".

My question is : how to catch the "Print > Invoice" event and exploit the defined value in the field and either apply a custom template or use the regular default one.

you can look in the module that imports the invoice template and the print function. so then you can modify it like you want. I don't have time right now to search it, but I think it's in the account_invoice module or in the reports.

Tác giả

I'll examine this module and consider if I can inherit its print function (or one function it uses to load the template.xml files) in my module to optionally override its behavior. Thanks. :)

Tác giả

Read overload instead of override.

Tác giả

@wizards, it's the account_invoice module that defines the account.invoice model in addons/account/models/account_invoice.py.

Then a template named account.report_invoice in is defined in addons/account/views/report_invoice.xml.

Both model and template are associated through a report /addons/account/views/account_report.xml.

The thing is, as the report is defined as XML, I do not know how to dynamically replace it. Is it possible to create a new model inheriting of account_invoice in order to overload its "file" attribut?

If so, how to do that ?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 22
2387
0
thg 3 22
2
1
thg 11 19
5451
0
thg 10 18
3923
2
thg 3 18
3843