Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import account_update_lock_date

View File

@@ -0,0 +1,82 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools.misc import format_date
from odoo.addons.account.models.company import LOCK_DATE_FIELDS
class AccountUpdateLockDate(models.TransientModel):
_name = "account.update.lock_date"
_description = "Wizard to Update Accounting Lock Dates"
company_id = fields.Many2one(comodel_name="res.company", required=True)
fiscalyear_lock_date = fields.Date(
string="Global Lock Date",
help="Impossible to edit/create journal entries prior to and "
"inclusive of this date. Subject to exceptions.",
)
tax_lock_date = fields.Date(
string="Tax Return Lock Date",
help="Impossible to edit/create journal entries related to a tax prior and "
"inclusive of this date. Subject to exceptions.",
)
sale_lock_date = fields.Date(
help="Impossible to edit/create sale journal entries prior to and "
"inclusive of this date. Subject to exceptions.",
)
purchase_lock_date = fields.Date(
help="Impossible to edit/create purchase journal entries prior to and "
"inclusive of this date. Subject to exceptions.",
)
hard_lock_date = fields.Date(
help="Impossible to edit/create journal entries prior to and "
"inclusive of this date. This lock date is irreversible and "
"does not allow any exception.",
)
@api.model
def default_get(self, field_list):
res = super().default_get(field_list)
company = self.env.company
for lock_field in LOCK_DATE_FIELDS:
res[lock_field] = company[lock_field]
res["company_id"] = company.id
return res
def _check_execute_allowed(self):
self.ensure_one()
has_adviser_group = self.env.user.has_group("account.group_account_manager")
if not (has_adviser_group or self.env.user._is_admin()):
raise UserError(_("You are not allowed to execute this action."))
def execute(self):
self.ensure_one()
self._check_execute_allowed()
today = fields.Date.context_today(self)
fields_sr = (
self.env["ir.model.fields"]
.sudo()
.search_read(
[("model", "=", self._name), ("name", "in", LOCK_DATE_FIELDS)],
["field_description", "name"],
)
)
field2string = dict(
(field["name"], field["field_description"]) for field in fields_sr
)
vals = {}
for lock_field in LOCK_DATE_FIELDS:
if self[lock_field] and self[lock_field] > today:
raise UserError(
_(
"You tried to set %(field)s to %(date)s, "
"but it is in the future.",
field=field2string[lock_field],
date=format_date(self.env, self[lock_field]),
)
)
vals[lock_field] = self[lock_field]
self.company_id.sudo().write(vals)

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="account_update_lock_date_form_view" model="ir.ui.view">
<field
name="name"
>account.update.lock_date.form (in account_lock_date_update)</field>
<field name="model">account.update.lock_date</field>
<field name="arch" type="xml">
<form>
<sheet>
<group id="soft_lock_dates" string="Reversible Lock Dates">
<field name="company_id" invisible="1" />
<field name="sale_lock_date" options="{'warn_future': true}" />
<field
name="purchase_lock_date"
options="{'warn_future': true}"
/>
<field name="tax_lock_date" options="{'warn_future': true}" />
<field
name="fiscalyear_lock_date"
options="{'warn_future': true}"
/>
</group>
<group id="hard_lock_dates" string="Irreversible Lock Date">
<field name="hard_lock_date" options="{'warn_future': true}" />
</group>
</sheet>
<footer>
<button
string="Update"
name="execute"
type="object"
class="btn-primary"
groups="account.group_account_manager"
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="account_update_lock_date_act_window" model="ir.actions.act_window">
<field name="name">Lock Dates</field>
<field name="res_model">account.update.lock_date</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="account_update_lock_date_menu" model="ir.ui.menu">
<field name="name">Lock Dates</field>
<field name="parent_id" ref="account.menu_finance_entries" />
<field name="action" ref="account_update_lock_date_act_window" />
<field name="sequence" eval="70" />
</record>
</odoo>