Skip to content

Commit

Permalink
Merge df1e3c6 into 42bd636
Browse files Browse the repository at this point in the history
  • Loading branch information
igallart committed May 28, 2019
2 parents 42bd636 + df1e3c6 commit d0c740b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion l10n_es_aeat/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
'name': "AEAT Base",
'summary': "Modulo base para declaraciones de la AEAT",
'version': "12.0.1.0.0",
'version': "12.0.1.0.1",
'author': "Pexego,"
"Acysos,"
"AvanzOSC,"
Expand Down
27 changes: 27 additions & 0 deletions l10n_es_aeat/models/l10n_es_aeat_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,33 @@ def _get_previous_fiscalyear_reports(self, date):
previous reports.
"""
self.ensure_one()
if self.period_type in ("1T", "2T", "3T", "4T"):
periods = ("1T", "2T", "3T", "4T")
else:
periods = (
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
"11", "12",)
search_periods = self.search([
("year", "=", self.year),
("period_type", "in", periods),
("state", "not in", ("draft", "cancelled")),
("type", "=", "N"),
], order="period_type")
search_periods |= self
search_periods = search_periods.sorted(key=lambda r: r.period_type)
if search_periods and len(search_periods) != len(
set(search_periods.mapped("period_type"))):
# Periodos repetidos
raise exceptions.UserError(
_("Already exist a report with same date period"))
elif len(search_periods) > 1:
# Periodos anteriores que deberían estar
pos = periods.index(self.period_type)
period_filter = periods[:pos]
if not set(period_filter).issubset(
search_periods.mapped("period_type")):
raise exceptions.UserError(
_("There are missing reports from earlier periods"))
return self.search([
('year', '=', self.year),
('date_start', '<', date),
Expand Down
1 change: 1 addition & 0 deletions l10n_es_aeat/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
* Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Juan Vicente Pascual <jvpascual@puntsistemes.es>
* Abraham Anes <abraham@studio73.es>
* Isaac Gallart <igallart@puntsistemes.es>

0 comments on commit d0c740b

Please sign in to comment.