Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_ar_account_withholding: Incorporate the padron detection b…
…y file localy
- Loading branch information
Showing
12 changed files
with
176 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
l10n_ar_account_withholding/models/res_company_jurisdiction_aliquot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from odoo import models, fields, api, _ | ||
from odoo.exceptions import UserError | ||
import zipfile | ||
import os, re | ||
|
||
|
||
class ResCompanyJurisdictionAliquot(models.Model): | ||
_name = "res.company.jurisdiction.aliquot" | ||
_descrption = "res.company.jurisdiction.aliquot" | ||
|
||
company_id = fields.Many2one( | ||
"res.company", | ||
) | ||
jurisdiction_code = fields.Many2many( | ||
"account.account.tag", domain="[('applicability', '=', 'taxes')]" | ||
) | ||
|
||
file_padron = fields.Binary("File") | ||
l10n_ar_padron_from_date = fields.Date("From Date") | ||
l10n_ar_padron_to_date = fields.Date("To Date") | ||
|
||
def descompress_file(self, archivo_zip): | ||
_logger.log(25, "Descompress rar file") | ||
# ruta_zip = "/home/nmr/Descargas/PadronRGS122021.zip" | ||
# archivo_zip = zipfile.ZipFile(rar_file_name, "r") | ||
ruta_extraccion = "/tmp" | ||
try: | ||
archivo_zip.extractall(path=ruta_extraccion) | ||
except: | ||
pass | ||
archivo_zip.close() | ||
|
||
def find_aliquot(self, path, cuit): | ||
with open(path, "r") as fp: | ||
res = False | ||
for line in fp.readlines(): | ||
values = line.split(";") | ||
if values[4] == cuit: | ||
res = values[8] | ||
break | ||
return res | ||
|
||
def find_file(self, rootdir, type_code): | ||
res = False | ||
pattern = "%s.{1}|.TXT\Z" % type_code | ||
for subdir, dirs, files in os.walk(rootdir): | ||
for f in files: | ||
if re.search(pattern, f): | ||
res = f | ||
break | ||
return res | ||
|
||
def _get_alicuot(self, partner): | ||
padron_type = "Per" if self.jurisdiction_code else "Ret" | ||
path_file = self.find_file("/tmp/", padron_type) | ||
if path_file: | ||
self.descompress_file(self.file_padron) | ||
aliquot = self.find_aliquot("tmp/" + path_file, partner.vat) | ||
return aliquot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
l10n_ar_account_withholding/views/res_company_jurisdiction_aliquot_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="view_res_company_jurisdiction_aliquot_form"> | ||
<field name="name">res.company.jurisdiction.aliquot.form.inherit</field> | ||
<field name="model">res.company.jurisdiction.aliquot</field> | ||
<field name="arch" type="xml"> | ||
<!-- <field name="imp_ganancias_padron" position="after"> | ||
<field name="default_regimen_ganancias_id" attrs="{'invisible': [('imp_ganancias_padron', 'in', ['EX', 'NC'])]}"/> | ||
</field> | ||
<group name="others_col_1"> | ||
<field name="drei"/> | ||
</group> | ||
<group name="others" position="after"> | ||
<label for="arba_alicuot_ids"/> | ||
<field name="arba_alicuot_ids"/> | ||
</group> --> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
l10n_ar_account_withholding/wizard/arba_padron_file_wizard_views.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models, fields | ||
|
||
|
||
class PadronFileWizard(models.TransientModel): | ||
_name = "padron.file.wizard" | ||
_description = 'padron.file.wizard' | ||
|
||
l10n_ar_padron_date = fields.Date( | ||
string='Date Padron', | ||
required=True, | ||
) | ||
|
||
file_padron = fields.Binary( | ||
string='File padron', | ||
required=True, | ||
) | ||
|
||
jurisdiction_code = fields.Many2many( | ||
comodel_name="account.account.tag", | ||
domain="[('applicability', '=', 'taxes')]", | ||
required=True, | ||
) | ||
|
||
def upload_file(self): | ||
self.ensure_one() | ||
company = self.env.company | ||
|
||
last_day_of_month = fields.Date.subtract(fields.Date.add( | ||
self.l10n_ar_padron_date.replace(day=1), | ||
months=1), days=1) | ||
|
||
start_day_of_month = self.l10n_ar_padron_date.replace(day=1) | ||
self.env['res.company.jurisdiction.aliquot'].create({ | ||
'l10n_ar_padron_from_date': start_day_of_month, | ||
'l10n_ar_padron_to_date': last_day_of_month, | ||
'file_padron': self.file_padron, | ||
'jurisdiction_code': self.jurisdiction_code, | ||
'company_id': company.id, | ||
}) |
32 changes: 32 additions & 0 deletions
32
l10n_ar_account_withholding/wizard/padron_file_wizard_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="file_wizard_form" model="ir.ui.view"> | ||
<field name="name">padron.file.wizard.form</field> | ||
<field name="model">padron.file.wizard</field> | ||
<field name="arch" type="xml"> | ||
<form string="Padron Wizard"> | ||
<group> | ||
<group> | ||
<field name="l10n_ar_padron_date" /> | ||
</group> | ||
<group> | ||
<field name="jurisdiction_code" widget="many2many_tags"/> | ||
<field name="file_padron"/> | ||
</group> | ||
</group> | ||
<footer> | ||
<button string="Upload" class="btn-primary" type="object" name="upload_file" /> | ||
<button string="Close" class="btn-secondary" special="cancel"/> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="file_wizard_action" model="ir.actions.act_window"> | ||
<field name="name">Padron Files Upload</field> | ||
<field name="res_model">padron.file.wizard</field> | ||
<field name="view_mode">form</field> | ||
<field name="target">new</field> | ||
</record> | ||
<menuitem id="menu_action_file_wizard" name="Partner Aliqut wizard" parent="account.account_invoicing_menu" action="file_wizard_action" sequence="25"/> | ||
</odoo> |