Skip to content

Commit

Permalink
[FIX] fix use account.move.line rather than account.move
Browse files Browse the repository at this point in the history
  • Loading branch information
Unoqualsiasi committed Jan 22, 2024
1 parent 9c39929 commit 372ec91
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 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.4",
"category": "Account",
"summary": "Riclassificazione merci e servizi per dichiarazioni Intrastat",
"author": "Openforce, Link IT srl, Agile Business Group, "
Expand Down
46 changes: 27 additions & 19 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

domain = [
("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 = [
("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)
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 = [
("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 = [
("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)

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)
for line in invoice_lines:
total += line.price_subtotal
return total

@api.model
Expand Down

0 comments on commit 372ec91

Please sign in to comment.