[IMP] account_financial_report: black, isort

This commit is contained in:
Ernesto Tejeda
2020-03-23 11:14:52 -04:00
committed by chaule97
parent 1227d53d4f
commit 40c874a112
57 changed files with 7565 additions and 6087 deletions

View File

@@ -1,13 +1,14 @@
# ?? 2011 Guewen Baconnier (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from odoo import models, fields
from odoo import fields, models
class AccountAccount(models.Model):
_inherit = 'account.account'
_inherit = "account.account"
centralized = fields.Boolean(
'Centralized',
"Centralized",
help="If flagged, no details will be displayed in "
"the General Ledger report (the webkit one only), "
"only centralized amounts per period.")
"the General Ledger report (the webkit one only), "
"only centralized amounts per period.",
)

View File

@@ -5,49 +5,45 @@ from odoo import api, fields, models
class AccountGroup(models.Model):
_inherit = 'account.group'
_inherit = "account.group"
group_child_ids = fields.One2many(
comodel_name='account.group',
inverse_name='parent_id',
string='Child Groups')
level = fields.Integer(
string='Level',
compute='_compute_level',
store=True)
comodel_name="account.group", inverse_name="parent_id", string="Child Groups"
)
level = fields.Integer(string="Level", compute="_compute_level", store=True)
account_ids = fields.One2many(
comodel_name='account.account',
inverse_name='group_id',
string="Accounts")
comodel_name="account.account", inverse_name="group_id", string="Accounts"
)
compute_account_ids = fields.Many2many(
'account.account',
compute='_compute_group_accounts',
string="Compute accounts", store=True)
complete_name = fields.Char("Full Name",
compute='_compute_complete_name')
complete_code = fields.Char("Full Code",
compute='_compute_complete_code')
"account.account",
compute="_compute_group_accounts",
string="Compute accounts",
store=True,
)
complete_name = fields.Char("Full Name", compute="_compute_complete_name")
complete_code = fields.Char("Full Code", compute="_compute_complete_code")
@api.depends('name', 'parent_id.complete_name')
@api.depends("name", "parent_id.complete_name")
def _compute_complete_name(self):
""" Forms complete name of location from parent location to child location. """
if self.parent_id.complete_name:
self.complete_name = '%s/%s' % (self.parent_id.complete_name,
self.name)
self.complete_name = "{}/{}".format(self.parent_id.complete_name, self.name)
else:
self.complete_name = self.name
@api.depends('code_prefix', 'parent_id.complete_code')
@api.depends("code_prefix", "parent_id.complete_code")
def _compute_complete_code(self):
""" Forms complete code of location from parent location to child location. """
if self.parent_id.complete_code:
self.complete_code = '%s/%s' % (self.parent_id.complete_code,
self.code_prefix)
self.complete_code = "{}/{}".format(
self.parent_id.complete_code,
self.code_prefix,
)
else:
self.complete_code = self.code_prefix
@api.multi
@api.depends('parent_id', 'parent_id.level')
@api.depends("parent_id", "parent_id.level")
def _compute_level(self):
for group in self:
if not group.parent_id:
@@ -56,13 +52,17 @@ class AccountGroup(models.Model):
group.level = group.parent_id.level + 1
@api.multi
@api.depends('code_prefix', 'account_ids', 'account_ids.code',
'group_child_ids', 'group_child_ids.account_ids.code')
@api.depends(
"code_prefix",
"account_ids",
"account_ids.code",
"group_child_ids",
"group_child_ids.account_ids.code",
)
def _compute_group_accounts(self):
account_obj = self.env['account.account']
account_obj = self.env["account.account"]
accounts = account_obj.search([])
for group in self:
prefix = group.code_prefix if group.code_prefix else group.name
gr_acc = accounts.filtered(
lambda a: a.code.startswith(prefix)).ids
gr_acc = accounts.filtered(lambda a: a.code.startswith(prefix)).ids
group.compute_account_ids = [(6, 0, gr_acc)]

View File

@@ -4,7 +4,7 @@ from odoo import api, models
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
_inherit = "account.move.line"
@api.model_cr
def init(self):
@@ -21,10 +21,13 @@ class AccountMoveLine(models.Model):
By adding the following index, performances are strongly increased.
:return:
"""
self._cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = '
'%s',
('account_move_line_account_id_partner_id_index',))
self._cr.execute(
"SELECT indexname FROM pg_indexes WHERE indexname = " "%s",
("account_move_line_account_id_partner_id_index",),
)
if not self._cr.fetchone():
self._cr.execute("""
self._cr.execute(
"""
CREATE INDEX account_move_line_account_id_partner_id_index
ON account_move_line (account_id, partner_id)""")
ON account_move_line (account_id, partner_id)"""
)