-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.0.5.1.2][l10n_id_taxform_bukti_potong_pph_common]
- Loading branch information
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
l10n_id_taxform_bukti_potong_pph_common/models/account_move_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, api, _ | ||
from openerp.exceptions import Warning as UserError | ||
|
||
|
||
class AccountMoveLine(models.Model): | ||
_inherit = 'account.move.line' | ||
|
||
@api.multi | ||
def _check_taxform(self): | ||
self.ensure_one() | ||
self._cr.execute( | ||
"""SELECT 1 FROM rel_bukpot_line_2_income_move | ||
WHERE account_move_id=%s | ||
""", | ||
(self.id,)) | ||
if self._cr.fetchone(): | ||
return True | ||
else: | ||
return False | ||
|
||
@api.multi | ||
def unlink(self): | ||
for move_line in self: | ||
taxform = self._check_taxform() | ||
if taxform: | ||
raise UserError( | ||
_("Warning!"), | ||
_("You cannot delete journal item linked to taxform!") | ||
) | ||
return super(AccountMoveLine, self).unlink() |