Hello everyone,
I am working on Odoo 12 and trying to put a "Print Receipt" button on payments form for the model account.payment.
This is located under Invoicing | Customers | Payments and Invoicing | Vendors | Payments
Loooking into the code for the account.payment, I can see that there is an xml that puts an Action menu option for printing the Payment Receipt, so I want to use this report for my button.
The xml for the core "account.payment" is (report definition):
<report
id="action_report_payment_receipt"
model="account.payment"
string="Payment Receipt"
report_type="qweb-pdf"
name="account.report_payment_receipt"
file="account.report_payment_receipt"
menu="True"
/>
So, I have inherited the account.payment form view and was abble to put the print button there, by:
<!-- PRINT RECEIPT BUTTON -->
<record id="receipt_form_print_document" model="ir.ui.view">
<field name="name">Print Receipt Button on Form</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button name="document_print" string="Print Receipt" type="object" attrs="{'invisible':[('state', '==', 'draft')]}" icon="fa-print" class="oe_highlight" groups="base.group_user"/>
</xpath>
</field>
</record>
The button is ok and is shown only when document is not in draft state.
For the button to work, I have inherited account.payment and entered the method "document_print" into it:
class AccountPayment(models.Model):
_inherit = 'account.payment'
@api.multi
def document_print(self):
self.env.ref('account.action_report_payment_receipt').report_action(self)
The problem is that I can see the button, but when pressed nothing happens.
Odoo raises no error but the report is simple not printed.
I garantee that Odoo locates the "action" for the report, because if I change it, Odoo raises and error...
What I am missing here?
Thank you all in advance
Best regards
PM
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
2
Replies
2265
Views
Hi,
Update the code with a return ,
@api.multi
def document_print(self):
return self.env.ref('account.action_report_payment_receipt').report_action(self)
Thanks
Thank you @Niyas,
It worked. +1000 for you.
Best regards
PM
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Mar 22
|
4312 | ||
|
1
Mar 19
|
5494 | ||
|
1
May 16
|
2073 | ||
|
1
Mar 15
|
4668 | ||
|
0
Sep 17
|
2462 |