<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alfadil mustafa</title>
    <description>The latest articles on DEV Community by Alfadil mustafa (@alfadil).</description>
    <link>https://dev.to/alfadil</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F368414%2F03b40d1e-5a50-4d8b-9b50-517fab184fbb.jpg</url>
      <title>DEV Community: Alfadil mustafa</title>
      <link>https://dev.to/alfadil</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alfadil"/>
    <language>en</language>
    <item>
      <title>How to approach your application infrastructure</title>
      <dc:creator>Alfadil mustafa</dc:creator>
      <pubDate>Tue, 11 Apr 2023 15:01:47 +0000</pubDate>
      <link>https://dev.to/alfadil/how-to-design-your-apps-infrastructure-581c</link>
      <guid>https://dev.to/alfadil/how-to-design-your-apps-infrastructure-581c</guid>
      <description>&lt;p&gt;Here are some of my thoughts about &lt;strong&gt;DESIGN APP'S INFRASTRUCTURE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;MAINLY YOU NEED TO HAVE A PERSPECTIVE, In other words you must know the application you are about to work with. what is it's nature? how it handles the data? does it needs to scale? and so on... .&lt;br&gt;
Setting a perspective will guide you and ease your decision making process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some principles for you to follow
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The application should be able to start and stop without any corruption on the data.&lt;/li&gt;
&lt;li&gt;You should be able to tell that the app is working or not.&lt;/li&gt;
&lt;li&gt;You should be able to replicate the app environment.&lt;/li&gt;
&lt;li&gt;Re-configuring the application should not lead to re-writing it.&lt;/li&gt;
&lt;li&gt;The data should always be external to all the components using it.&lt;/li&gt;
&lt;li&gt;Try to reach the ephemeral host concept. meaning that any host should be expendable.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Here are some questions you need to answer
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. How you will handle data? (filesystem, cache and database)
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The filesystem
&lt;/h4&gt;

&lt;p&gt;And when I say the filesystem I means all the files that the application uses directly from the host, Using those files in business applications usually leads to data lost or complicate the process of scaling or shuting a server down so I would recommend using network filesystem like (nfs) or &lt;em&gt;storage as a service&lt;/em&gt; solutions like S3 or solutions from others vendors.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cache
&lt;/h4&gt;

&lt;p&gt;Any data you keep for a temporary period of time usually to speed up the transactions or to host some sessions data.&lt;br&gt;
And like the filesystem and for the same reasons it should be external to the servers hosts using solutions like redis and memcached.&lt;/p&gt;

&lt;h3&gt;
  
  
  Database
&lt;/h3&gt;

&lt;p&gt;What type of database you will need (SQL, NoSQL) will you host it or use a managed service. As a rule of thumb &lt;strong&gt;If you don't have sensitive data just use a managed database&lt;/strong&gt; you will have less headache.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. How you will scale each component?
&lt;/h3&gt;

&lt;p&gt;Is your environment scalable?&lt;br&gt;
One might get asked this question by that management or an audit but how to answer it?&lt;br&gt;
let's ask another question what does you need to scale and when?&lt;br&gt;
Is it your backend or the database or the whole solution?&lt;br&gt;
there are two ways to decide:&lt;/p&gt;

&lt;h4&gt;
  
  
  based on resource utilization
&lt;/h4&gt;

&lt;p&gt;Like CPU and RAM or generally hardware resources.&lt;/p&gt;

&lt;h4&gt;
  
  
  based on custom (metric)
&lt;/h4&gt;

&lt;p&gt;Any custom business event metric like specific pattern of requests that alarm of a huge load requests or an event external to the application.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. How you handle failure? (in all levels infra - database - data - app)
&lt;/h3&gt;

&lt;p&gt;Here you need to know how to handle disaster and have a clair disaster recovery plan (DR) for all levels of your infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. How you deal with application starting up and shuting down ?
&lt;/h3&gt;

&lt;p&gt;For the app to make sure of the consistency of the data it needs to properly handle the shutting down to release all the connections and streams.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DevOps for Odoo</title>
      <dc:creator>Alfadil mustafa</dc:creator>
      <pubDate>Fri, 20 Jan 2023 13:14:35 +0000</pubDate>
      <link>https://dev.to/alfadil/devops-for-odoo-3l6j</link>
      <guid>https://dev.to/alfadil/devops-for-odoo-3l6j</guid>
      <description>&lt;p&gt;DevOps is all about shipping code to a running environment. It got a lot of benefits but the major one is to have consistence environment and stop (it works in my machine excuse).&lt;br&gt;
and as I worked with Odoo for a long period of time I took it as an example to create a simple way to backage developer's code as a container.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;disclaimer:&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;The pipeline created here is not meant to be used in production it's only for simplifying the idea of Devops for Odoo code base.&lt;/p&gt;

&lt;h3&gt;
  
  
  The goal:
&lt;/h3&gt;

&lt;p&gt;To create a docker image with the latest changes from git.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools:
&lt;/h3&gt;

&lt;p&gt;1.Github.&lt;br&gt;
2.Docker.&lt;br&gt;
3.Github actions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The repo structure is:&lt;/li&gt;
&lt;li&gt;Dockerfile&lt;/li&gt;
&lt;li&gt;extra-addons

&lt;ul&gt;
&lt;li&gt;addon1&lt;/li&gt;
&lt;li&gt;addon2&lt;/li&gt;
&lt;li&gt;addon..&lt;/li&gt;
&lt;li&gt;…….&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;odoo.conf&lt;/li&gt;
&lt;li&gt;requirements.txt &lt;/li&gt;
&lt;li&gt;.github

&lt;ul&gt;
&lt;li&gt;workflows&lt;/li&gt;
&lt;li&gt;docker-image.yml&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;The requirements.txt is only for python modules&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As in &lt;a href="https://github.com/AlfadilTabar/odoo-devops"&gt;odoo-devops&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The github action will generate an image with the latest and an image with a hash tag from git.&lt;br&gt;
Like dockermanfirst/odoo-14:latest, dockermanfirst/odoo-14:main-228a04c, you can deploy it on any docker host.&lt;/p&gt;

&lt;p&gt;What this structure will guarantee:&lt;br&gt;
Consistency of deployment between environments.&lt;br&gt;
Standard way to deploy the odoo version.&lt;/p&gt;

</description>
      <category>odoo</category>
      <category>devops</category>
      <category>cicd</category>
    </item>
    <item>
      <title>Build container images in Kubernetes</title>
      <dc:creator>Alfadil mustafa</dc:creator>
      <pubDate>Fri, 28 Jan 2022 23:02:52 +0000</pubDate>
      <link>https://dev.to/alfadil/build-container-images-in-kubernetes-klj</link>
      <guid>https://dev.to/alfadil/build-container-images-in-kubernetes-klj</guid>
      <description>&lt;p&gt;One of the major steps when you are designing how you gonna ship your app is &lt;strong&gt;&lt;em&gt;how you will build it&lt;/em&gt;&lt;/strong&gt; and where.&lt;/p&gt;

&lt;p&gt;Some people still use conventional ways to ship their apps where the is some Sysadmin dude who does all the deployment process, Some use automation of some kind, and some use a CI/CD pipeline to achieve this.&lt;/p&gt;

&lt;p&gt;Here I'm talking about the last type of teams (The cool one 😎) and precisely the step of building Docker images in Kubernetes environment.&lt;/p&gt;

&lt;p&gt;I'm assuming that we have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dockerfile for the project.&lt;/li&gt;
&lt;li&gt;Docker hub account.&lt;/li&gt;
&lt;li&gt;Kubernetes cluster.&lt;/li&gt;
&lt;li&gt;Kubectl client.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What we will do:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a namespace in k8s.&lt;/li&gt;
&lt;li&gt;Get authorized to store (push) the resulted image to docker hub (Docker registry).&lt;/li&gt;
&lt;li&gt;Deploy a buildkit engine to a Kubernetes cluster.&lt;/li&gt;
&lt;li&gt;Build The docker image and push it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's start:&lt;br&gt;
First we should create a namespace &lt;br&gt;
&lt;code&gt;kubectl create namespace images-builder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then create a &lt;a href="https://hub.docker.com/"&gt;Docker hub&lt;/a&gt; account.&lt;br&gt;
Go to your terminal and&lt;br&gt;
&lt;code&gt;docker login&lt;/code&gt;&lt;br&gt;
then find the docker config file&lt;br&gt;
in linux you will find it in &lt;code&gt;~/.docker/config.json&lt;/code&gt;&lt;br&gt;
it looks like &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;em&gt;if you don't find it in that place go search the internet for docker/config.json in the environment you are currently using.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After that we gonna create a secret containing the docker config file we just found using the command&lt;br&gt;
&lt;code&gt;kubectl create secret generic regcred \&lt;br&gt;
--from-file=.dockerconfigjson=/path/to/config.json \&lt;br&gt;
--type=kubernetes.io/dockerconfigjson -n images-builder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now it's time to deploy the buildkit engine.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;save it in a file let's say buildkit.yaml and then &lt;br&gt;
&lt;code&gt;kubectl apply -f buildkit.yaml -n images-builder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let expose the buildkit engine to use able to use it.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Save it in a file let's say buildkit-service.yaml and then &lt;br&gt;
&lt;code&gt;kubectl apply -f buildkit-service.yaml -n images-builder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We are going to use the engine form our local machine so let's forward the service using &lt;br&gt;
&lt;code&gt;kubectl port-forward service/buildkitd 1234 -n images-builder&lt;/code&gt;&lt;br&gt;
And then download the buildkit client from &lt;a href="https://github.com/moby/buildkit/releases"&gt;moby/buildkit&lt;/a&gt;.&lt;br&gt;
&lt;em&gt;Download the latest version with the version that suits your machine&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Extract the files to specific location.&lt;/p&gt;

&lt;p&gt;Now we can build the dockerfile using the command.&lt;br&gt;
&lt;code&gt;/path/to/bin/buildctl --addr tcp://127.0.0.1:1234  build --frontend dockerfile.v0 --local context=/path/to/context --local dockerfile=/path/contains/the/Dockerfile&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And to build the image and push to the dockerhub&lt;br&gt;
&lt;code&gt;/path/to/bin/buildctl --addr tcp://127.0.0.1:1234  build --frontend dockerfile.v0 --local context=/path/to/context --local dockerfile=/path/contains/the/Dockerfile --output type=image,name=docker.io/username/image-name,push=true&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;where username is your docker hub username and image-name is the name of the image you would like to use.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>kubernetes</category>
      <category>buildkit</category>
    </item>
    <item>
      <title>My Odoo Development Environment</title>
      <dc:creator>Alfadil mustafa</dc:creator>
      <pubDate>Mon, 15 Feb 2021 21:07:06 +0000</pubDate>
      <link>https://dev.to/alfadil/my-odoo-development-setup-33ce</link>
      <guid>https://dev.to/alfadil/my-odoo-development-setup-33ce</guid>
      <description>&lt;p&gt;&lt;em&gt;First of all it does not has to be the best way but it's the way that works for me and I would like to share it with you.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  RUNNING THE SERVICE
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Technologies used:&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;1- Docker &lt;em&gt;&lt;a href="https://www.docker.com/"&gt;more about it&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;at the start we need a postgres database server so we create a container using docker.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; p 5436:5432 &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;odoo &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;odoo &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres &lt;span class="nt"&gt;--name&lt;/span&gt; dev_pg_12 postgres:12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This means we have a pg server exposed at port 5436 so we can access it in localhost:5436&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;so you want to get on with your life which is running odoo server and develop awesome odoo apps (or you would be wasting your life here my friend 😕) &lt;/p&gt;

&lt;p&gt;so you have this project which based on odoo 12 and you have some custom code so you need to create a docker file to tell docker how to create your container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;1 FROM odoo:12.0
2 USER root
3 RUN mkdir /opt/odoo &amp;amp;&amp;amp; mkdir /opt/odoo/extra-addons
4 WORKDIR /opt/odoo
5 COPY requirements.txt requirements.txt
6 RUN apt-get update &amp;amp;&amp;amp; apt-get install -y python3-pip &amp;amp;&amp;amp; pip3 install --no-cache-dir -r requirements.txt
7 RUN chown -R odoo /opt/odoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  What every line means:
&lt;/h5&gt;

&lt;p&gt;1- The first line mean we are going to use odoo:12.0 as the base image so after this step we gonna get all v12 stuff.&lt;/p&gt;

&lt;p&gt;2- Switch to the root user (we need the permissions).&lt;/p&gt;

&lt;p&gt;3- We need to create directory to store custom modules(you know, what you think you need to add or change in odoo functionality you big shot).&lt;/p&gt;

&lt;p&gt;4- Change the working directory (like 'cd' in bash). &lt;/p&gt;

&lt;p&gt;5- Copping the requirements file ,I forgot if you have a requirements file for python of course you need to put it at the same directory as the docker file.&lt;/p&gt;

&lt;p&gt;6- Just installing the requirements.txt file.&lt;/p&gt;

&lt;p&gt;7- Change the owner of the /opt/odoo we created in step 3 cause the service runs with odoo user permissions.&lt;/p&gt;

&lt;p&gt;save the file above on with name (Dockerfile) along side requirements.txt file.&lt;br&gt;
if you don't have requirements.txt omit steps 5 and 6.&lt;/p&gt;

&lt;p&gt;Now in the same directory open the terminal and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; custom_odoo_v12 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulation you have a working odoo v12 image on your device.&lt;/p&gt;

&lt;p&gt;In this step you need to get odoo source, For v12&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget https://nightly.odoo.com/12.0/nightly/tgz/odoo_12.0.latest.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now extract it any where in your pc.&lt;br&gt;
and navigate to the odoo directory inside it&lt;br&gt;
the path should be something like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/opt/odoo_12.0.latest/odoo-12.0.post20210215/odoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;next we gonna need an odoo.conf file&lt;br&gt;
let's keep it simple&lt;br&gt;
/etc/odoo.conf&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[options]
addons_path = /opt/odoo/extra-addons/
data_dir = /var/lib/odoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;next we gonna run odoo service by creating an odoo container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 8082:8069 -v odoo12-dev-web-data:/var/lib/odoo -v path/to/custom/addons:/opt/odoo/extra-addons -v /etc/odoo.conf:/etc/odoo/odoo.conf -v /opt/odoo_12.0.latest/odoo-12.0.post20210215/odoo:/usr/lib/python3/dist-packages/odoo --name odoo12-dev --link dev_pg_12:db -t custom_odoo_v12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;what does it means 🤔&lt;/em&gt;&lt;br&gt;
1) &lt;em&gt;-p 8082:8069&lt;/em&gt;&lt;br&gt;
    Mapping odoo port(8069) to port(8082) on the host (your device).&lt;br&gt;
2) &lt;em&gt;-v odoo12-dev-web-data:/var/lib/odoo&lt;/em&gt; &lt;br&gt;
    Creating a volume to store odoo data (like filestore ...).&lt;br&gt;
3) &lt;em&gt;-v path/to/custom/addons:/opt/odoo/extra-addons&lt;/em&gt;&lt;br&gt;
    You add the path to your custom addons.&lt;br&gt;
4) &lt;em&gt;-v /etc/odoo.conf:/etc/odoo/odoo.conf&lt;/em&gt;&lt;br&gt;
    The path to the conf file&lt;br&gt;
5) &lt;em&gt;-v /opt/odoo_12.0.latest/odoo-12.0.post20210215/odoo:/usr/lib/python3/dist-packages/odoo&lt;/em&gt;&lt;br&gt;
    The path to odoo source (this is optional you need it if you gonna debug the odoo files like set up a debugger or add some print statements 😅).&lt;br&gt;
6) &lt;em&gt;--name odoo12-dev&lt;/em&gt;&lt;br&gt;
    The name of the container.&lt;br&gt;
7) &lt;em&gt;--link dev_pg_12:db&lt;/em&gt;&lt;br&gt;
    Linking the PostgreSQL db to odoo as db (this is confusing I know but it's the easiest way to do it 🤷‍♂️ ).&lt;br&gt;
8) &lt;em&gt;-t custom_odoo_v12&lt;/em&gt;&lt;br&gt;
    The Image we gonna use.&lt;/p&gt;

&lt;p&gt;now you can access the service on &lt;a href="HTTP://localhost:8082"&gt;HTTP://localhost:8082&lt;/a&gt;.&lt;br&gt;
to restart the service and see the log just do&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker restart odoo12-dev &amp;amp;&amp;amp; docker logs -f odoo12-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  MANIPULATING THE DATA:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Technologies used:&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;1- Odooly &lt;em&gt;&lt;a href="https://pypi.org/project/Odooly/"&gt;get it&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;You can always access odoo service via the browser like (chrome , firefox ,...), But some highly repeated processes like upgrading modules or reading data from a model or checking users access rights and rules you may need a faster way to do things.&lt;br&gt;
I personally prefer Odooly it's an amazing tool which I depend on daily.&lt;br&gt;
to access odoo via Odooly you just&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;odooly --server="http://localhost:8082" -d dev-db-1 -u admin -p admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  &lt;em&gt;there are lots of variations but I prefer this one&lt;/em&gt;
&lt;/h5&gt;

&lt;p&gt;then you will be inside Odooly terminal just type help and you will find lots of options like &lt;br&gt;
1- env.install("module_name")&lt;br&gt;
2- env['res.partner'].search([],limit=10)&lt;br&gt;
3- env['hr.employee'].sudo(uid).search([]) #&lt;em&gt;uid of a user&lt;/em&gt;&lt;br&gt;
Enjoy...&lt;/p&gt;

</description>
      <category>docker</category>
      <category>odoo</category>
      <category>odooly</category>
      <category>devops</category>
    </item>
    <item>
      <title>Clean Odoo debugging</title>
      <dc:creator>Alfadil mustafa</dc:creator>
      <pubDate>Fri, 15 May 2020 12:21:09 +0000</pubDate>
      <link>https://dev.to/alfadil/clean-odoo-debugging-5e6g</link>
      <guid>https://dev.to/alfadil/clean-odoo-debugging-5e6g</guid>
      <description>&lt;p&gt;Did you ever reach a point where your code looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"################ here"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="s"&gt;'''
bunch of code
'''&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"################ here2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="s"&gt;'''
bla bla lala
'''&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;something&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"################ here3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;another_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you have to force your code to produce an error to make sour it reach that line?&lt;/p&gt;

&lt;p&gt;As you might know odoo cli provide debug option see &lt;a href="https://www.odoo.com/documentation/13.0/reference/cmdline.html"&gt;Command-line interface: odoo-bin&lt;/a&gt;&lt;br&gt;
and you can debug now &lt;br&gt;
&lt;a href="https://i.giphy.com/media/xT3i0V9CFe3YP3juV2/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xT3i0V9CFe3YP3juV2/giphy.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;yah...&lt;br&gt;
you want something a little bit friendly&lt;br&gt;&lt;br&gt;
OK as you wish &lt;/p&gt;
&lt;h4&gt;
  
  
  let's start 🔥
&lt;/h4&gt;

&lt;p&gt;⚠️ we gonna need to have &lt;a href="https://code.visualstudio.com/Download"&gt;vscode&lt;/a&gt; installed in our machine&lt;br&gt;
and then install python plugin you can find it &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-python.python"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First run this command in your terminal
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip3 &lt;span class="nb"&gt;install &lt;/span&gt;debugpy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h6&gt;
  
  
  it's an implementation of the Debug Adapter Protocol for Python &lt;a href="https://github.com/microsoft/debugpy/"&gt;check it!&lt;/a&gt;
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;Then go to where you usually start your odoo server. It should be something like this.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 odoo-bin &lt;span class="nt"&gt;--addons-path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;paths/to/your/addons
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;then change it to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; debugpy &lt;span class="nt"&gt;--listen&lt;/span&gt; 5678 odoo-bin &lt;span class="nt"&gt;--addons-path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;paths/to/your/addons
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  5678 is just a port number,So chose whatever available port in your machine( this port is only used for debugging and is &lt;em&gt;not&lt;/em&gt; related to odoo services )
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;then open your addons folder in vscode (if you have more than one folder or you want to see your custom code alongside odoo standard addons put them all in a workspace &lt;a href="https://code.visualstudio.com/docs/editor/multi-root-workspaces"&gt;see how!&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you will see some icons in the left sidebar choose the one that looks like this &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gwua8JOA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/python/debugging/debug-start.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gwua8JOA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/python/debugging/debug-start.png" alt="debug-icon" title="debug-icon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;em&gt;click on create a configuration (launch.json) file&lt;/em&gt;
&lt;/h5&gt;

&lt;p&gt;you should see something like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tNmUXkmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/python/debugging/debug-configurations.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tNmUXkmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/python/debugging/debug-configurations.png" alt="debug-icon" title="python debug menu"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  &lt;em&gt;select the third option&lt;/em&gt; Remote Attach
&lt;/h5&gt;

&lt;p&gt;you will be asked about hostname and port (just press enter)&lt;/p&gt;

&lt;p&gt;vscode will open a new file called launch.json&lt;br&gt;
replace the content of that file with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"configurations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Python: Attach"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"attach"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"connect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"host"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5678&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  if you have changed the port number in the running step change it here too.
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;To start debugging press Start Debugging button as in:
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zxhvcfU5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/python/debugging/debug-start-button.png" alt="debug-icon" title="start debug"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;During remote debugging, the debugging toolbar appears as below:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iCXWj_QM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/python/debugging/remote-debug-toolbar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iCXWj_QM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/python/debugging/remote-debug-toolbar.png" alt="debug-icon" title="debug toolbar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then you can add breakpoints where you want in your python files like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2PNXJAe1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/editor/debugging/bpts-in-overview.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2PNXJAe1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://code.visualstudio.com/assets/docs/editor/debugging/bpts-in-overview.png" alt="debug-icon" title="debug breakpoints"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and 💥 everything is working now&lt;/p&gt;

&lt;p&gt;TL;DR&lt;br&gt;
&lt;a href="https://code.visualstudio.com/docs/python/debugging"&gt;check here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>odoo</category>
      <category>debugging</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Run Odoo in docker for local development</title>
      <dc:creator>Alfadil mustafa</dc:creator>
      <pubDate>Fri, 08 May 2020 22:01:13 +0000</pubDate>
      <link>https://dev.to/alfadil/run-odoo-in-docker-for-local-development-192i</link>
      <guid>https://dev.to/alfadil/run-odoo-in-docker-for-local-development-192i</guid>
      <description>&lt;p&gt;anyone who is new to Odoo or even experienced developers may have a problem in install odoo in there local devices,So I'm going to show few tips to run odoo using  &lt;a href="https://www.docker.com/"&gt;docker&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔔 first this technique assume that you are running a linux distribution like (ubuntu, debian, redhat, ...).
&lt;/h4&gt;

&lt;p&gt;now let's do it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;we are going to install Docker CE using &lt;a href="https://www.docker.com/"&gt;https://get.docker.com/&lt;/a&gt; if you already have it installed skip this step
to check if you have docker install run
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it's going to show details of the current version of docker installed if not run :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://get.docker.com &lt;span class="nt"&gt;-o&lt;/span&gt; get-docker.sh
sh get-docker.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after that add the your user to the docker group&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker &lt;span class="nv"&gt;$USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  where $USER is the name of the user
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;we are going to create a new postgres database server container(don't worry if you don't understand the meaning of the container you can check at &lt;a href="https://www.docker.com/"&gt;docker&lt;/a&gt; )
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;odoo &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;odoo &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres &lt;span class="nt"&gt;--name&lt;/span&gt; postgres_db postgres:10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now we can start an odoo server
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 8070:8069 &lt;span class="nt"&gt;--name&lt;/span&gt; odoo &lt;span class="nt"&gt;--link&lt;/span&gt; postgres_db:db &lt;span class="nt"&gt;-t&lt;/span&gt; odoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  this is going to start latest odoo version which is 13 (in the day the post written)
&lt;/h5&gt;

&lt;p&gt;now in your browser go to &lt;a href="http://localhost:8070/"&gt;http://localhost:8070&lt;/a&gt; and 🎉&lt;/p&gt;

&lt;p&gt;and to stop it run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop odoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to start it run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker start odoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to run other versions of odoo just change the tag to odoo:11.0, or odoo:12.0&lt;br&gt;
like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 8071:8069 &lt;span class="nt"&gt;--name&lt;/span&gt; odoo &lt;span class="nt"&gt;--link&lt;/span&gt; postgres_db:db &lt;span class="nt"&gt;-t&lt;/span&gt; odoo:11.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🤔 now what about custom addons ❓
&lt;/h3&gt;

&lt;p&gt;💡 we have volumes to add modules to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-v&lt;/span&gt; /path/to/addons:/mnt/extra-addons &lt;span class="nt"&gt;-p&lt;/span&gt; 8069:8069 &lt;span class="nt"&gt;--name&lt;/span&gt; odoo
&lt;span class="nt"&gt;--link&lt;/span&gt; postgres_db:db &lt;span class="nt"&gt;-t&lt;/span&gt; odoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>odoo</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
