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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
2
Trả lời
3101
Lượt xem
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
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 2 25
|
5216 | ||
|
1
thg 3 19
|
6809 | ||
|
1
thg 5 16
|
3001 | ||
|
1
thg 3 15
|
5606 | ||
|
0
thg 9 17
|
3261 |