[IMP] grant.benefit

This commit is contained in:
younes 2025-07-31 08:16:40 +01:00
parent 956edf0f24
commit 2940ec92aa
3 changed files with 29 additions and 6 deletions

View File

@ -8,8 +8,8 @@
<field name="binding_model_id" ref="odex_benefit.model_service_request"/>
<field name="state">code</field>
<field name="code">
if record.project_create == False:
action = records.action_open_exchange_order_wizard()
if record.project_create == False:
action = records.action_open_exchange_order_wizard()
</field>
</record>
@ -42,5 +42,15 @@
</field>
<field name="binding_type">action</field>
</record>
<record id="action_assign_benefit_sequence" model="ir.actions.server">
<field name="name">Re-Assign Benefit Sequence</field>
<field name="model_id" ref="odex_benefit.model_grant_benefit"/>
<field name="binding_model_id" ref="odex_benefit.model_grant_benefit"/>
<field name="state">code</field>
<field name="code">
action = records.assign_sequence_to_all()
</field>
</record>
</data>
</odoo>

View File

@ -578,6 +578,18 @@ class GrantBenefitProfile(models.Model):
('unique_code', 'unique (code)', 'This code already exists')
]
def assign_sequence_to_all(self):
sequence = self.env['ir.sequence'].search([('code', '=', 'benefit.sequence')], limit=1)
if not sequence:
raise UserError(_("Sequence with code 'benefit.sequence' not found"))
sequence.sudo().write({'number_next': 1})
records = self.search([], order='create_date')
for rec in records:
code = self.env['ir.sequence'].sudo().next_by_code('benefit.sequence')
rec.with_context(force_website=True).write({'code':code})
def action_set_waiting_if_needed(self):
records = self.env['grant.benefit'].browse(self._context.get('active_ids', []))

View File

@ -1,6 +1,9 @@
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
import logging
_logger = logging.getLogger(__name__)
class ResUsers(models.Model):
_inherit = 'res.users'
@ -25,10 +28,8 @@ class ResUsers(models.Model):
try:
partner.unlink()
except Exception as e:
partner.message_post(
body=_(
"Failed to delete this partner after the related user was removed.<br/>Reason: %s") % str(
e),
_logger.warning(
"Failed to delete partner ID %s after user removal. Reason: %s", partner.id, str(e)
)
return res