Is it possible to have the projects a NUMBER ID so we can see this number directly. I think this is possible with code, but with the standard, what will be the best method to use?
THANKS!
😃
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Is it possible to have the projects a NUMBER ID so we can see this number directly. I think this is possible with code, but with the standard, what will be the best method to use?
THANKS!
😃
Hi,
One workaround could be, if you have Studio, you can add the existing field named "ID" to your list view and also to your form view. This is the database ID generated by Odoo when new project is created.
Thanks. But I understand this is a solution with code. But with the standard is not possible, is it?
Hi,
You can use the code like :
from odoo import models, fields, api
import uuid
class Project(models.Model):
_name = 'project.project'
_description = 'Project'
name = fields.Char(string='Name', required=True)
description = fields.Text(string='
numerical_id = fields.Integer(string='
@api.model
def create(self, vals):
vals['numerical_id'] = self.generate_numerical_id()
return super(Project, self).create(vals)
def generate_numerical_id(self):
# Generate a UUID and convert it to a numerical ID
uuid_str = str(uuid.uuid4())
# Convert the UUID to an integer
numerical_id = int(uuid_str.replace("-", "")[:16], 16)
return numerical_idif we need to do with UI , can add it through a button or any cases
like :
<!-- XML view definition -->
<record id="view_project_form_inherit" model="ir.ui.view">
<field name="name">project.project.
<field name="model">project.project</
<field name="inherit_id" ref="project.view_task_form"/>
<field name="arch" type="xml">
<!-- Add a button to trigger numerical ID generation -->
<footer>
<button name="generate_numerical_id" string="Generate Numerical ID" type="object" class="btn-primary"/>
</footer>
</field>
</record>
# Python code in your custom module
from odoo import models, fields, api
import uuid
class Project(models.Model):
_inherit = 'project.project'
numerical_id = fields.Integer(string='
@api.multi
def generate_numerical_id(self):
for project in self:
uuid_str = str(uuid.uuid4())
numerical_id = int(uuid_str.replace("-", "")[:16], 16)
project.write({'numerical_id': numerical_id})
This way, users can click the button in the UI to generate a numeric ID for the project. Adjust it according to your specific requirements and the UI design of your Odoo instance
Hope it helps
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się