Skip to content

Commit

Permalink
[FIX] account_vat_period_end_statement: get migration script multi co…
Browse files Browse the repository at this point in the history
…mpany compliant (OCA#428)

[FIX] account_vat_period_end_statement: check move_id exists to get statement_draft properly working (OCA#435)

move_id needs to be checked if exists in the computed fields, otherwise the method unlink, during the fields recomputation, raises a MissingError for them

[FIX] account_vat_period_end_statement: post move + cancel move (OCA#436)

[IMP] account_vat_period_end_statement: allow to adviser to manage date.range and date.range.type
Otherwise a user who belongs to adviser group cannot add a date.range to vat statement

[FIX] Move menu related to date range to l10n_it_account module
  • Loading branch information
tafaRU authored and michelerusti committed Nov 11, 2022
1 parent 10768dd commit a8a00c8
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 57 deletions.
2 changes: 1 addition & 1 deletion account_vat_period_end_statement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

{
"name": "Period End VAT Statement",
"version": "10.0.1.2.0",
"version": "10.0.1.4.2",
'category': 'Generic Modules/Accounting',
'license': 'AGPL-3',
"depends": [
Expand Down
26 changes: 13 additions & 13 deletions account_vat_period_end_statement/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-12-08 03:45+0000\n"
"PO-Revision-Date: 2017-12-08 03:45+0000\n"
"POT-Creation-Date: 2018-01-16 06:17+0000\n"
"PO-Revision-Date: 2018-01-16 06:17+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -169,7 +169,7 @@ msgid "Credit Account Lines"
msgstr "Righe conti di credito"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:347
#: code:addons/account_vat_period_end_statement/models/account.py:352
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_credit_vat_account_line_ids
#, python-format
msgid "Credit VAT"
Expand Down Expand Up @@ -198,7 +198,7 @@ msgid "Debit Account Lines"
msgstr "Righe conti di debito"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:328
#: code:addons/account_vat_period_end_statement/models/account.py:333
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_debit_vat_account_line_ids
#, python-format
msgid "Debit VAT"
Expand Down Expand Up @@ -242,7 +242,7 @@ msgid "Draft"
msgstr "Bozza"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:423
#: code:addons/account_vat_period_end_statement/models/account.py:428
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_interests_debit_vat_account_id
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.report_vatperiodendstatement_document
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.view_account_vat_period_end_statement
Expand Down Expand Up @@ -343,7 +343,7 @@ msgid "Last printed page"
msgstr "Ultima pagina stampata"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:442
#: code:addons/account_vat_period_end_statement/models/account.py:447
#, python-format
msgid "Other VAT Credits / Debits"
msgstr "Altri Crediti / Debiti per IVA"
Expand Down Expand Up @@ -407,7 +407,7 @@ msgid "Periods"
msgstr "Periodi"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:366
#: code:addons/account_vat_period_end_statement/models/account.py:371
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_previous_credit_vat_account_id
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.view_account_vat_period_end_statement
#, python-format
Expand All @@ -420,7 +420,7 @@ msgid "Previous Credits VAT Amount"
msgstr "Importo IVA crediti precedenti"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:404
#: code:addons/account_vat_period_end_statement/models/account.py:409
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_previous_debit_vat_account_id
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.view_account_vat_period_end_statement
#, python-format
Expand Down Expand Up @@ -521,7 +521,7 @@ msgid "Tax Authority Partner"
msgstr "Partner Erario"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:458
#: code:addons/account_vat_period_end_statement/models/account.py:463
#, python-format
msgid "Tax Authority VAT"
msgstr "IVA Erario"
Expand All @@ -532,7 +532,7 @@ msgid "Tax Authority VAT Account"
msgstr "Conto IVA Erario"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:385
#: code:addons/account_vat_period_end_statement/models/account.py:390
#, python-format
msgid "Tax Credits"
msgstr "Crediti d'imposta"
Expand All @@ -550,7 +550,7 @@ msgid "Tax credits Amount"
msgstr "Importo crediti d'imposta"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:623
#: code:addons/account_vat_period_end_statement/models/account.py:629
#, python-format
msgid "The account for vat interest must be configurated"
msgstr "Il conto per gli interessi IVA deve essere configurato"
Expand Down Expand Up @@ -595,7 +595,7 @@ msgid "Undeductible"
msgstr "Non detraibile"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:316
#: code:addons/account_vat_period_end_statement/models/account.py:321
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_date_range_vat_statement_id
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_statement_credit_account_line_statement_id
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_statement_debit_account_line_statement_id
Expand Down Expand Up @@ -628,7 +628,7 @@ msgid "Vat statement"
msgstr "Liquidazione IVA"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:274
#: code:addons/account_vat_period_end_statement/models/account.py:278
#, python-format
msgid "You cannot delete a confirmed or paid statement"
msgstr "Non è possibile eliminare una liquidazione confermata o pagata"
Expand Down
26 changes: 13 additions & 13 deletions account_vat_period_end_statement/i18n/sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-12-08 03:45+0000\n"
"PO-Revision-Date: 2017-12-08 03:45+0000\n"
"POT-Creation-Date: 2018-01-16 06:17+0000\n"
"PO-Revision-Date: 2018-01-16 06:17+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -169,7 +169,7 @@ msgid "Credit Account Lines"
msgstr "Postavke konta terjatev"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:347
#: code:addons/account_vat_period_end_statement/models/account.py:352
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_credit_vat_account_line_ids
#, python-format
msgid "Credit VAT"
Expand Down Expand Up @@ -198,7 +198,7 @@ msgid "Debit Account Lines"
msgstr "Postavke konta obveznosti"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:328
#: code:addons/account_vat_period_end_statement/models/account.py:333
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_debit_vat_account_line_ids
#, python-format
msgid "Debit VAT"
Expand Down Expand Up @@ -242,7 +242,7 @@ msgid "Draft"
msgstr "Osnutek"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:423
#: code:addons/account_vat_period_end_statement/models/account.py:428
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_interests_debit_vat_account_id
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.report_vatperiodendstatement_document
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.view_account_vat_period_end_statement
Expand Down Expand Up @@ -343,7 +343,7 @@ msgid "Last printed page"
msgstr "Zadnja natisnjena stran"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:442
#: code:addons/account_vat_period_end_statement/models/account.py:447
#, python-format
msgid "Other VAT Credits / Debits"
msgstr "Druge DDV terjatve / obveznosti"
Expand Down Expand Up @@ -407,7 +407,7 @@ msgid "Periods"
msgstr "Obdobja"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:366
#: code:addons/account_vat_period_end_statement/models/account.py:371
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_previous_credit_vat_account_id
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.view_account_vat_period_end_statement
#, python-format
Expand All @@ -420,7 +420,7 @@ msgid "Previous Credits VAT Amount"
msgstr "Znesek prejšnjih DDV v dobro"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:404
#: code:addons/account_vat_period_end_statement/models/account.py:409
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_account_vat_period_end_statement_previous_debit_vat_account_id
#: model:ir.ui.view,arch_db:account_vat_period_end_statement.view_account_vat_period_end_statement
#, python-format
Expand Down Expand Up @@ -521,7 +521,7 @@ msgid "Tax Authority Partner"
msgstr "Partner davčni organ"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:458
#: code:addons/account_vat_period_end_statement/models/account.py:463
#, python-format
msgid "Tax Authority VAT"
msgstr "DDV davčnega organa"
Expand All @@ -532,7 +532,7 @@ msgid "Tax Authority VAT Account"
msgstr "Konto DDV davčnega organa"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:385
#: code:addons/account_vat_period_end_statement/models/account.py:390
#, python-format
msgid "Tax Credits"
msgstr ""
Expand All @@ -550,7 +550,7 @@ msgid "Tax credits Amount"
msgstr ""

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:623
#: code:addons/account_vat_period_end_statement/models/account.py:629
#, python-format
msgid "The account for vat interest must be configurated"
msgstr "Nastaviti morate konto za DDV obresti"
Expand Down Expand Up @@ -593,7 +593,7 @@ msgid "Undeductible"
msgstr "Neodbitni"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:316
#: code:addons/account_vat_period_end_statement/models/account.py:321
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_date_range_vat_statement_id
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_statement_credit_account_line_statement_id
#: model:ir.model.fields,field_description:account_vat_period_end_statement.field_statement_debit_account_line_statement_id
Expand Down Expand Up @@ -626,7 +626,7 @@ msgid "Vat statement"
msgstr "DDV izjava"

#. module: account_vat_period_end_statement
#: code:addons/account_vat_period_end_statement/models/account.py:274
#: code:addons/account_vat_period_end_statement/models/account.py:278
#, python-format
msgid "You cannot delete a confirmed or paid statement"
msgstr "Potrjenih ali plačanih izjav ne morete brisati"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,29 @@ def migrate(cr, version):
"""SELECT vat_statement_id, company_id, name, date_start, date_stop
from account_period """)
date_range_model = env['date.range']
date_range_type = env['date.range.type']
date_range_type_model = env['date.range.type']
periods = env.cr.fetchall()
for period in periods:
# if period has vat statement
if period[0]:
date_range_type = date_range_type_model.search(
[('name', '=', 'periodo fiscale'),
('company_id', '=', period[1])
])
if not date_range_type:
date_range_type = date_range_type_model.create(
{'name': 'periodo fiscale',
'company_id': period[1]})
date_range = date_range_model.search(
[('date_start', '=', period[3]),
('date_end', '=', period[4])
('date_end', '=', period[4]),
('company_id', '=', period[1])
])
if date_range:
date_range.write({'vat_statement_id': period[0]})
date_range.write(
{'vat_statement_id': period[0],
'type_id': date_range_type.id})
else:
if not date_range_type:
date_range_type = env['date.range.type'].create(
{'name': 'periodo fiscale'})
date_range_type.company_id = period[1]
date_range_vals = {
'vat_statement_id': period[0],
'company_id': period[1],
Expand Down
34 changes: 20 additions & 14 deletions account_vat_period_end_statement/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ def _compute_residual(self):
precision = self.env.user.company_id.currency_id.decimal_places
for statement in self:
residual = 0.0
if not statement.move_id:
statement.residual = 0.0
statement.reconciled = False
return
for line in statement.move_id.line_ids:
if line.account_id.id == statement.authority_vat_account_id.id:
residual += line.amount_residual
if statement.move_id.exists():
if not statement.move_id:
statement.residual = 0.0
statement.reconciled = False
return
for line in statement.move_id.line_ids:
authority_vat_account_id = (
statement.authority_vat_account_id.id)
if line.account_id.id == authority_vat_account_id:
residual += line.amount_residual
statement.residual = abs(residual)
if float_is_zero(statement.residual, precision_digits=precision):
statement.reconciled = True
Expand All @@ -88,13 +91,14 @@ def _compute_residual(self):
def _compute_lines(self):
for statement in self:
payment_lines = []
for line in statement.move_id.line_ids:
payment_lines.extend(filter(None, [
rp.credit_move_id.id for rp in line.matched_credit_ids
]))
payment_lines.extend(filter(None, [
rp.debit_move_id.id for rp in line.matched_debit_ids
]))
if statement.move_id.exists():
for line in statement.move_id.line_ids:
payment_lines.extend(filter(None, [
rp.credit_move_id.id for rp in line.matched_credit_ids
]))
payment_lines.extend(filter(None, [
rp.debit_move_id.id for rp in line.matched_debit_ids
]))
statement.payment_ids = self.env['account.move.line'].browse(
list(set(payment_lines)))

Expand Down Expand Up @@ -295,6 +299,7 @@ def _write(self, vals):
def statement_draft(self):
for statement in self:
if statement.move_id:
statement.move_id.button_cancel()
statement.move_id.unlink()
statement.state = 'draft'

Expand Down Expand Up @@ -484,6 +489,7 @@ def create_move(self):
lines_to_create.append((0, 0, end_debit_vat_data))

move.line_ids = lines_to_create
move.post()
statement.state = 'confirmed'

return True
Expand Down
20 changes: 11 additions & 9 deletions account_vat_period_end_statement/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_account_vat_period_end_statement_accountant","access_account_vat_period_end_statement_accountant","model_account_vat_period_end_statement","account.group_account_user","1","1","1","1"
"access_account_vat_period_end_statement_manager","access_account_vat_period_end_statement_manager","model_account_vat_period_end_statement","account.group_account_manager","1","1","1","1"
"access_statement_debit_account_line_accountant","access_statement_debit_account_line_accountant","model_statement_debit_account_line","account.group_account_user","1","1","1","1"
"access_statement_debit_account_line_manager","access_statement_debit_account_line_manager","model_statement_debit_account_line","account.group_account_manager","1","1","1","1"
"access_statement_credit_account_line_accountant","access_statement_credit_account_line_accountant","model_statement_credit_account_line","account.group_account_user","1","1","1","1"
"access_statement_credit_account_line_manager","access_statement_credit_account_line_manager","model_statement_credit_account_line","account.group_account_manager","1","1","1","1"
"access_statement_generic_account_line_accountant","access_statement_generic_account_line_accountant","model_statement_generic_account_line","account.group_account_user","1","1","1","1"
"access_statement_generic_account_line_manager","access_statement_generic_account_line_manager","model_statement_generic_account_line","account.group_account_manager","1","1","1","1"
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_vat_period_end_statement_accountant,access_account_vat_period_end_statement_accountant,model_account_vat_period_end_statement,account.group_account_user,1,1,1,1
access_account_vat_period_end_statement_manager,access_account_vat_period_end_statement_manager,model_account_vat_period_end_statement,account.group_account_manager,1,1,1,1
access_statement_debit_account_line_accountant,access_statement_debit_account_line_accountant,model_statement_debit_account_line,account.group_account_user,1,1,1,1
access_statement_debit_account_line_manager,access_statement_debit_account_line_manager,model_statement_debit_account_line,account.group_account_manager,1,1,1,1
access_statement_credit_account_line_accountant,access_statement_credit_account_line_accountant,model_statement_credit_account_line,account.group_account_user,1,1,1,1
access_statement_credit_account_line_manager,access_statement_credit_account_line_manager,model_statement_credit_account_line,account.group_account_manager,1,1,1,1
access_statement_generic_account_line_accountant,access_statement_generic_account_line_accountant,model_statement_generic_account_line,account.group_account_user,1,1,1,1
access_statement_generic_account_line_manager,access_statement_generic_account_line_manager,model_statement_generic_account_line,account.group_account_manager,1,1,1,1
access_statement_date_range_manager,access_statement_date_range_manager,date_range.model_date_range,account.group_account_manager,1,1,1,1
access_statement_date_range_type_manager,access_statement_date_range_type_manager,date_range.model_date_range_type,account.group_account_manager,1,1,1,1

0 comments on commit a8a00c8

Please sign in to comment.