Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
5
account_usability/models/__init__.py
Executable file
5
account_usability/models/__init__.py
Executable file
@@ -0,0 +1,5 @@
|
||||
from . import account_account
|
||||
from . import account_group
|
||||
from . import account_tag
|
||||
from . import account_tax_group
|
||||
from . import res_config_settings
|
||||
58
account_usability/models/account_account.py
Executable file
58
account_usability/models/account_account.py
Executable file
@@ -0,0 +1,58 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class Account(models.Model):
|
||||
_inherit = "account.account"
|
||||
|
||||
group_id = fields.Many2one(search="_search_group_id")
|
||||
|
||||
def _search_group_id(self, operator, value):
|
||||
if operator not in ("in", "="):
|
||||
raise NotImplementedError
|
||||
|
||||
# Browse groups because value can be an odoo.tools.query.Query
|
||||
groups = self.env["account.group"].browse(value)
|
||||
|
||||
if not groups:
|
||||
return [("id", "=", 0)]
|
||||
|
||||
query = """
|
||||
SELECT
|
||||
a.id
|
||||
FROM
|
||||
account_account a
|
||||
JOIN
|
||||
account_group g
|
||||
ON g.code_prefix_start <= LEFT(
|
||||
(a.code_store::json ->> %(company_id)s),
|
||||
char_length(g.code_prefix_start)
|
||||
)
|
||||
AND g.code_prefix_end >= LEFT(
|
||||
(a.code_store::json ->> %(company_id)s),
|
||||
char_length(g.code_prefix_end)
|
||||
)
|
||||
AND g.company_id = %(company_id)s
|
||||
WHERE g.id IN %(group_ids)s
|
||||
"""
|
||||
self.env.cr.execute(
|
||||
query,
|
||||
{
|
||||
"group_ids": tuple(groups.ids),
|
||||
"company_id": str(self.env.company.root_id.id),
|
||||
},
|
||||
)
|
||||
account_ids = [row[0] for row in self.env.cr.fetchall()]
|
||||
return [("id", "in", account_ids)]
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
res = super().create(vals_list)
|
||||
res.mapped("group_id").invalidate_recordset()
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
groups = self.mapped("group_id")
|
||||
res = super().write(vals)
|
||||
if "code" in vals:
|
||||
(self.mapped("group_id") | groups).invalidate_recordset()
|
||||
return res
|
||||
14
account_usability/models/account_group.py
Executable file
14
account_usability/models/account_group.py
Executable file
@@ -0,0 +1,14 @@
|
||||
# Copyright 2018 FOREST AND BIOMASS ROMANIA SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountGroup(models.Model):
|
||||
_inherit = "account.group"
|
||||
|
||||
account_ids = fields.One2many(
|
||||
comodel_name="account.account",
|
||||
inverse_name="group_id",
|
||||
string="Accounts",
|
||||
)
|
||||
14
account_usability/models/account_tag.py
Executable file
14
account_usability/models/account_tag.py
Executable file
@@ -0,0 +1,14 @@
|
||||
# Copyright 2018 FOREST AND BIOMASS ROMANIA SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountAccountTag(models.Model):
|
||||
_inherit = "account.account.tag"
|
||||
|
||||
account_ids = fields.Many2many(
|
||||
comodel_name="account.account",
|
||||
relation="account_account_account_tag",
|
||||
string="Accounts",
|
||||
)
|
||||
14
account_usability/models/account_tax_group.py
Executable file
14
account_usability/models/account_tax_group.py
Executable file
@@ -0,0 +1,14 @@
|
||||
# Copyright 2018 FOREST AND BIOMASS ROMANIA SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountTaxGroup(models.Model):
|
||||
_inherit = "account.tax.group"
|
||||
|
||||
tax_ids = fields.One2many(
|
||||
comodel_name="account.tax",
|
||||
inverse_name="tax_group_id",
|
||||
string="Taxes",
|
||||
)
|
||||
17
account_usability/models/res_config_settings.py
Executable file
17
account_usability/models/res_config_settings.py
Executable file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2021 Opener B.V. <stefan@opener.amsterdam>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
anglo_saxon_accounting = fields.Boolean(
|
||||
related="company_id.anglo_saxon_accounting",
|
||||
readonly=False,
|
||||
string="Use anglo-saxon accounting",
|
||||
help=(
|
||||
"Record the cost of a good as an expense when this good is "
|
||||
"invoiced to a final customer."
|
||||
),
|
||||
)
|
||||
Reference in New Issue
Block a user