Skip to content

Commit

Permalink
[FIX] Tests fiscal_payment
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Felipe Mileo <mileo@kmee.com.br>

Signed-off-by: Luis Felipe Mileo <mileo@kmee.com.br>

Signed-off-by: Luis Felipe Mileo <mileo@kmee.com.br>
  • Loading branch information
mileo committed May 5, 2020
1 parent e16319e commit 4250b45
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
4 changes: 3 additions & 1 deletion l10n_br_fiscal/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def _onchange_payment_term_id(self):
communication = 1
for date_maturity, amount in payment_term_list:
line_ids.append((
0, False, self._prepare_line_id(communication, date_maturity, amount)
0,
False,
self._prepare_line_id(communication, date_maturity, amount)
))
communication += 1

Expand Down
3 changes: 1 addition & 2 deletions l10n_br_fiscal/models/payment_line.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Copyright 2020 KMEE
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models, _
from odoo import fields, models


class FiscalPaymentLine(models.Model):

_name = 'l10n_br_fiscal.payment.line'
_description = 'Fiscal Payment Line'

Expand Down
18 changes: 5 additions & 13 deletions l10n_br_fiscal/models/payment_term.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@

from odoo import api, fields, models, _
from dateutil.relativedelta import relativedelta

from ..constants.payment import (
BANDEIRA_CARTAO,
FORMA_PAGAMENTO,
INTEGRACAO_CARTAO,
INTEGRACAO_CARTAO_NAO_INTEGRADO,
FORMA_PAGAMENTO_OUTROS,
)
from odoo.exceptions import UserError, ValidationError


class FiscalPaymentTerm(models.Model):
Expand Down Expand Up @@ -85,9 +78,8 @@ def compute(self, value, date_ref=False):
if line.option == 'day_after_invoice_date':
next_date += relativedelta(days=line.days)
if line.day_of_the_month > 0:
months_delta = (
line.day_of_the_month < next_date.day
) and 1 or 0
months_delta = \
(line.day_of_the_month < next_date.day) and 1 or 0
next_date += relativedelta(
day=line.day_of_the_month, months=months_delta)
elif line.option == 'after_invoice_month':
Expand All @@ -110,12 +102,12 @@ def compute(self, value, date_ref=False):
@api.multi
def unlink(self):
if self.env['l10n_br_fiscal.document'].search(
[('payment_term_id', 'in', self.ids)]):
[('payment_term_id', 'in', self.ids)]):
raise UserError(_(
'You can not delete payment terms as other '
'records still reference it. However, you can archive it.'))
if self.env['l10n_br_fiscal.payment.line'].search(
[('payment_term_id', 'in', self.ids)]):
[('payment_term_id', 'in', self.ids)]):
raise UserError(_(
'You can not delete payment terms as other'
' records still reference it. However, you can archive it.'))
Expand Down
5 changes: 3 additions & 2 deletions l10n_br_fiscal/models/payment_term_abstract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2020 KMEE
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models, _
from odoo import fields, models

from ..constants.payment import (
BANDEIRA_CARTAO,
Expand All @@ -12,8 +12,9 @@
)


class FiscalPaymentTermAbstract(models.Model):
class FiscalPaymentTermAbstract(models.AbstractModel):
_name = 'l10n_br_fiscal.payment.term.abstract'
_description = 'Campos dos Pagamentos Brasileiros'

forma_pagamento = fields.Selection(
selection=FORMA_PAGAMENTO,
Expand Down
6 changes: 4 additions & 2 deletions l10n_br_fiscal/models/payment_term_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models, _
from odoo.exceptions import ValidationError


class AccountPaymentTermLine(models.Model):
Expand Down Expand Up @@ -49,14 +50,15 @@ class AccountPaymentTermLine(models.Model):
@api.constrains('value', 'value_amount')
def _check_percent(self):
if self.value == 'percent' and (
self.value_amount < 0.0 or self.value_amount > 100.0):
self.value_amount < 0.0 or self.value_amount > 100.0):
raise ValidationError(
_('Percentages on the Payment Terms lines must be between 0 and 100.'))

@api.one
@api.constrains('days')
def _check_days(self):
if self.option in ('day_following_month', 'day_current_month') and self.days <= 0:
if self.option in (
'day_following_month', 'day_current_month') and self.days <= 0:
raise ValidationError(
_("The day of the month used for this term must be stricly positive."))
elif self.days < 0:
Expand Down
2 changes: 0 additions & 2 deletions l10n_br_fiscal/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
"l10n_br_fiscal_document_related_manager","Fiscal Document Related for Manager","model_l10n_br_fiscal_document_related","l10n_br_fiscal.group_manager",1,1,1,1
"l10n_br_fiscal_document_line_user","Fiscal Document Line for User","model_l10n_br_fiscal_document_line","l10n_br_fiscal.group_user",1,0,0,0
"l10n_br_fiscal_document_line_manager","Fiscal Document Line for Manager","model_l10n_br_fiscal_document_line","l10n_br_fiscal.group_manager",1,1,1,1
"l10n_br_fiscal_payment_user","Fiscal payment for User","model_l10n_br_fiscal_payment","l10n_br_fiscal.group_user",1,0,0,0
"l10n_br_fiscal_payment_manager","Fiscal Document for Manager","model_l10n_br_fiscal_payment","l10n_br_fiscal.group_manager",1,1,1,1
"l10n_br_fiscal_comment_user","Comment for User","model_l10n_br_fiscal_comment","l10n_br_fiscal.group_user",1,0,0,0
"l10n_br_fiscal_comment_manager","Comment for Manager","model_l10n_br_fiscal_comment","l10n_br_fiscal.group_manager",1,1,1,1
"l10n_br_fiscal_tax_definition_user","Tax Definition for User","model_l10n_br_fiscal_tax_definition","l10n_br_fiscal.group_user",1,0,0,0
Expand Down

0 comments on commit 4250b45

Please sign in to comment.