24. How To Create Computed Field In Odoo 15 || Compute Field In Odoo 15 || Odoo 15 Development

  Рет қаралды 16,020

Odoo Mates

Odoo Mates

Күн бұрын

Пікірлер: 33
@Mizo_Koki
@Mizo_Koki 9 ай бұрын
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???
@SamirSELLAMI
@SamirSELLAMI 2 жыл бұрын
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
@OdooMates 2 жыл бұрын
there is people who defines computed function starting with an underscore and without underscore.
@SamirSELLAMI
@SamirSELLAMI 2 жыл бұрын
@@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.
@OdooMates
@OdooMates 2 жыл бұрын
@@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
@SamirSELLAMI
@SamirSELLAMI 2 жыл бұрын
@@OdooMates ah okay thanks
@OdooMates
@OdooMates 2 жыл бұрын
Welcome brother
@alielnagar2
@alielnagar2 Жыл бұрын
nice
@OdooMates
@OdooMates Жыл бұрын
Thanks
@ShadHastam
@ShadHastam Жыл бұрын
thanks
@OdooMates
@OdooMates 7 ай бұрын
Welcome
@malikkamil6596
@malikkamil6596 2 жыл бұрын
i want to show field from sale order to stock picking how can i do that
@DonTimo12
@DonTimo12 2 жыл бұрын
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.
@abdullah-nasser-
@abdullah-nasser- Жыл бұрын
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
@OdooMates Жыл бұрын
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
@abdullah-nasser-
@abdullah-nasser- Жыл бұрын
@@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?
@Urbanbash-Lore
@Urbanbash-Lore Жыл бұрын
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 :)
@HScreators99HScreators99
@HScreators99HScreators99 7 ай бұрын
you didn't define the exact date field because of this it will get error
@mohamedsobh2626
@mohamedsobh2626 2 жыл бұрын
api run if i put it between class and field
@OdooMates
@OdooMates 2 жыл бұрын
yes, it will
@alimhanna9551
@alimhanna9551 2 жыл бұрын
how can i use compute to set many2many value ?
@OdooMates
@OdooMates 2 жыл бұрын
self.m2m_field = record_set.ids
@aadhishesanlakshmanan7354
@aadhishesanlakshmanan7354 2 жыл бұрын
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"
@OdooMates
@OdooMates 2 жыл бұрын
Add from datetime import date at the top file to import date package
@aadhishesanlakshmanan7354
@aadhishesanlakshmanan7354 2 жыл бұрын
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
@OdooMates
@OdooMates 2 жыл бұрын
@@aadhishesanlakshmanan7354 try with: fields.Date.today()
@aadhishesanlakshmanan7354
@aadhishesanlakshmanan7354 2 жыл бұрын
@@OdooMates ok bro thanks
@OdooMates
@OdooMates 2 жыл бұрын
@@aadhishesanlakshmanan7354 welcome brother
@OpenERPGolssary
@OpenERPGolssary Жыл бұрын
thank you , I get this error AttributeError: 'Date' object has no attribute 'split' when use @api.depends(date_of_birth) , can you help please
@mohamedsobh2626
@mohamedsobh2626 2 жыл бұрын
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'
@OdooMates
@OdooMates 2 жыл бұрын
did you restarted the service after adding the function ?
How to create Computed Field in Odoo
5:28
Odoo by Talha Alam
Рет қаралды 2,7 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 300 М.