hello, i have a question after finishing making search panel in patient xm view , i finished work and turned my computer off. when i came to continue work on next day , i didn't find search filters or search panel on UI of odoo although they are still in my xml file on pycharm. what is the issue???
is the use of the _ underscore symbole in the beginning of a compute method name (or any Odoo Python method) have a meaning or it is just a naming convention?
@@OdooMates I don’t remember well, but I read an article mentioned that the use of _underscore in Python has relation with public vs private methods. So in Odoo it’s only a manner of naming convention. Thanks Bro.
@@SamirSELLAMI yes _underscore method will be private and it cannot be accessed or triggered from outside, like what i can say, those functions cannot be called from xmlrpc for example
Hi Odoo Mates Thanks for this tutorial, it's simple and clear I have question is there any difference if I wrote the _compute function with/out the `for record in self` because I made it like this, and it's working without any error @api.depends("DOB") # I named date_of_birth as DOB def _compute_age(self): today = date.today() self.age = today.year - self.DOB.year don't worry about the blank value of the DOB field, I defined a function to set it by default to 25 years back from current year.
@@OdooMates yeah, it appears, the singleton but isn't this loop is exhausting for the server? I'm imagining if I have a 10000 records, is it going to loop through them on every action I do on the UI?
Hi is it possible that there is a mistake in the calculation of the age field... there has not been taken in account that that today.month might be before the patients birthday in that year and the today.day might be before the patients birthday if today.month == rec.date_of_birth.month.
i very like your tutorials, but i see a small issue here correct me if im wrong. :) The python code is not thinking through. It is only looking at the year, but this creates an issue. For exampel: Patient A born 01.03.1994 Patient B born 01.09.1994 current date 01.07.1994 both will get the same age in the code. i guess most are aware of this but i needed it for my self to write this down :)
from datetime import date def _compute_age(self): for rec in self: today = date.today() if rec.date_of_birth(): rec.age = today.year - rec.date_of_birth else: rec.age = 1 Hi bro. This is my code. When i try to implement the above code i got a error, which is "date is not defined", kindly give me the solution for this. And for your reference "now I'm use odoo 13 version"
def _compute_age(self): for rec in self: today = date.today() if rec.date_of_birth(): rec.age = today.year - rec.date_of_birth else: rec.age = 1 This is my code bro. age = fields.Integer(string="Age", compute='_compute_age') date_of_birth = fields.Date(string="Date of Birth", required=True) This is my fields bro. Also I'm import "from datetime import date" at the top. The error is 'type error :datetime.date' object is not callable Kindly give me the solution for this
def _compute_gdays(self): for record in self: today = date.today() if record.start_date: record.gdays = today - record.start_date else: record.gdays = 1 AttributeError: 'agri.projects' object has no attribute '_compute_gdays'
hello,
i have a question
after finishing making search panel in patient xm view , i finished work and turned my computer off.
when i came to continue work on next day , i didn't find search filters or search panel on UI of odoo although they are still in my xml file on pycharm.
what is the issue???
nice
Thanks
is the use of the _ underscore symbole in the beginning of a compute method name (or any Odoo Python method) have a meaning or it is just a naming convention?
there is people who defines computed function starting with an underscore and without underscore.
@@OdooMates I don’t remember well, but I read an article mentioned that the use of _underscore in Python has relation with public vs private methods. So in Odoo it’s only a manner of naming convention. Thanks Bro.
@@SamirSELLAMI yes _underscore method will be private and it cannot be accessed or triggered from outside, like what i can say, those functions cannot be called from xmlrpc for example
@@OdooMates ah okay thanks
Welcome brother
Hi Odoo Mates
Thanks for this tutorial, it's simple and clear
I have question
is there any difference if I wrote the _compute function with/out the `for record in self`
because I made it like this, and it's working without any error
@api.depends("DOB") # I named date_of_birth as DOB
def _compute_age(self):
today = date.today()
self.age = today.year - self.DOB.year
don't worry about the blank value of the DOB field, I defined a function to set it by default to 25 years back from current year.
thanks for the support, if it is a non stored compute field, can you add this to list view and see if there is any error
@@OdooMates
yeah, it appears, the singleton
but isn't this loop is exhausting for the server?
I'm imagining if I have a 10000 records, is it going to loop through them on every action I do on the UI?
thanks
Welcome
i want to show field from sale order to stock picking how can i do that
Hi is it possible that there is a mistake in the calculation of the age field... there has not been taken in account that that today.month might be before the patients birthday in that year and the today.day might be before the patients birthday if today.month == rec.date_of_birth.month.
i very like your tutorials, but i see a small issue here correct me if im wrong. :)
The python code is not thinking through.
It is only looking at the year, but this creates an issue.
For exampel:
Patient A born 01.03.1994
Patient B born 01.09.1994
current date 01.07.1994
both will get the same age in the code.
i guess most are aware of this but i needed it for my self to write this down :)
you didn't define the exact date field because of this it will get error
api run if i put it between class and field
yes, it will
how can i use compute to set many2many value ?
self.m2m_field = record_set.ids
from datetime import date
def _compute_age(self):
for rec in self:
today = date.today()
if rec.date_of_birth():
rec.age = today.year - rec.date_of_birth
else:
rec.age = 1
Hi bro. This is my code. When i try to implement the above code i got a error, which is "date is not defined", kindly give me the solution for this.
And for your reference "now I'm use odoo 13 version"
Add from datetime import date at the top file to import date package
def _compute_age(self):
for rec in self:
today = date.today()
if rec.date_of_birth():
rec.age = today.year - rec.date_of_birth
else:
rec.age = 1
This is my code bro.
age = fields.Integer(string="Age", compute='_compute_age')
date_of_birth = fields.Date(string="Date of Birth", required=True)
This is my fields bro.
Also I'm import "from datetime import date" at the top.
The error is 'type error :datetime.date' object is not callable
Kindly give me the solution for this
@@aadhishesanlakshmanan7354 try with: fields.Date.today()
@@OdooMates ok bro thanks
@@aadhishesanlakshmanan7354 welcome brother
thank you , I get this error AttributeError: 'Date' object has no attribute 'split' when use @api.depends(date_of_birth) , can you help please
def _compute_gdays(self):
for record in self:
today = date.today()
if record.start_date:
record.gdays = today - record.start_date
else:
record.gdays = 1
AttributeError: 'agri.projects' object has no attribute '_compute_gdays'
did you restarted the service after adding the function ?