| 1 |
from odoo import api, fields, models |
| 2 |
|
| 3 |
|
| 4 |
class AccountJournal(models.Model): |
| 5 |
_inherit = 'account.journal' |
| 6 |
|
| 7 |
l10n_dk_nemhandel_proxy_state = fields.Selection(related='company_id.l10n_dk_nemhandel_proxy_state') |
| 8 |
is_nemhandel_journal = fields.Boolean(string='Journal used for Nemhandel') |
| 9 |
|
| 10 |
@api.depends('l10n_dk_nemhandel_proxy_state') |
| 11 |
def _compute_show_refresh_out_einvoices_status_button(self): |
| 12 |
# EXTENDS 'account' |
| 13 |
super()._compute_show_refresh_out_einvoices_status_button() |
| 14 |
self.filtered(lambda j: j.l10n_dk_nemhandel_proxy_state == 'receiver' and j.type == 'sale').show_refresh_out_einvoices_status_button = True |
| 15 |
|
| 16 |
@api.depends('is_nemhandel_journal', 'l10n_dk_nemhandel_proxy_state') |
| 17 |
def _compute_show_fetch_in_einvoices_button(self): |
| 18 |
# EXTENDS 'account' |
| 19 |
super()._compute_show_fetch_in_einvoices_button() |
| 20 |
|
| 21 |
self.filtered(lambda j: j.is_nemhandel_journal and j.l10n_dk_nemhandel_proxy_state == 'receiver' and j.type == 'purchase').show_fetch_in_einvoices_button = True |
| 22 |
|
| 23 |
def button_fetch_in_einvoices(self): |
| 24 |
# EXTENDS 'account' |
| 25 |
super().button_fetch_in_einvoices() |
| 26 |
edi_users = self.env['account_edi_proxy_client.user'].search([ |
| 27 |
('company_id.l10n_dk_nemhandel_proxy_state', '=', 'receiver'), |
| 28 |
('company_id', 'in', self.company_id.ids), |
| 29 |
('proxy_type', '=', 'nemhandel'), |
| 30 |
]) |
| 31 |
edi_users._nemhandel_get_new_documents() |
| 32 |
|
| 33 |
def button_refresh_out_einvoices_status(self): |
| 34 |
# EXTENDS 'account' |
| 35 |
super().button_refresh_out_einvoices_status() |
| 36 |
edi_users = self.env['account_edi_proxy_client.user'].search([ |
| 37 |
('company_id.l10n_dk_nemhandel_proxy_state', '=', 'receiver'), |
| 38 |
('company_id', 'in', self.company_id.ids), |
| 39 |
('proxy_type', '=', 'nemhandel'), |
| 40 |
]) |
| 41 |
edi_users._nemhandel_get_message_status() |