Debian Codegraph @

addons/l10n_tr_nilvera_einvoice/models/account_journal.py

raw
1 from odoo import api, models
2
3
4 class AccountJournal(models.Model):
5 _inherit = 'account.journal'
6
7 @api.depends('is_nilvera_journal', 'l10n_tr_nilvera_api_key', 'type')
8 def _compute_show_fetch_in_einvoices_button(self):
9 # EXTENDS 'account'
10 super()._compute_show_fetch_in_einvoices_button()
11 self.filtered(
12 lambda j: j.is_nilvera_journal and
13 j.l10n_tr_nilvera_api_key and
14 j.type == 'purchase'
15 ).show_fetch_in_einvoices_button = True
16
17 @api.depends('l10n_tr_nilvera_api_key', 'type')
18 def _compute_show_refresh_out_einvoices_status_button(self):
19 # EXTENDS 'account'
20 super()._compute_show_refresh_out_einvoices_status_button()
21 self.filtered(
22 lambda j: j.l10n_tr_nilvera_api_key and
23 j.type == 'sale'
24 ).show_refresh_out_einvoices_status_button = True
25
26 def button_fetch_in_einvoices(self):
27 # EXTENDS 'account'
28 """ Fetches bills from Nilvera."""
29 super().button_fetch_in_einvoices()
30 self.env['account.move']._cron_nilvera_get_new_einvoice_purchase_documents()
31
32 def button_refresh_out_einvoices_status(self):
33 # EXTENDS 'account'
34 super().button_refresh_out_einvoices_status()
35 self.env['account.move']._cron_nilvera_get_invoice_status()