Skip to content

Commit

Permalink
[IMP]*: pre-commit automatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jue-adhoc committed Feb 5, 2025
1 parent 7f4a307 commit bed8484
Show file tree
Hide file tree
Showing 80 changed files with 2,809 additions and 2,418 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

exclude: |
(?x)
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|^eslint.config.cjs|^prettier.config.cjs|
# Library files can have extraneous formatting (even minimized)
Expand Down
50 changes: 24 additions & 26 deletions account_accountant_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,30 @@
#
##############################################################################
{
'name': 'Accounting Accountant UX',
'version': "18.0.1.4.0",
'category': 'Accounting',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'images': [
"name": "Accounting Accountant UX",
"version": "18.0.1.4.0",
"category": "Accounting",
"sequence": 14,
"summary": "",
"author": "ADHOC SA",
"website": "www.adhoc.com.ar",
"license": "AGPL-3",
"images": [],
"depends": [
"account_reports",
"account_internal_transfer",
"account_ux",
],
'depends': [
'account_reports',
'account_internal_transfer',
'account_ux',
"data": [
"views/res_partner_view.xml",
"views/account_move_line.xml",
"wizards/account_change_lock_date_views.xml",
"wizards/res_config_settings_views.xml",
"data/account_accountant_data.xml",
"views/account_journal_dashboard_view.xml",
],
'data': [
'views/res_partner_view.xml',
'views/account_move_line.xml',
'wizards/account_change_lock_date_views.xml',
'wizards/res_config_settings_views.xml',
'data/account_accountant_data.xml',
'views/account_journal_dashboard_view.xml',
],
'demo': [
],
'installable': True,
'auto_install': True,
'application': False,
"demo": [],
"installable": True,
"auto_install": True,
"application": False,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
@openupgrade.migrate()
def migrate(env, version):
"""Sets filter by same amount in bank reconciliation in True by default"""
env['ir.config_parameter'].set_param('account_accountant_ux.use_search_filter_amount', 'True')
env["ir.config_parameter"].set_param("account_accountant_ux.use_search_filter_amount", "True")
1 change: 0 additions & 1 deletion account_accountant_ux/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
from . import res_partner
from . import account_journal_dashboard
from . import account_partner_ledger
from . import res_partner
34 changes: 24 additions & 10 deletions account_accountant_ux/models/account_journal_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
from odoo import models, fields
from odoo import fields, models
from odoo.tools.misc import formatLang


class AccountJournal(models.Model):
_inherit = 'account.journal'
_inherit = "account.journal"

def _get_journal_dashboard_data_batched(self):
res = super(AccountJournal, self)._get_journal_dashboard_data_batched()
self._fill_journal_dashboard_general_balance(res)
return res

def _fill_journal_dashboard_general_balance(self, dashboard_data):
journals = self.filtered(lambda journal: journal.type in ['bank', 'cash'])
journals = self.filtered(lambda journal: journal.type in ["bank", "cash"])
for journal in journals:
if journal.default_account_id:
amount_field = 'aml.balance' if (not journal.currency_id or journal.currency_id == journal.company_id.currency_id) else 'aml.amount_currency'
amount_field = (
"aml.balance"
if (not journal.currency_id or journal.currency_id == journal.company_id.currency_id)
else "aml.amount_currency"
)
query = """SELECT sum(%s) FROM account_move_line aml
LEFT JOIN account_move move ON aml.move_id = move.id
WHERE aml.account_id = %%s
AND move.date <= %%s AND move.state = 'posted';""" % (amount_field,)
self.env.cr.execute(query, (journal.default_account_id.id, fields.Date.context_today(self),))
self.env.cr.execute(
query,
(
journal.default_account_id.id,
fields.Date.context_today(self),
),
)
query_results = self.env.cr.dictfetchall()
if query_results and query_results[0].get('sum') is not None:
account_sum = query_results[0].get('sum')
if query_results and query_results[0].get("sum") is not None:
account_sum = query_results[0].get("sum")
currency = journal.currency_id or journal.company_id.currency_id
dashboard_data[journal.id].update({
'account_balance_general': formatLang(self.env, currency.round(account_sum) + 0.0, currency_obj=currency)
})
dashboard_data[journal.id].update(
{
"account_balance_general": formatLang(
self.env, currency.round(account_sum) + 0.0, currency_obj=currency
)
}
)
2 changes: 1 addition & 1 deletion account_accountant_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AccountMove(models.Model):
_inherit = "account.move"

def action_open_business_doc(self):
""" En account_accountant odoo modifica este metodo y si tiene vinculada statement_line line te manda al statement line
"""En account_accountant odoo modifica este metodo y si tiene vinculada statement_line line te manda al statement line
el tema es que para migraciones de 13 podes tener un asiento vinculado a statement_line y payment a la vez.
Como ya existe un boton que permite ir a la statement_line preferimos que el boton que tiene string "pago" te
lleve efectivamente al pago
Expand Down
41 changes: 20 additions & 21 deletions account_accountant_ux/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
from odoo import models, fields
from odoo import fields, models


class AccountMovetLine(models.Model):
_inherit = "account.move.line"

_inherit = 'account.move.line'

filter_amount = fields.Float(compute="_compute_filter_amout", search='_search_filter_amount')
filter_amount = fields.Float(compute="_compute_filter_amout", search="_search_filter_amount")

def _compute_filter_amout(self):
self.filter_amount = False

def _search_filter_amount(self, operator, value):
res = []
if self.env.context.get('default_st_line_id'):
statement_line = self.env['account.bank.statement.line'].browse(self.env.context.get('default_st_line_id'))
if self.env.context.get("default_st_line_id"):
statement_line = self.env["account.bank.statement.line"].browse(self.env.context.get("default_st_line_id"))

primary_currency = statement_line.company_id.currency_id == statement_line.currency_id
if primary_currency:
amount = statement_line['amount']
amount_currency = statement_line['amount_currency']
amount = statement_line["amount"]
amount_currency = statement_line["amount_currency"]
else:
amount = statement_line['amount_currency']
amount_currency = statement_line['amount']

if value != 0 and operator == '=':
base_amount = ((100 - value)/100) * amount
top_amount = ((100 + value)/100) * amount
res.append(('amount_residual', '>', base_amount))
res.append(('amount_residual', '<', top_amount))
amount = statement_line["amount_currency"]
amount_currency = statement_line["amount"]

if value != 0 and operator == "=":
base_amount = ((100 - value) / 100) * amount
top_amount = ((100 + value) / 100) * amount
res.append(("amount_residual", ">", base_amount))
res.append(("amount_residual", "<", top_amount))
else:
amount = ((100 - value)/100) * amount
amount_currency = ((100 - value)/100) * amount_currency
amount = ((100 - value) / 100) * amount
amount_currency = ((100 - value) / 100) * amount_currency

if primary_currency:
res.append(('amount_residual', operator, amount))
res.append(("amount_residual", operator, amount))
else:
res.append(('amount_residual', operator, amount_currency))
res.append(("amount_residual", operator, amount_currency))
return res
8 changes: 4 additions & 4 deletions account_accountant_ux/models/account_partner_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@


class PartnerLedgerCustomHandler(models.AbstractModel):
_inherit = 'account.partner.ledger.report.handler'
_inherit = "account.partner.ledger.report.handler"

def open_journal_items(self, options, params):
# Modificamos las vistas para que use las nuestras de account_ux en vez de las de partner grouped
res = super().open_journal_items(options, params)
res['search_view_id'] = [self.env.ref('account_ux.view_account_partner_ledger_filter').id, 'search']
res['views'] = [(self.env.ref('account.view_move_line_payment_tree').id, 'list')]
res.get('context', {}).update({'search_default_group_by_partner': 1})
res["search_view_id"] = [self.env.ref("account_ux.view_account_partner_ledger_filter").id, "search"]
res["views"] = [(self.env.ref("account.view_move_line_payment_tree").id, "list")]
res.get("context", {}).update({"search_default_group_by_partner": 1})
return res
25 changes: 12 additions & 13 deletions account_accountant_ux/models/bank_rec_widget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from odoo import models, api, Command
from odoo import Command, models

# from odoo.tools.misc import formatLang
from odoo.exceptions import UserError

Expand All @@ -8,13 +9,12 @@ class BankRecWidget(models.Model):

def _prepare_embedded_views_data(self):
data = super()._prepare_embedded_views_data()
data['amls']['context']['default_st_line_id'] = self.st_line_id.id
data["amls"]["context"]["default_st_line_id"] = self.st_line_id.id

if bool(self.env['ir.config_parameter'].sudo().get_param('account_accountant_ux.use_search_filter_amount')):
data['amls']['context']['search_default_same_amount'] = True
if bool(self.env["ir.config_parameter"].sudo().get_param("account_accountant_ux.use_search_filter_amount")):
data["amls"]["context"]["search_default_same_amount"] = True
return data


# def collect_global_info_data(self, journal_id):

# journal = self.env['account.journal'].browse(journal_id)
Expand All @@ -25,33 +25,32 @@ def _prepare_embedded_views_data(self):
# 'balance_amount': balance,
# }


def _lines_recompute_exchange_diff(self,lines):
def _lines_recompute_exchange_diff(self, lines):
self.ensure_one()
self._ensure_loaded_lines()

line_ids_commands = []

# Clean the existing lines.
for exchange_diff in self.line_ids.filtered(lambda x: x.flag == 'exchange_diff'):
for exchange_diff in self.line_ids.filtered(lambda x: x.flag == "exchange_diff"):
line_ids_commands.append(Command.unlink(exchange_diff.id))

new_amls = self.line_ids.filtered(lambda x: x.flag == 'new_aml')
new_amls = self.line_ids.filtered(lambda x: x.flag == "new_aml")
if self.company_id.reconcile_on_company_currency:

accounts_currency_ids = []
for new_aml in new_amls:
if new_aml.account_id.currency_id not in accounts_currency_ids:
accounts_currency_ids.append(new_aml.account_id.currency_id)
if len(accounts_currency_ids) > 1:
raise UserError(
'No puede conciliar en el mismo registro apuntes de cuentas con moneda secundaria y apuntes sin '
'cuando tiene configurada la compañía con "Reconcile On Company Currency"')
"No puede conciliar en el mismo registro apuntes de cuentas con moneda secundaria y apuntes sin "
'cuando tiene configurada la compañía con "Reconcile On Company Currency"'
)
if not accounts_currency_ids or not accounts_currency_ids[0]:
line_ids_commands = []

# Clean the existing lines.
for exchange_diff in self.line_ids.filtered(lambda x: x.flag == 'exchange_diff'):
for exchange_diff in self.line_ids.filtered(lambda x: x.flag == "exchange_diff"):
line_ids_commands.append(Command.unlink(exchange_diff.id))

self.line_ids = line_ids_commands
Expand Down
35 changes: 18 additions & 17 deletions account_accountant_ux/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import ast

from odoo import models
from odoo.exceptions import UserError


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

def action_open_reconcile(self):
action_values = self.env['ir.actions.act_window']._for_xml_id('account_accountant.action_move_line_posted_unreconciled')
domain = ast.literal_eval(action_values['domain'])
domain.append(('partner_id', '=', self.id))
action_values['domain'] = domain
action_values = self.env["ir.actions.act_window"]._for_xml_id(
"account_accountant.action_move_line_posted_unreconciled"
)
domain = ast.literal_eval(action_values["domain"])
domain.append(("partner_id", "=", self.id))
action_values["domain"] = domain
return action_values

def open_partner_ledger(self):
""" Heredamos y modificamos el método original que está en account reports y lo dejamos como estaba en 16
"""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.
Expand All @@ -27,22 +30,20 @@ def open_partner_ledger(self):
desde la form de partners
"""
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',
action["params"] = {
"options": {"partner_ids": [self.id]},
"ignore_session": "both",
}
return action

def open_mass_partner_ledger(self):
selected_partner_ids = self.env.context.get('active_ids')
selected_partner_ids = self.env.context.get("active_ids")
if len(selected_partner_ids) < 1000:

action = self.env["ir.actions.actions"]._for_xml_id("account_reports.action_account_report_partner_ledger")
action['params'] = {

'options': {'partner_ids': selected_partner_ids},
'ignore_session': 'both',
action["params"] = {
"options": {"partner_ids": selected_partner_ids},
"ignore_session": "both",
}
return action
else:
raise UserError('Se deben seleccionar menos de 1000 contactos')
raise UserError("Se deben seleccionar menos de 1000 contactos")
Loading

0 comments on commit bed8484

Please sign in to comment.