Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,2 @@
from . import wizard_auth_partner_reset_password
from . import wizard_auth_partner_force_set_password

View file

@ -0,0 +1,37 @@
# Copyright 2025 Akretion (http://www.akretion.com).
# @author Florian Mounier <florian.mounier@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
class WizardAuthPartnerForceSetPassword(models.TransientModel):
_name = "wizard.auth.partner.force.set.password"
_description = "Wizard Partner Auth Reset Password"
password = fields.Char(required=True)
password_confirm = fields.Char(string="Confirm Password", required=True)
@api.constrains("password", "password_confirm")
def _check_password(self):
for wizard in self:
if wizard.password != wizard.password_confirm:
raise ValidationError(
_("Password and Confirm Password must be the same")
)
def action_force_set_password(self):
self.ensure_one()
if self.env.context.get("active_model") != "auth.partner":
raise UserError(_("This wizard can only be used on auth.partner"))
auth_partner_id = self.env.context.get("active_id")
if not auth_partner_id:
raise UserError(_("No active_id in context"))
auth_partner = self.env["auth.partner"].browse(auth_partner_id)
auth_partner.write({"password": self.password})
return {"type": "ir.actions.act_window_close"}

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2025 Akretion (http://www.akretion.com).
@author Florian Mounier <florian.mounier@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="wizard_auth_partner_force_set_password_view_form" model="ir.ui.view">
<field name="model">wizard.auth.partner.force.set.password</field>
<field name="arch" type="xml">
<form string="Label">
<group>
<field name="password" password="True" />
<field name="password_confirm" password="True" />
</group>
<footer>
<button
name="action_force_set_password"
string="Set Password"
type="object"
class="oe_highlight"
/>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="auth_partner_force_set_password_action" model="ir.actions.act_window">
<field name="name">Set Password</field>
<field name="res_model">wizard.auth.partner.force.set.password</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View file

@ -0,0 +1,59 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# @author Florian Mounier <florian.mounier@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from datetime import datetime, timedelta
from odoo import api, fields, models
class WizardAuthPartnerResetPassword(models.TransientModel):
_name = "wizard.auth.partner.reset.password"
_description = "Wizard Partner Auth Reset Password"
delay = fields.Selection(
[
("manually", "Manually"),
("6-hours", "6 Hours"),
("2-days", "2-days"),
("7-days", "7 Days"),
("14-days", "14 Days"),
],
default="6-hours",
required=True,
)
template_id = fields.Many2one(
"mail.template",
"Mail Template",
required=True,
domain=[("model_id", "=", "auth.partner")],
)
date_validity = fields.Datetime(
compute="_compute_date_validity", store=True, readonly=False
)
@api.depends("delay")
def _compute_date_validity(self):
for record in self:
if record.delay != "manually":
duration, key = record.delay.split("-")
record.date_validity = datetime.now() + timedelta(
**{key: float(duration)}
)
def action_reset_password(self):
expiration_delta = None
if self.delay != "manually":
duration, key = self.delay.split("-")
expiration_delta = timedelta(**{key: float(duration)})
for auth_partner in self.env["auth.partner"].browse(
self._context["active_ids"]
):
auth_partner.directory_id._send_mail_background(
self.template_id,
auth_partner,
callback_job=auth_partner.delayable()._on_reset_password_sent(),
token=auth_partner._generate_set_password_token(expiration_delta),
)

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="wizard_auth_partner_reset_password_view_form" model="ir.ui.view">
<field name="model">wizard.auth.partner.reset.password</field>
<field name="arch" type="xml">
<form string="Label">
An email will be send with a token to each customer, you can specify the date until the link is valid
<group>
<field name="template_id" />
<field name="delay" />
<field
name="date_validity"
attrs="{'readonly': [('delay', '!=', 'manually')],
'required': [('delay', '=', 'manually')]}"
/>
</group>
<footer>
<button
name="action_reset_password"
string="Send Reset Password"
type="object"
class="oe_highlight"
/>
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="auth_partner_action_reset_password" model="ir.actions.act_window">
<field name="name">Send Reset Password Instruction</field>
<field name="res_model">wizard.auth.partner.reset.password</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="model_auth_partner" />
<field name="groups_id" eval="[(4, ref('group_auth_partner_manager'))]" />
</record>
</odoo>