Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
account_lock_date_update/wizards/__init__.py
Executable file
1
account_lock_date_update/wizards/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import account_update_lock_date
|
||||
82
account_lock_date_update/wizards/account_update_lock_date.py
Executable file
82
account_lock_date_update/wizards/account_update_lock_date.py
Executable 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)
|
||||
55
account_lock_date_update/wizards/account_update_lock_date.xml
Executable file
55
account_lock_date_update/wizards/account_update_lock_date.xml
Executable 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>
|
||||
Reference in New Issue
Block a user