I have two reports for journal entries and i want to print a report based on the journal type. if journal type is bank then the report1 must print and if journal type is cash then report2 must print. kindly help me with the python code for implying this condition i have already made reports and button but struggling with the conditional statement. Thanks in advance
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
There will be 2 Report option available to print in Print menu if you added two reports in code.
So firstly hide this report from print option by clicking " Remove from the 'Print' menu " in report form.
Then You can add a button in journal entry form view and in button action we can define which report to be printed.
in View and PY //
thanks for replying. I do have two reports in the print menu but i want odoo to check if the journal type is "Bank" then after pressing print button it print report 1 and if journal type is "Cash" print report 2. How should i write for that?
Yes i got your intuition that's why i said you can remove the 2 print option from print menu and you can add a button in form view . then in py we can check the journal type. Please check the code.
sir m really sorry as i am bothering you again but it is giving key error "report". kindly check my code. Actually my pasted code :D
class AccountMove(models.Model):
_inherit = 'account.move'
@api.multi
def print_journal_entry(self):
self.ensure_one()
if self.journal_id.type == 'bank':
return self.env['report'].get_action(self,'bi_print_journal_entries.bank_journal_entry_report_id')
elif self.journal_id.type == 'cash':
return self.env['report'].get_action(self, 'bi_print_journal_entries.journal_entry_report_id')
else:
pass
No problem, actually that was my issue So sorry. I have used code for V12 , now i have updated the code please check it.
Hey man! you are a life saver. Thank you soo much :) it works 100%
Glad You find your Solution. Have a Great Day dude!
No problem, actually that was my issue So sorry. I have used code for V12 , now i have updated the code please check it.
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 | |
---|---|---|---|---|
|
2
Jul 24
|
12604 | ||
|
1
Jul 21
|
6665 | ||
|
0
Apr 20
|
3412 | ||
|
1
May 18
|
2144 | ||
|
0
Apr 18
|
2495 |