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
- 회계
- 재고 관리
- PoS
- Project
- MRP
신고된 질문입니다
2
답글
2746
화면
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
관련 게시물 | 답글 | 화면 | 활동 | |
---|---|---|---|---|
|
1
2월 25
|
4808 | ||
|
1
3월 19
|
6184 | ||
|
1
5월 16
|
2475 | ||
|
1
3월 15
|
5160 | ||
|
0
9월 17
|
2941 |