Tuesday, 21 January 2025

How can I install python xlrd module?

The easiest way is to use the pip tool which will download and install the module for you. First of all you need to open a root terminal and then type following command:

pip install xlrd
if all runs well (i hope so), you will get this message "Successfully installed xlrd". If you get a "Permission denied" error, it means that you are not logged as root.

To make sure has been installed correctly, type following command, which will show you the version of the xlrd module:

python -c "import xlrd; print xlrd.__VERSION__"

Wednesday, 12 April 2023

How to update One2many or Many2many field in odoo ?

Below is the possible way to update, remove or add values in the many2many field:


(0, 0, { values }) link to a new record that needs to be created with the given values dictionary


(1, ID, { values }) update the linked record with id = ID (write values on it)


(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)


(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)


(4, ID) link to existing record with id = ID (adds a relationship)


(5) unlink all (like using (3, ID) for all linked records)


(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4, ID) for each ID in the list of IDs) 

Friday, 31 March 2023

How to scan barcode without barcode scanner using python ?

 import time, sys, pyautogui


def barcode_scan(delay, output):

    time.sleep(delay)

    pyautogui.typewrite(output)

    

barcode_scan(4, 'DU0000000084')

Monday, 6 March 2023

Log all queries in the official Postgres docker image

 Setting log_destination to stderr did the trick for me without creating a new image:


version: "2.2" services: db: image: postgres:12-alpine command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]


And then I was able to trace the statements using docker-compose logs -f db.

Should work with other versions too, but I only tested it with postgres:12-alpine. 

Tuesday, 10 January 2023

How to pass data from wizard to sql view report odoo?

 There is 2 way we can pass wizard data to SQL view ODOO. 


1 )  using context we can pass the selected value by user .

        as per below wizard view report method.


 def view_report(self):

        action = self.env["ir.actions.actions"]._for_xml_id("module_name.report_sql_view_action")

        context = {

            'start_date': self.start_date,

            'end_date': self.end_date,

        }

        # to initialise again SQL report with user new value.

        self.env["model.report"].with_context(context).init()

        return action


2 )  using init method of sql class as a passing parameter in the method.


 def view_report(self):

        action = self.env["ir.actions.actions"]._for_xml_id("module_name.report_sql_view_action")

        # to initialise again SQL report with user new value.

        self.env["model.report"].init(self.start_date, self.end_date)

        return action

Wednesday, 17 June 2020

Which is the best IDE for developping in Odoo on Ubuntu?

There are best 3 editor you can use for developing odoo applications or any developing purpose.

1) Sublime: This is the light weight editor and provides some theme and shortcuts for ubuntu. It is very useful for low configuration device. It will take very low memory of usage.

2) PyCharm: This is very useful and attractive editor. It will provides lots of addons.

3) Eclipse: This is also good one

Odoo10 - How to inherit t-if tag and extend it template.

<t t-extend="template_name">

    <t t-jquery="[div,span,button,etc].class_name" t-operation="[replace,after,before]">

        <-- your code -->

    </t>

</t>

for example :

<t t-extend="website_sale.products_item">

    <t t-jquery="div.product_price" t-operation="replace">

        <-- your code -->

    </t>

</t>