Skip to content

Commit

Permalink
[FIX] mail send error
Browse files Browse the repository at this point in the history
  • Loading branch information
Unoqualsiasi committed Jan 23, 2024
1 parent 9c39929 commit c7ddb8e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion l10n_it_intrastat/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "ITA - Intrastat",
"version": "16.0.1.0.3",
"version": "16.0.1.0.5",
"category": "Account",
"summary": "Riclassificazione merci e servizi per dichiarazioni Intrastat",
"author": "Openforce, Link IT srl, Agile Business Group, "
Expand Down
58 changes: 35 additions & 23 deletions l10n_it_intrastat/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ def _calculate_goods_sale_total(self, company):
fiscal_position_id = company.fiscal_position_goods_sale_id.id

Check warning on line 334 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L334

Added line #L334 was not covered by tests

domain = [

Check warning on line 336 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L336

Added line #L336 was not covered by tests
("move_type", "=", "out_invoice"),
("fiscal_position_id", "=", fiscal_position_id),
("invoice_date", ">=", self._get_quarter_start_date()),
("move_id.move_type", "=", "out_invoice"),
("move_id.fiscal_position_id", "=", fiscal_position_id),
("move_id.invoice_date", ">=", self._get_quarter_start_date()),
(
"invoice_date",
"move_id.invoice_date",
"<=",
self._get_quarter_end_date(self._get_quarter_start_date()),
),
Expand All @@ -350,10 +350,14 @@ def _calculate_goods_sale_total(self, company):
def _calculate_goods_purchase_total(self, company):
fiscal_position_id = company.fiscal_position_goods_purchase_id.id
domain = [

Check warning on line 352 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L351-L352

Added lines #L351 - L352 were not covered by tests
("move_type", "=", "in_invoice"),
("fiscal_position_id", "=", fiscal_position_id),
("date", ">=", self._get_quarter_start_date()),
("date", "<=", self._get_quarter_end_date(self._get_quarter_start_date())),
("move_id.move_type", "=", "in_invoice"),
("move_id.fiscal_position_id", "=", fiscal_position_id),
("move_id.invoice_date", ">=", self._get_quarter_start_date()),
(
"move_id.invoice_date",
"<=",
self._get_quarter_end_date(self._get_quarter_start_date()),
),
("product_id.detailed_type", "in", ["consu", "product"]),
]
return self._compute_total(domain)

Check warning on line 363 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L363

Added line #L363 was not covered by tests
Expand All @@ -362,11 +366,11 @@ def _calculate_goods_purchase_total(self, company):
def _calculate_service_sale_total(self, company):
fiscal_position_id = company.fiscal_position_service_sale_id.id
domain = [

Check warning on line 368 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L367-L368

Added lines #L367 - L368 were not covered by tests
("move_type", "=", "out_invoice"),
("fiscal_position_id", "=", fiscal_position_id),
("invoice_date", ">=", self._get_quarter_start_date()),
("move_id.move_type", "=", "out_invoice"),
("move_id.fiscal_position_id", "=", fiscal_position_id),
("move_id.invoice_date", ">=", self._get_quarter_start_date()),
(
"invoice_date",
"move_id.invoice_date",
"<=",
self._get_quarter_end_date(self._get_quarter_start_date()),
),
Expand All @@ -378,19 +382,23 @@ def _calculate_service_sale_total(self, company):
def _calculate_service_purchase_total(self, company):
fiscal_position_id = company.fiscal_position_service_purchase_id.id
domain = [

Check warning on line 384 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L383-L384

Added lines #L383 - L384 were not covered by tests
("move_type", "=", "in_invoice"),
("fiscal_position_id", "=", fiscal_position_id),
("date", ">=", self._get_quarter_start_date()),
("date", "<=", self._get_quarter_end_date(self._get_quarter_start_date())),
("move_id.move_type", "=", "in_invoice"),
("move_id.fiscal_position_id", "=", fiscal_position_id),
("move_id.invoice_date", ">=", self._get_quarter_start_date()),
(
"move_id.invoice_date",
"<=",
self._get_quarter_end_date(self._get_quarter_start_date()),
),
("product_id.detailed_type", "=", "service"),
]
return self._compute_total(domain)

Check warning on line 395 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L395

Added line #L395 was not covered by tests

def _compute_total(self, domain):
total = 0
invoices = self.env["account.move"].search(domain)
for invoice in invoices:
total += sum(line.price_subtotal for line in invoice.invoice_line_ids)
invoice_lines = self.env["account.move.line"].search(domain)

Check warning on line 399 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L398-L399

Added lines #L398 - L399 were not covered by tests
for line in invoice_lines:
total += line.price_subtotal
return total

Check warning on line 402 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L401-L402

Added lines #L401 - L402 were not covered by tests

@api.model
Expand All @@ -407,31 +415,35 @@ def _check_intrastat_threshold_and_send_email(self, company):
> company.intrastat_goods_sale_threshold
):
self._send_intrastat_email(

Check warning on line 417 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L417

Added line #L417 was not covered by tests
company, "email_template_intrastat_goods_sale_exceeded"
company,
"l10n_it_intrastat.email_template_intrastat_goods_sale_exceeded",
)

if (
self._calculate_goods_purchase_total(company)
> company.intrastat_goods_purchase_threshold
):
self._send_intrastat_email(

Check warning on line 426 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L426

Added line #L426 was not covered by tests
company, "email_template_intrastat_goods_purchase_exceeded"
company,
"l10n_it_intrastat.email_template_intrastat_goods_purchase_exceeded",
)

if (
self._calculate_service_sale_total(company)
> company.intrastat_service_sale_threshold
):
self._send_intrastat_email(

Check warning on line 435 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L435

Added line #L435 was not covered by tests
company, "email_template_intrastat_service_sale_exceeded"
company,
"l10n_it_intrastat.email_template_intrastat_service_sale_exceeded",
)

if (
self._calculate_service_purchase_total(company)
> company.intrastat_service_purchase_threshold
):
self._send_intrastat_email(

Check warning on line 444 in l10n_it_intrastat/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_intrastat/models/account.py#L444

Added line #L444 was not covered by tests
company, "email_template_intrastat_service_purchase_exceeded"
company,
"l10n_it_intrastat.email_template_intrastat_service_purchase_exceeded",
)

def _send_intrastat_email(self, company, template_xml_id):
Expand Down

0 comments on commit c7ddb8e

Please sign in to comment.