Skip to content

Commit

Permalink
últimos cambios
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohmontenegro committed Jan 29, 2024
1 parent ba8d72e commit 1154742
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 158 deletions.
1 change: 1 addition & 0 deletions account_tax_settlement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'account_reports',
# dependencia porque llevamos a pagos y tmb porque usamos el boton
# en apuntes contables para abrir documento relacionado
'account_payment_pro'
],
'data': [
'wizards/account_tax_settlement_wizard_view.xml',
Expand Down
12 changes: 0 additions & 12 deletions account_tax_settlement/migrations/15.0.1.3.0/post-migration.py

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion account_tax_settlement/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from . import account_move
from . import account_journal_dashboard
from . import account_report
from . import account_payment
from . import account_generic_tax_report
from . import res_partner
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GenericTaxReportCustomHandler(models.AbstractModel):
_inherit = 'account.generic.tax.report.handler'

def _custom_options_initializer(self, report, options, previous_options=None):
""" Se borra boton tax closing ('Cierre de impuestos') en tax report ('Reporte de impuestos'). """
super()._custom_options_initializer(report, options, previous_options=previous_options)
for x in (options['buttons']):
if x.get('action') == 'action_periodic_vat_entries':
Expand Down
1 change: 1 addition & 0 deletions account_tax_settlement/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def action_create_payment(self):
'context': {
'default_partner_id': partner.id,
'default_partner_type': 'supplier',
'default_payment_type': 'outbound'
},
}

Expand Down
3 changes: 3 additions & 0 deletions account_tax_settlement/models/account_journal_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def _get_journal_dashboard_data_batched(self):
return res

def _fill_tax_settlement_dashboard_data(self, dashboard_data):
""" En diarios de liquidación en vista kanban agregamos al lado del botoncitos 'Líneas a liquidar' la cantidad de líneas de liquidar y el importe y al lado del botoncito 'Saldo a pagar' agregamos el importe """
tax_settlement_journals = self.filtered(lambda journal: journal.tax_settlement != False)
if not tax_settlement_journals:
return
Expand All @@ -33,10 +34,12 @@ def open_action(self):
tax_settlement = self._context.get('tax_settlement', False)
debt_balance = self._context.get('debt_balance', False)
if tax_settlement:
# Ingresa aquí al entrar en vista Kanban en diario de liquidacion en el botoncito "Líneas a liquidar"
action = self.env["ir.actions.actions"]._for_xml_id('account_tax_settlement.action_account_tax_move_line')
action['domain'] = self._get_tax_settlement_lines_domain_by_tags()
return action
elif debt_balance and self.settlement_partner_id:
# Ingresa aquí al entrar en vista Kanban en diario de liquidacion en el botoncito 'Saldo a pagar'
action = self.settlement_partner_id.open_partner_ledger()
ctx = safe_eval(action.get('context'))
ctx.update({
Expand Down
3 changes: 2 additions & 1 deletion account_tax_settlement/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def action_pay_tax_settlement(self):
'type': 'ir.actions.act_window',
'context': {
'default_partner_type': 'supplier',
'default_partner_id': open_move_line_ids.mapped('partner_id').id,
'default_to_pay_move_line_ids': open_move_line_ids.ids,
'default_payment_type': 'outbound',
# We set this because if became from other view and in the context has 'create=False'
# you can't crate payment lines (for ej: subscription)
'create': True,
Expand All @@ -121,6 +121,7 @@ def action_pay_tax_settlement(self):
# por defecto, en pago de retenciones, no hacemos double
# validation
'force_simple': True,
'default_partner_id': open_move_line_ids.mapped('partner_id').id,
},
}

Expand Down
20 changes: 0 additions & 20 deletions account_tax_settlement/models/account_payment.py

This file was deleted.

2 changes: 1 addition & 1 deletion account_tax_settlement/models/account_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AccountReport(models.AbstractModel):
_inherit = 'account.report'

allow_settlement = fields.Boolean(
help='This optin will enable a new button on this report to settle all the lines that are of engine "domain".')
help='This option will enable a new button on this report to settle all the lines that are of engine "domain".')
settlement_title = fields.Char(translate=True)
settlement_allow_unbalanced = fields.Boolean(
help='If you enble this option, then an account will be required when creating the settlement entry and '
Expand Down
16 changes: 16 additions & 0 deletions account_tax_settlement/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import models


class ResPartner(models.Model):
_name = 'res.partner'
_inherit = 'res.partner'


def open_partner_ledger(self):
""" Heredamos y modificamos el método original que está en account reports y lo dejamos como estaba en 16 para que al momento de hacer click en 'Saldo a pagar' en algún diario de liquidación de impuestos entonces se abra el libro mayor de empresas para el partner de liquidación, caso contrario, se van a visualizar los asientos contables de las liquidaciones de impuestos de ese diario propiamente dicho. Este método se llama en ../account_journal_dashboard.py en el método open_action. """
action = self.env["ir.actions.actions"]._for_xml_id("account_reports.action_account_report_partner_ledger")
action['params'] = {
'options': {'partner_ids': [self.id]},
'ignore_session': 'both',
}
return action
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class AccountTaxSettlementWizard(models.TransientModel):
settlement_journal_id = fields.Many2one(
'account.journal',
string='Journal',
check_company=True,
domain=[('type', '=', 'general')]
)
report_id = fields.Many2one(
'account.report',
Expand All @@ -39,6 +41,8 @@ class AccountTaxSettlementWizard(models.TransientModel):
)
account_id = fields.Many2one(
'account.account',
check_company=True,
domain=[('deprecated', '=', False)]
)
report_settlement_allow_unbalanced = fields.Boolean(
related='report_id.settlement_allow_unbalanced',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</p>
<group>
<field name="date"/>
<field name="settlement_journal_id" invisible="not report_id" required="report_id" domain="[('company_id', '=', company_id), ('type', '=', 'general')]"/>
<field name="account_id" invisible="not report_settlement_allow_unbalanced" required="report_settlement_allow_unbalanced" domain="[('company_id', '=', company_id), ('deprecated', '=', False)]"/>
<field name="settlement_journal_id" invisible="not report_id" required="report_id"/>
<field name="account_id" invisible="not report_settlement_allow_unbalanced" required="report_settlement_allow_unbalanced"/>
</group>
<footer>
<button name="confirm" string="Confirm" type="object" class="oe_highlight"/>
Expand Down
1 change: 0 additions & 1 deletion account_tax_settlement/wizards/download_files_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class DownloadFilesWizard(models.TransientModel):
@api.model
def action_get_files(self, files_values):
# transformamos a binary y agregamos formato para campos o2m

wizard = self.env['download_files_wizard'].create({
'line_ids': [(0, False, {
'txt_filename': x['txt_filename'],
Expand Down
159 changes: 69 additions & 90 deletions l10n_ar_account_tax_settlement/models/account_chart_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,80 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api
from odoo import models, api, Command
import logging
_logger = logging.getLogger(__name__)
from odoo.addons.account.models.chart_template import template


class AccountChartTemplate(models.Model):
class AccountChartTemplate(models.AbstractModel):
_inherit = 'account.chart.template'

def _create_bank_journals(self, company, acc_template_ref):
res = super(
AccountChartTemplate, self)._create_bank_journals(
company, acc_template_ref)
if company.country_id != self.env.ref('base.ar'):
return res

ref = self.env.ref

def get_account(ext_id):
"""
Helper para obtener referencia a alguna cuenta
"""
return acc_template_ref.get(ref('l10n_ar.%s' % ext_id))

# add more journals commonly used in argentina localization
journals_data = [
('Liquidación de IIBB', 'IIBB', 'allow_per_line', 'iibb_sufrido',
ref('l10n_ar.par_iibb_pagar'),
get_account('base_iibb_a_pagar'),
ref('l10n_ar_ux.tax_tag_a_cuenta_iibb'))
]
@api.model
def _get_country_code(self):
""" Return the list of country codes for the countries where third party checks journals should be created
when installing the COA"""
return ["AR"]

chart = company.chart_template_id
ri_chart = ref('l10n_ar.l10nar_ri_chart_template', False)
ex_chart = ref('l10n_ar.l10nar_ex_chart_template', False)
@template(model='account.journal')
def _get_latam_check_account_journal(self, template_code):
""" Creamos diarios de tipo 'varios' para liquidación de impuestos cuando se instala el plan de cuentas de la compañía. Los diarios a crear dependen de la condición fiscal de la compañía """
company = self.env.company
if company.country_id.code in self._get_country_code():
journals_data = [
('Liquidación de IIBB', 'IIBB', 'allow_per_line', 'iibb_sufrido',
self.env.ref('l10n_ar.par_iibb_pagar'),
'base_iibb_a_pagar',
self.env.ref('l10n_ar_ux.tax_tag_a_cuenta_iibb'))
]
if template_code == 'ar_ri':
journals_data += [
('Liquidación de IVA', 'IVA', 'yes', False,
self.env.ref('l10n_ar.partner_afip'),
'ri_iva_saldo_a_pagar',
self.env.ref('l10n_ar_ux.tax_tag_a_cuenta_iva'))]

# iva solo para RI
if chart == ri_chart:
journals_data += [
('Liquidación de IVA', 'IVA', 'yes', False,
# ref('l10n_ar_ux_reports.'
# 'account_financial_report_vat_position'),
ref('l10n_ar.partner_afip'),
get_account('ri_iva_saldo_a_pagar'),
ref('l10n_ar_ux.tax_tag_a_cuenta_iva'))]
l10n_ar_withholding_ux = self.env['ir.module.module'].search([
('name', '=', 'l10n_ar_withholding_ux'),
('state', '=', 'installed')])

account_withholding_automatic = self.env['ir.module.module'].search([
('name', '=', 'account_withholding_automatic'),
('state', '=', 'installed')])
# por ahora, por mas que no tenga retenciones automaticas,
# creamos los daiarios de liquidacion ya que es mas facil desactivarlos
# que crearlos luego, y si es un ri lo mas probable es que deba
# tenerlos

# estas para mono no van, para exento y ri si
if chart in (ri_chart, ex_chart):
journals_data += [
('Liquidación de Ganancias', 'GAN', 'yes', False,
# ref('l10n_ar_ux_reports.'
# 'account_financial_report_profits_position'),
ref('l10n_ar.partner_afip'),
get_account('base_impuesto_ganancias_a_pagar'),
ref('l10n_ar_ux.tax_tag_a_cuenta_ganancias')),
# only if account_withholding_automatic installed we
# set sicore_aplicado for txt
('Liquidación SICORE Aplicado', 'SICORE', 'allow_per_line',
account_withholding_automatic and 'sicore_aplicado' or False,
ref('l10n_ar.partner_afip'),
get_account('ri_retencion_sicore_a_pagar'),
ref('l10n_ar_ux.tag_ret_perc_sicore_aplicada')),
('Liquidación IIBB Aplicado', 'IB_AP', 'allow_per_line',
False, # 'iibb_aplicado', (Se debe elegir segun provincia)
ref('l10n_ar.par_iibb_pagar'),
# TODO flatan crear estas cuentas!
get_account('ri_retencion_iibb_a_pagar'),
ref('l10n_ar_ux.tag_ret_perc_iibb_aplicada')),
]

# for name, code, tax, report, partner, credit_id, debit_id, tag \
for name, code, type, tax, partner, account, tag in journals_data:
if not account:
_logger.info("Skip creation of journal %s because we didn't found default account")
continue
# journal_data.append({
self.env['account.journal'].create({
'type': 'general',
'name': name,
'code': code,
'tax_settlement': type,
'settlement_tax': tax,
'settlement_partner_id': partner and partner.id or False,
'settlement_account_id': account.id,
'company_id': company.id,
# al final hicimos otro dashboard
'show_on_dashboard': False,
'settlement_account_tag_ids': tag and [(4, tag.id, False)],
})

return res
if template_code in ('ar_ri', 'ar_ex'):
journals_data += [
('Liquidación de Ganancias', 'GAN', 'yes', False,
# ref('l10n_ar_ux_reports.'
# 'account_financial_report_profits_position'),
self.env.ref('l10n_ar.partner_afip'),
'base_impuesto_ganancias_a_pagar',
self.env.ref('l10n_ar_ux.tax_tag_a_cuenta_ganancias')),
# only if account_withholding_automatic installed we
# set sicore_aplicado for txt
('Liquidación SICORE Aplicado', 'SICORE', 'allow_per_line',
l10n_ar_withholding_ux and 'sicore_aplicado' or False,
self.env.ref('l10n_ar.partner_afip'),
'ri_retencion_sicore_a_pagar',
self.env.ref('l10n_ar_ux.tag_ret_perc_sicore_aplicada')),
('Liquidación IIBB Aplicado', 'IB_AP', 'allow_per_line',
False, # 'iibb_aplicado', (Se debe elegir segun provincia)
self.env.ref('l10n_ar.par_iibb_pagar'),
# TODO flatan crear estas cuentas!
'ri_retencion_iibb_a_pagar',
self.env.ref('l10n_ar_ux.tag_ret_perc_iibb_aplicada')),
]
res = {}
for name, code, type, tax, partner, account, tag in journals_data:
if not account:
_logger.info("Skip creation of journal %s because we didn't found default account")
continue
res[code] = {
'type': 'general',
'name': name,
'code': code,
'tax_settlement': type,
'settlement_tax': tax,
'settlement_partner_id': partner and partner.id or False,
'settlement_account_id': account,
'company_id': company.id,
# al final hicimos otro dashboard
'show_on_dashboard': False,
'settlement_account_tag_ids': tag and [(4, tag.id, False)],
}
return res

0 comments on commit 1154742

Please sign in to comment.