<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Othmane Ghandi on Medium]]></title>
        <description><![CDATA[Stories by Othmane Ghandi on Medium]]></description>
        <link>https://medium.com/@othmane.ghandi?source=rss-242880942b14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aB0K6DQ2ovghWvNUL8f-iA.png</url>
            <title>Stories by Othmane Ghandi on Medium</title>
            <link>https://medium.com/@othmane.ghandi?source=rss-242880942b14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 18:55:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@othmane.ghandi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your ERP Knows It’s in Trouble. It Just Has No Way to Tell You.]]></title>
            <link>https://medium.com/@othmane.ghandi/your-erp-knows-its-in-trouble-it-just-has-no-way-to-tell-you-620672bd4dee?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/620672bd4dee</guid>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[datadog]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[erp]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 17:01:04 GMT</pubDate>
            <atom:updated>2026-09-14T17:01:04.791Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why we connected Odoo to Datadog — and what changes when your ERP starts reporting on itself</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z4_ruPhdSlDxABjym_WZPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Be8S5X6k9xiMgGLPxwmfpQ.png" /><figcaption>ERP — Datadog Monitoring</figcaption></figure><p>The first person to notice your ERP is struggling should not be the customer waiting on an invoice.</p><p>Yet that’s almost always how it goes. Someone can’t confirm a sales order. A warehouse team can’t print labels. A finance manager calls IT two hours into month-end close. By the time anyone technical hears about it, it has stopped being a technical problem and become a business one — delayed orders, idle staff, a closing deadline slipping.</p><p>The fix often takes ten minutes. The discovery took four hours.</p><h4>The blind spot nobody plans</h4><p>Most companies monitor their website closely. Many monitor their cloud infrastructure. Very few monitor the system that actually runs the business.</p><p>That’s odd when you say it plainly. Your ERP holds your inventory, your invoicing, your payroll, your customer history. If your marketing site is down for an hour, you lose some traffic. If Odoo is down for an hour on the last day of the quarter, you lose considerably more.</p><p>The reason isn’t negligence. It’s that monitoring an ERP has traditionally meant a project — someone to instrument the system, design the dashboards, decide what “abnormal” looks like, and keep it all alive. That project competes with a hundred other priorities, so it quietly never happens. The result is an organisation that is well instrumented everywhere except its most critical system.</p><p>That’s the gap we set out to close, by connecting Odoo directly to Datadog.</p><h4>What the integration actually does</h4><p>You install the module, paste in a Datadog API key, and Odoo starts reporting on itself. There’s no agent to deploy and no custom development involved. Within minutes you’re seeing database size and growth, available storage, server load, and a continuous signal confirming the instance is alive.</p><p>From there, one button installs a set of recommended alerts — storage filling up, load climbing, the database outgrowing its server, and the instance going silent. Another button generates a complete Datadog dashboard for that Odoo instance, with every chart already scoped to it.</p><p>The point isn’t the dashboard. The point is that your ERP stops producing surprises.</p><h4>Silence is the most useful signal</h4><p>The single most valuable thing this gives you isn’t a chart. It’s a dependable answer to “is it running right now?”</p><p>Most alerting waits for something to report a problem. But a system that has genuinely stopped doesn’t report anything at all — it goes quiet. So the integration has Odoo check in on a schedule, and treats a missed check-in as the alert.</p><p>That one inversion moves the discovery of an outage from “a user calls” to “a notification arrives” — usually within minutes, at 3am on a Sunday included.</p><h4>Problems that announce themselves weeks early</h4><p>Most ERP emergencies aren’t sudden. They’re slow problems that turned urgent because nobody was watching the trend.</p><p>Storage fills up. Invoices, attachments, scanned documents and backups accumulate every single day. Storage at 70% is a calendar entry. Storage at 100% is an outage, usually a messy one.</p><p>The database grows. Growth is healthy — it means you’re trading. But growth you can’t see means discovering you’ve outgrown your server through degraded performance, rather than through an upgrade you planned calmly a month earlier.</p><p>The server strains. “It’s slow” is the complaint every ERP team hears and the hardest to act on, because by the time it’s reported the moment has passed. Continuous measurement replaces “it felt slow yesterday” with a timestamp and a number.</p><p>None of this is exotic. It’s ordinary capacity planning — which is exactly why it stings to be caught out by it.</p><h4>The question almost nobody can answer</h4><p>Here’s one that tends to interest finance more than IT.</p><p>You know how many Odoo users you have. Do you know how many actually logged in last week?</p><p>Nearly every company can answer the first question instantly, from the licence agreement. Very few can answer the second. The gap between those two numbers is worth real money, every month, indefinitely.</p><p>But the cost isn’t the interesting part. It’s what the gap tells you. When a department’s usage quietly drops off, it rarely means they stopped working — it usually means they went back to spreadsheets, found a workaround, or never really adopted the module you rolled out last year. That shows up in login patterns long before it surfaces in a project review.</p><p>Seat count is a contract. Actual usage is adoption. Only one of them tells you whether your ERP investment is working. The integration reports both, separately and deliberately.</p><h4>If you run Odoo for other people</h4><p>For Odoo partners and hosting providers, all of this multiplies. Managing fifteen client instances means fifteen opportunities to be surprised.</p><p>Because every instance reports with its customer, environment and region attached, the whole portfolio becomes a single view. More importantly, it changes a relationship: being the partner who calls the client about a problem is a fundamentally different position from being the partner the client calls.</p><p>That’s a retention argument well before it’s a technical one.</p><h4>Where this leaves you</h4><p>Monitoring the system your business runs on isn’t an IT nicety or a line on next year’s roadmap. It’s operational insurance — and unlike most insurance, it also happens to tell you whether you’re paying for software nobody uses.</p><p>If your Odoo instance went down right now, how long would it take you to find out?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=620672bd4dee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your CI/CD Tutorial Lied to You About Odoo]]></title>
            <link>https://medium.com/@othmane.ghandi/your-ci-cd-tutorial-lied-to-you-about-odoo-24d2bcdd0401?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/24d2bcdd0401</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Fri, 04 Sep 2026 14:55:09 GMT</pubDate>
            <atom:updated>2026-09-04T14:55:09.275Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glvZVaI3wH8_gajZCb2Mww.png" /></figure><blockquote>Every “Python CI/CD” guide assumes a stateless app. Odoo isn’t one — and that difference is where production deployments go to die.</blockquote><p>You’ve read the CI/CD tutorials. Push code, run `pytest`, build a Docker image, <strong>`kubectl apply`</strong>, done. Green checkmarks everywhere.</p><p>Then you tried it with Odoo, and something felt off. Your tests needed a database just to ‘<strong>import’</strong>. A code change didn’t do anything until you ran some <strong>`-u`</strong> flag. And the first time you “just deployed” a field rename to production, you quietly lost a column of customer data.</p><p>Here’s the thing nobody tells you: <strong><em>Odoo breaks four core assumptions that generic Python CI/CD tutorials are built on.</em></strong> If you don’t design your pipeline around them, you get a pipeline that’s green in CI and on fire in production.</p><p>Let me walk you through all four — with the exact commands and config that handle them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v0mc3u60L7kJqrf4LFNXIw.png" /></figure><h4>Assumption #1: “You can unit-test in isolation”</h4><p>In a normal Python project, a unit test imports a function and asserts on its output. No I/O, no database, milliseconds.</p><p>Odoo doesn’t work like that. An Odoo test runs <strong><em>inside a real Postgres database with the module installed</em></strong>, wrapped in a transaction that rolls back afterward. There is no “pure” unit test — the ORM *is* the framework, and the ORM needs a database.</p><p>That means your CI pipeline can’t just be<strong> <em>`pip install &amp;&amp; pytest`</em></strong>. Every test job has to<strong> <em>spin up Postgres first</em></strong>. In GitHub Actions, that’s a service container:</p><pre>test:<br> runs-on: ubuntu-latest<br> services:<br> db:<br> image: postgres:15<br> env: { POSTGRES_USER: odoo, POSTGRES_PASSWORD: odoo, POSTGRES_DB: postgres }<br> options: &gt;-<br> - health-cmd &quot;pg_isready -U odoo&quot; - health-interval 5s<br> - health-timeout 5s - health-retries 10<br> container:<br> image: odoo:17.0 # the job runs INSIDE the Odoo image<br> steps:<br> - uses: actions/checkout@v4<br> - run: |<br> odoo -d test_db \<br> - db_host=db - db_user=odoo - db_password=odoo \<br> -i my_module - test-enable - stop-after-init \<br> - test-tags=/my_module - log-level=test</pre><p>Two subtle things most people get wrong here:</p><p>- <strong><em>` — stop-after-init`</em></strong> is not optional. Without it, Odoo finishes the tests and then <em>keeps running as a web server</em> — your CI job hangs until it times out.<br>- <strong><em>Running the job inside `odoo:17.0`</em></strong> (not a plain Python image where you pip-install Odoo) means CI runs against the *same* Odoo build that ships to production. Fewer “works in CI, breaks in prod” surprises.</p><p>And the test itself? It looks like this:</p><pre>@tagged(&quot;post_install&quot;, &quot;-at_install&quot;)<br>class TestCourseTask(TransactionCase):<br> def test_done_task_is_never_overdue(self):<br>   task = self.env[&quot;course.task&quot;].create({<br>     &quot;name&quot;: &quot;Late task&quot;,<br>     &quot;deadline&quot;: date.today() - timedelta(days=5),<br>     })<br>   task.action_done()<br>   self.assertFalse(task.is_overdue)</pre><h4>Assumption #2: “Deploying = replacing the running code”</h4><p>For a Flask or FastAPI app, deployment is: swap the container, restart, done. The new code is live.</p><p>Not in Odoo. Odoo caches an enormous amount in the database — model definitions, views, security rules, records created from XML. <strong><em>Changing a `.py` or `.xml` file does nothing until you run an upgrade:</em></strong></p><pre>odoo -d prod_db -u my_module - stop-after-init</pre><p>That `-u` triggers Odoo to reload the module’s models (altering tables), reload its data files (updating views and records), run any migration scripts, and recompute stored fields.</p><p>So a correct Odoo deployment is never just “restart the container.” It’s:</p><pre># what a real deploy script does, in order<br>1. back up the database + filestore # your undo button<br>2. docker pull &lt;image&gt;:&lt;git-sha&gt; # the exact artifact that passed tests<br>3. odoo -u my_module - stop-after-init # apply the upgrade ← the step tutorials skip<br>4. docker compose up -d # roll to the new container<br>5. curl -f http://localhost:8069/web/health || rollback</pre><p>Miss step <strong>3</strong> and your “successful” deploy ships code that quietly does nothing.</p><h4>Assumption #3: “Rolling back is easy — just redeploy the old image”</h4><p>This is the dangerous one.</p><p>Because you deploy immutable, SHA-tagged images, rolling back *code* really is easy — redeploy the previous SHA. But step 3 above already ran `odoo -u`, which <strong><em>migrated your database schema</em></strong>. The old image may not run against the new schema.</p><p>Concrete example. In version `2.0.0` you rename a field, `deadline` → `due_date`. If you naively let the ORM handle it, Odoo <strong><em>drops</em></strong> the `deadline` column and <strong><em>creates a fresh, empty</em></strong> `due_date`. Every existing deadline is gone. And now you can’t roll back either, because the old code expects a `deadline` column that no longer exists.</p><p>The fix is a migration script, keyed to your manifest version:</p><pre># my_module/migrations/17.0.2.0.0/pre-migrate.py<br>def migrate(cr, version):<br> # Rename at the SQL level BEFORE the ORM sees it - data is preserved.<br> cr.execute(&quot;ALTER TABLE course_task RENAME COLUMN deadline TO due_date&quot;)</pre><p>The mental model that keeps you safe:</p><p>- <strong><em>Additive changes</em></strong> (new field, new model) are safe — the ORM just creates the column.<br>- <strong>Destructive changes</strong> (rename, retype, delete) need a script <strong>and</strong> a rehearsal.<br>- For zero-downtime, use <strong><em>expand/contract</em></strong>: add the new column, write to both, migrate reads, and only <strong><em>drop the old column in a later release</em></strong>. That keeps every deploy backward-compatible — which is the only way blue-green or a safe rollback actually works.</p><h4>Assumption #4: “The pipeline ends when the deploy succeeds”</h4><p>A green deploy is a hypothesis, not a conclusion. Odoo has real users and a real database; you need to <strong><em>prove</em></strong> it’s healthy and be able to undo fast.</p><p>That means the tail of your pipeline is:</p><pre>deploy-prod → smoke test (/web/health + a real login) <br> → pass: mark this SHA &quot;last known good&quot;, notify<br> → fail: auto-rollback to the last good SHA, alert</pre><p>And you track the four DORA metrics your pipeline gives you for free — deployment frequency, lead time, change-failure rate, and mean-time-to-recovery. Good CI/CD moves the first two up and the last two down.</p><h4>Putting it together</h4><p>Here’s the shape of the whole thing — the <strong><em>“Code → PROD”</em></strong> path, Odoo-aware at every stage:</p><pre>push → lint (ruff/black/pylint-odoo) → test (Odoo + Postgres) → build image (SHA tag)<br>→ scan (trivy/pip-audit) → publish → deploy staging (auto) → smoke<br>→ approve → deploy prod → odoo -u (migrate) → smoke → rollback-if-needed</pre><p>Every box has an Odoo-specific gotcha, and now you know the four biggest ones:</p><pre>1. Tests need a database → Postgres as a service, run inside the Odoo image, ` - stop-after-init`.<br>2. Deploys need `-u` → the upgrade *is* the deployment step.<br>3. DB rollback is hard → additive + expand/contract migrations, backups, staging rehearsal.<br>4. Green ≠ healthy → smoke tests and automated rollback close the loop.</pre><h4>Want the whole thing, hands-on?</h4><p>This article is the ‘<strong><em>why’</em></strong>. I’m building a full, hands-on course that’s the ‘<strong><em>how’</em></strong> — a complete Code-to-PROD pipeline for a real Odoo addons, on <strong><em>both GitHub Actions and GitLab CI</em></strong>, with:</p><p>- a working sample module + Docker lab you run yourself,<br>- lint/test/build/scan/deploy pipelines you can copy-paste,<br>- real DB migration labs (including the field-rename disaster above — and how to prevent it),<br>- and a capstone where you ship a feature to prod, break it on purpose, and watch it auto-roll-back.</p><p><strong><em>It’s dropping soon.</em></strong> If you want it the day it launches: follow me here, and drop a 💬 comment with the part of Odoo deployment that’s burned you most — I’ll make sure those land in the course.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24d2bcdd0401" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pytest vs Unittest: Which Testing Framework Should You Use?]]></title>
            <link>https://medium.com/@othmane.ghandi/pytest-vs-unittest-which-testing-framework-should-you-use-535788a2df72?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/535788a2df72</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[pytest]]></category>
            <category><![CDATA[unittest]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Wed, 23 Oct 2024 10:00:53 GMT</pubDate>
            <atom:updated>2024-10-26T14:34:14.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*6FSCNzBpaNWj6SLjTC3n1w.jpeg" /></figure><p>In the world of <strong>Python</strong> testing, unittest and pytest are two widely used frameworks. If you&#39;re starting out with automated testing or wondering which one to use, this article will walk you through the main differences, features, and use cases of both unittest and pytest. Lets first start with a classical/Philosophical introduction 😛</p><h3>Introduction to Testing Frameworks</h3><p>Automated testing is critical in ensuring the reliability and stability of your codebase, that’s why Python provides two primary testing frameworks:</p><ol><li><strong>Unittest</strong>: A built-in Python library based on Java’s JUnit, introduced as part of Python’s standard library.</li><li><strong>Pytest</strong>: A third-party testing framework, which is often considered more flexible and powerful, gaining significant popularity over the years.</li></ol><p>Enough from Philosophy :D. Let’s dive into the key differences between the two and help you decide which one suits your needs better.</p><h3>1. Ease of Use and Readability</h3><p><strong>Unittest</strong>:<br>Unittest follows an object-oriented approach, requiring you to structure your tests in classes. It’s somewhat verbose and follows the traditional setUp, tearDown, and assert methods.</p><p>Example:</p><pre>import unittest<br><br>class TestExample(unittest.TestCase):<br>    def setUp(self):<br>        self.value = 10<br><br>    def test_increment(self):<br>        self.assertEqual(self.value + 1, 11)<br><br>    def tearDown(self):<br>        pass<br><br>if __name__ == &#39;__main__&#39;:<br>    unittest.main()</pre><p><strong>Pytest</strong>:<br>Pytest offers a more concise and readable syntax. It doesn’t require you to write tests inside classes or to follow strict setup/teardown rules. It can also handle test discovery automatically.</p><p>Example:</p><pre>def test_increment():<br>    value = 10<br>    assert value + 1 == 11</pre><p><strong>Takeaway</strong>:<br>If you prefer simple, readable tests with less boilerplate, pytest wins. It is more Pythonic and eliminates the need for OOP overhead.</p><h3>2. Fixtures</h3><p>In easy terms, what are the necessary setups for running and ending tests ? 😉</p><p><strong>Unittest</strong>:<br>Unittest provides setup methods like setUp and tearDown to create and destroy test environments. While effective, this approach can sometimes feel rigid.</p><pre>class TestExample(unittest.TestCase):<br>    def setUp(self):<br>        # Prepare something for each test<br>        pass<br><br>    def tearDown(self):<br>        # Clean up after each test<br>        pass</pre><p><strong>Pytest</strong>:<br>Pytest’s fixture system is more powerful and flexible. You can use fixtures to share setup logic across multiple tests, make them reusable, and even apply them at different levels (module, class, etc.). Plus, fixtures allow injection of dependencies automatically.</p><pre>import pytest<br><br>@pytest.fixture<br>def value():<br>    return 10<br><br>def test_increment(value):<br>    assert value + 1 == 11</pre><p><strong>Takeaway</strong>:<br>Pytest&#39;s fixture system is more versatile and can be scoped to individual functions, modules, or classes, making it easier to manage reusable setup code.</p><h3>3. Assertions</h3><p><strong>Unittest</strong>:<br>Unittest requires using specific assert methods like assertEqual(), assertTrue(), assertFalse() etc., which can make tests a bit verbose.</p><pre>self.assertEqual(value + 1, 11)<br>self.assertTrue(condition)</pre><p><strong>Pytest</strong>:<br>In Pytest, you can use plain Python assert statements, which are simpler and easier to write. Pytest provides better error messages by showing the differences between expected and actual results.</p><pre>assert value + 1 == 11</pre><p><strong>Takeaway</strong>:<br>Pytest uses Python’s native assert, making it much cleaner and easier to write and debug.</p><h3>4. Test Discovery</h3><p>In easy terms, how we discovers files and methods to test inside our project ? 😉</p><p><strong>Unittest</strong>:<br>With unittest, test discovery is done using command-line options like unittest discover. It requires a bit of configuration and is not as automatic as pytest.</p><p><strong>Pytest</strong>:<br>Pytest automatically discovers all tests by looking for files prefixed with test_ or suffixed with _test.py. You can just run pytest in your terminal, and it will find and run all the tests.</p><pre>$ pytest</pre><p><strong>Takeaway</strong>:<br>Pytest provides automatic and powerful test discovery without additional configuration.</p><h3>5. Third-Party Plugin Support</h3><p><strong>Unittest</strong>:<br>While unittest can be extended, it doesn’t have a large ecosystem of plugins. You may need to write more custom code to integrate with other libraries or add extra functionality.</p><p><strong>Pytest</strong>:<br>Pytest has a huge ecosystem of plugins that allow you to extend its functionality easily. From generating test reports, mocking, handling database setups, to running parallel tests, pytest has an extensive plugin collection.</p><p>Popular plugins include:</p><ul><li>pytest-cov for coverage reports.</li><li>pytest-xdist for parallel test execution.</li><li>pytest-mock for mock object support.</li></ul><p><strong>Takeaway</strong>:<br>Pytest has a richer plugin ecosystem, making it more flexible for specialized needs.</p><h3>6. Parameterization</h3><p><strong>Unittest</strong>:<br>Unittest lacks built-in support for parameterized testing. You would need to use external libraries like ddt to achieve this.</p><p><strong>Pytest</strong>:<br>Pytest has built-in support for parameterized testing, making it simple to run the same test with different inputs using @pytest.mark.parametrize.</p><p>Example:</p><pre>import pytest<br><br>@pytest.mark.parametrize(&quot;input,expected&quot;, [(1, 2), (10, 11), (20, 21)])<br>def test_increment(input, expected):<br>    assert input + 1 == expected</pre><p><strong>Takeaway</strong>:<br>Pytest makes it easy to write parameterized tests, while unittest requires external libraries.</p><h3>Conclusion</h3><p>Both unittest and pytest are powerful testing frameworks, but they cater to different needs. If you are working on a small project and want simplicity, or if you&#39;re a fan of more readable and less verbose tests, pytest might be the right choice for you. On the other hand, if you are already used to object-oriented design and prefer built-in libraries without external dependencies, unittest may be a better fit.</p><p>Here’s a quick summary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UXUvgME9mKEeFJGgyeRAgA.png" /></figure><p>In the end, it’s all about your project needs and preferences. For most modern Python projects, pytest offers more flexibility, a larger plugin ecosystem, and easier test writing, making it a go-to choice for developers today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=535788a2df72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Python Code Quality: By Integrating Pre-Commit with GitHub Actions]]></title>
            <link>https://medium.com/@othmane.ghandi/automating-python-code-quality-by-integrating-pre-commit-with-github-actions-3d29c9bb8067?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d29c9bb8067</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pre-commit]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 21:55:51 GMT</pubDate>
            <atom:updated>2024-10-26T14:31:19.879Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-J5850sTaAsXFuDaEwVvWA.jpeg" /></figure><p>In today’s fast-paced development environment, Continuous Integration (CI) is key to maintaining a healthy, bug-free codebase. Python developers can benefit for the power / easy to use of GitHub Actions to automate CI processes while ensuring high code quality by incorporating <strong>pre-commit</strong> hooks. In this article, we’ll explore how to combine these powerful tools to streamline your Python project’s CI pipeline.</p><p>Attention Please !! there will be some scary technical names (Kidding!) that we will not explain but you can ask Mr google or the Big Boss ChatGPT I’m pretty sure you will find answers, technical names like :</p><p><strong>- Yaml files<br>- Github Actions Workflows<br>- Pre-commit hooks</strong></p><h4>What is GitHub Actions?</h4><p>GitHub Actions is automation tool built directly into GitHub (How they did that ? … sorry it’s me who is asking here 😝). Anyway, It allows developers to create custom workflows triggered by various GitHub happening events (like when you commit somthing or do a pull requests). This automation can be used for CI/CD pipelines, testing, building …etc</p><p>With <strong>GitHub Actions</strong>, you define your CI/CD processes as YAML files, making it easier to automate tasks such as running tests, linting code, or deploying software — right from your repository.</p><p>In simple terms, inside the Github action workflow you define a trigger that will trigger (x2 😛) a section of the workflow and in this section you write what you want to do. For example, do you want when you do a pull request, directly a raise of salary happens ? I’m still looking for this workflow too I didn’t find it 😆, but you get the idea, you can define an action or couple of actions that must happen</p><h4>What is Pre-Commit?</h4><p><strong>Pre-commit</strong> is a framework for managing and maintaining multi-language pre-commit hooks. Essentially, it ensures that specific checks (like linting, formatting, or static analysis) are automatically run before every commit. This helps to catch issues such as improper formatting or code that doesn’t meet quality standards before it ever gets pushed.</p><p>Some common uses for pre-commit in Python include:</p><ul><li><strong>Black</strong>: Automatic code formatting.</li><li><strong>Flake8</strong>: Code linting and style enforcement.</li><li><strong>isort</strong>: Sorting imports in Python files.</li></ul><p>Additionally, if you’re working on front-end components alongside Python, you can integrate tools like <strong>Prettier</strong>:</p><ul><li><strong>Prettier</strong>: A widely-used code formatter that enforces consistent style across different languages, including HTML, CSS, and JavaScript. It automatically formats your code, ensuring readability and eliminating style debates among team members.</li></ul><p>When all team members use the same <strong>pre-commit hooks</strong> and configurations, it ensures uniform code quality and formatting across the project. This leads to cleaner code, reduces the chance of errors, and simplifies code reviews by focusing on functionality rather than style issues. Ultimately, it promotes a smoother and more efficient collaboration process.</p><h3>Step 1: Integrating Pre-Commit with Your IDE</h3><p>While pre-commit works well in CI pipelines, integrating it with your local development environment (IDE) helps prevent issues before even pushing code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*qwsQJCdIj2mbfKYCaWfXLQ.gif" /></figure><ol><li><strong>Install Pre-Commit</strong><br>Install pre-commit locally by running:</li></ol><pre>pip install pre-commit</pre><p><strong>2. Set Up Pre-Commit Config File</strong><br>Add a .pre-commit-config.yaml file in your project’s root directory. Here’s an example config:</p><pre>repos:<br>  - repo: https://github.com/psf/black<br>    rev: 23.1.0  # Use the version of Black you want<br>    hooks:<br>      - id: black<br><br>  - repo: https://gitlab.com/pycqa/flake8<br>    rev: 4.0.1<br>    hooks:<br>      - id: flake8<br>  - repo: https://github.com/pre-commit/mirrors-prettier<br>    rev: v4.0.0-alpha.8<br>    hooks:<br>      - id: prettier<br>        name: prettier (with plugin-xml)<br>        additional_dependencies:<br>          - &quot;prettier@2.4.1&quot;<br>          - &quot;@prettier/plugin-xml@1.1.0&quot;</pre><p><strong>3. Activate Pre-Commit in Your Repository</strong><br>Once you’ve set up the config, install the hooks:</p><pre>pre-commit install</pre><p>Now, every time you try to commit changes, <strong>pre-commit</strong> will run the checks defined in your configuration file. If any checks fail, the commit will be blocked until you fix the issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*zPHn4Bb_frU2gkxenLsuwQ.gif" /><figcaption>me when your commit is blocked 😜</figcaption></figure><h4>IDE Integration</h4><p>For a smoother developer experience, you can integrate <strong>pre-commit</strong> directly into your IDE:</p><ul><li><strong>PyCharm/IntelliJ</strong>: You can add a custom pre-commit hook in your version control settings or run hooks as part of the IDE’s commit process.</li><li><strong>VSCode</strong>: Use the <strong>Python Extension</strong> to run pre-commit hooks automatically, or configure tasks to run the hooks before each commit.</li></ul><p>This ensures that your code meets the necessary standards right from your development environment.</p><h3>Step 2: Setting Up GitHub Actions for CI with Pre-Commit</h3><p>Now that we’ve set up pre-commit locally, let’s automate this process by integrating it into a <strong>GitHub Actions</strong> workflow. This ensures that pre-commit hooks are run every time you push code or open a pull request, preventing low-quality code from reaching production.</p><h4>Step 2.1: Create a GitHub Actions Workflow</h4><p>In your project’s root directory, create a directory named .github/workflows/. Inside, create a file called ci.yml (or any name you prefer, but better be meaningful 😉).</p><p>Here’s an example of a GitHub Actions workflow that runs pre-commit hooks:</p><pre>name: Python CI with Pre-Commit<br><br>on:<br>  push:<br>    branches:<br>      - main<br>  pull_request:<br>    branches:<br>      - main<br><br>jobs:<br>  lint:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v2<br><br>      - name: Set up Python<br>        uses: actions/setup-python@v2<br>        with:<br>          python-version: 3.9<br><br>      - name: Install dependencies<br>        run: |<br>          python -m venv venv<br>          source venv/bin/activate<br>          pip install pre-commit<br>          pip install -r requirements.txt<br><br>      - name: Run Pre-Commit<br>        run: |<br>          source venv/bin/activate<br>          pre-commit run --all-files</pre><h4>Step 2.2: Configure the Workflow</h4><ul><li><strong>Trigger Events</strong>: The workflow runs on every push to the main branch and on every pull request to ensure the code is always properly checked.</li><li><strong>Install Python &amp; Dependencies</strong>: We use the actions/setup-python to define the Python version and install dependencies.</li><li><strong>Run Pre-Commit Hooks</strong>: Finally, the workflow runs all configured pre-commit hooks using pre-commit run --all-files.</li></ul><p>This ensures that every push and pull request to your project goes through the same quality checks, automatically fixing or flagging any issues before merging.</p><h3>Step 3: Additional Best Practices for CI Pipelines with Pre-Commit</h3><ol><li><strong>Customize Pre-Commit Hooks</strong><br>You can add or remove hooks depending on your project needs. For example, if you use a specific linter or static analysis tool, it can be easily added to your pre-commit configuration.</li><li><strong>Run Pre-Commit in Multiple Python Versions</strong><br>If your project needs to support multiple Python versions, you can extend your workflow to run tests across various versions:</li></ol><pre>strategy:<br>  matrix:<br>    python-version: [3.8, 3.9, 3.10]</pre><h3>Conclusion</h3><p>By integrating GitHub Actions with <strong>pre-commit</strong> hooks, you can automate code quality checks and streamline your Continuous Integration process for Python projects. This workflow ensures your code is always clean, consistent, and up to your project’s standards — both in local development and the CI pipeline.</p><p>With minimal setup, you can take advantage of GitHub Actions to catch issues early and pre-commit to ensure your code remains flawless.</p><h3>Happy coding!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d29c9bb8067" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Useful Pycharm shortcuts]]></title>
            <link>https://medium.com/analytics-vidhya/useful-pycharm-shortcuts-65343a72e6f2?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/65343a72e6f2</guid>
            <category><![CDATA[pycharm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[shortcuts]]></category>
            <category><![CDATA[ide]]></category>
            <category><![CDATA[jetbrains]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Mon, 24 Feb 2020 09:03:46 GMT</pubDate>
            <atom:updated>2020-03-11T09:08:40.949Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*ZQeNKLWVioF4dv5gNK5Beg.jpeg" /><figcaption>Python IDE</figcaption></figure><p>For every programming language you can use either <strong>Code Editor</strong> or <strong>IDE </strong>to write your code:</p><p><strong>Code Editor : </strong>or Text Editor is where you write your code like a text but you benefit from syntax highlighting for different programming languages, you can also make auto-completion and some other features, which help you be more efficient in writing your code</p><p><strong>IDE :</strong> <strong>I</strong>ntegrated <strong>D</strong>evelopment <strong>E</strong>nvironment it’s more powerful, it offers all the features that a code editor can give but also other useful features : Debugging, Version Control System (VCS), install new packages &amp; plugins, Class mapping, a clear view for your project …etc.</p><p>So we can say that for just testing or compiling a small code, a Code Editor is a good option. but to work on project/program, an IDE is the best solution.</p><p>PyCharm (Py + Charm: Python is Charming 😆 just kidding) is one of the most widely used IDEs for Python programming language, developed by JetBrain.</p><p>In this article we will show you some useful shortcuts to use for Pycharm (JetBrain soltutions in general) which will help you be more efficient and save time for you (+ Make you look like a geek even if you are not 😉 )</p><p>let’s dive into these shortcuts :</p><ul><li><strong>ctrl + a : </strong>Select all the text inside your file</li><li><strong>Alt + up/down :</strong> jump from a function to another</li><li><strong>ctrl + e: </strong>Shows you the recent visited files</li><li><strong>ctrl + d :</strong></li></ul><p>We all know ctrl + c &amp; ctrl + v =&gt; ctrl + d is like a combination of both or to be more exact is a way to duplicate your text</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*Z3s5QkWgsukXdxy_NFLr1Q.gif" /><figcaption>Ctrl + d</figcaption></figure><ul><li><strong>ctrl + f:</strong></li></ul><p>It will open a search bar to look for a specific work/sentence in your file, you can also select the expression that you want to look for and then press ctrl + f it will put it automatically in the search bar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*X8EBEna3B-x-5Q41E1vzRg.gif" /><figcaption>ctrl + f</figcaption></figure><ul><li><strong>ctrl + shift + f:</strong></li></ul><p>It does the same thing as ctrl + f but it will give you more searching options : specify the directory to look in, possibility to choose the type of files to check (*.py, *.xml …), Match case …etc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*dQkqSHGhsS7X0LE8Ud2gKQ.png" /><figcaption><strong>ctrl + shift + f</strong></figcaption></figure><ul><li><strong>ctrl + shift + up/down or Alt+ shift + up/down:</strong></li></ul><p>It helps you move efficiently your selected lines to another place</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*KIpaoPwdqLhUQVBQ7IepYA.gif" /><figcaption><strong>ctrl + shift + up/down or Alt+ shift + up/down</strong></figcaption></figure><ul><li><strong>ctrl + a then ctrl + alt + i:</strong></li></ul><p>This is a good shortcut that help organize/auto-indent your code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ar22ewv4vREskizOim6IDg.gif" /><figcaption><strong>ctrl + alt + i</strong></figcaption></figure><ul><li><strong>Ctrl + a → Ctrl + Alt + L:</strong></li></ul><p>It helps formatting your code based on the suggested code style (PEP8)</p><ul><li><strong>Alt + Enter:</strong></li></ul><p>Import the missing packages</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ltTrr5NMtbFkzVGVGlzo0g.gif" /><figcaption>Alt+ Enter</figcaption></figure><ul><li><strong>ctrl + Alt + O:</strong></li></ul><p>Optimizes your imported packages, remove the unused ones</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RdWqzSp_utzjkPpbf2L4rQ.gif" /><figcaption><strong>ctrl + Alt + O</strong></figcaption></figure><ul><li><strong>ctrl + k:</strong></li></ul><p>Quick way to open the window to commit your changes when you are using Version Control System (VCS)</p><ul><li><strong>ctrl + alt + shift + delete + insert + j + enter :</strong></li></ul><p>Calm down !! you are not an octopus to press all this buttons at the same time 😜</p><h3>Conclusion</h3><p>You can have a look at all the shortcuts by going to : <strong>File -&gt; Settings -&gt; Keymap</strong></p><p>You can also change or add a shortcut to this list</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z8Q7q4ieOR0jgiqLCbTQcg.gif" /><figcaption>change or add a shortcut</figcaption></figure><p>I hope that I was helpful</p><p>Othmane Ghandi, With love ❤</p><p>You can find me easily in <a href="https://www.linkedin.com/in/othmane-ghandi/">Linkedin</a>, <a href="https://twitter.com/GHANDIOthmane">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65343a72e6f2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/useful-pycharm-shortcuts-65343a72e6f2">Useful Pycharm shortcuts</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Odoo : Community Edition  (CE) Vs Enterprise Edition (EE)]]></title>
            <link>https://medium.com/@othmane.ghandi/odoo-community-edition-ce-vs-enterprise-edition-ee-d21d8777e43d?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/d21d8777e43d</guid>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[odoo-community]]></category>
            <category><![CDATA[odoo-implementation]]></category>
            <category><![CDATA[odoo-enterprise]]></category>
            <category><![CDATA[odoo-erp]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Mon, 10 Feb 2020 09:15:43 GMT</pubDate>
            <atom:updated>2020-02-10T09:51:14.603Z</atom:updated>
            <content:encoded><![CDATA[<h3>Odoo : Community Edition (CE) Vs Enterprise Edition (EE)</h3><p>… TinyERP, OpenERP V5, 6, 7 and Odoo V8 till now we were talking about one Edition (The total Open Source one).</p><p>But starting from Odoo V9, the business model of Odoo SA changed by introducing a new Edition (Enterprise Edition) which from the name you can tell that you need some $$ to have it.</p><p>The main reason behind this changes, is to give more value/features to this new edition and in return customers need to pay a reasonable fees per month per user and also per module.</p><p>The question now what is the difference between both editions ? are they, two completely different products ? Since the community edition contains all the modules that we need, why we need an Enterprise Edition ? How much I need to pay for EE ? Is EE as expensive as the the other proprietary ERP (SAP, Netsuite, Dynamics NAV …etc) ? Why you are asking too many questions 😛 ?</p><p>I will try to give a clear picture about the 2 Editions in this article</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiZWu0xTaIQSBtYUg4pLzA.png" /><figcaption>Odoo CE vs EE</figcaption></figure><h4>a) Odoo Community Edition :</h4><p>The big and only changes that occurs on the Open Source Edition is that, Odoo SA stopped to support some modules, especially the ones related to Accounting.</p><p>So now each year/version you can find some changes in the supported modules in this Edition :</p><ul><li><em>Some modules, that were in the Odoo EE before, they get included in the upcoming CE. For example some marketing modules where added in Odoo V13 CE</em></li><li><em>Some other modules disappear to have a shinning appearance in EE. For example in Odoo V10 CE there was modules for Budget Management &amp; Assets managements but after this version they were removed</em></li></ul><p>The idea of Odoo SA is that any module that has a clear and direct dependence with accounting (Like : Payroll, Assets, Budget …etc ) will be dedicated to Odoo EE.</p><h4>b) Odoo Enterprise Edition :</h4><p>For this Edition the Core Odoo remains the same as CE. The EE offers some additional features :</p><ul><li><em>Extra modules : Odoo SA invested time and effort in some sensible processes, to meet exactly the needs of the customers. This investment should be redeemed, by putting these modules in EE.</em></li><li><em>Migration by Odoo S.A from version to another.</em></li><li><em>Mobile version.</em></li></ul><p>All these new features turned EE to a lucrative Edition by applying a <em>pricing model</em> per user per month and modules acquisition. To benefit from this Edition you need to pay 22 €/month (or 18€ for subscription more than 1 year) for each user who use the system + <strong>XX</strong> € for the modules you want to use per month <em>(NB: Each module had a specific price, you can check the </em><a href="https://www.odoo.com/pricing#pl=66&amp;version_id=3&amp;num_users=1&amp;hosting=online&amp;odoosh_workers=1&amp;odoosh_storage=1&amp;odoosh_staging=1&amp;implementation_service=self&amp;pack=25&amp;force_country=DE&amp;integrating_partner_id=0&amp;price_by=yearly"><em>pricing model here</em></a><em>, and another </em><a href="https://www.odoo.com/fr_FR/forum/aide-1/question/odoo-pricing-and-why-most-modules-are-now-pay-to-use-140915"><em>explanation here</em></a><em>).</em></p><p>From open source eye these prices are expensive but a proprietary ERP will consider them as a cheap deal or a price for a meal 😂.</p><h4>c) What should I choose ?</h4><p>This is a hard question to answer, because there is a lot of parameters that we need to take in count:</p><ul><li><em>How many modules that we want to use and how many of them are not in CE ?</em></li><li><em>How many users do we have ?</em></li><li><em>Do we want to migrate always to the last version or keep the same version ?</em></li><li><em>How much will cost us if we purchase the same missing modules from the </em><a href="https://www.odoo.com/apps"><em>Odoo apps </em></a><em>or Odoo service providers (Developers, partners, consultants, freelancers …etc) ?</em></li><li>Do we have an Odoo developer in the company ?</li></ul><p>The answer to these questions will definitely give you an overview about which way to follow.</p><h4>d) I want to use CE but benefit from the additional features of EE:</h4><p>Like I mentioned previously you can look in <a href="https://www.odoo.com/apps">Odoo apps</a> for free or paid modules provided by many sources (Companies, freelancers …etc).</p><p><em>NB: I also contribute with some free and paid modules, I’m known as </em><a href="https://www.odoo.com/apps/modules/browse?search=Odoo+Tips"><em>Odoo Tips</em></a><em>.</em></p><p>Also Odoo Community Association (OCA) do a great job to provide modules similar to those missing in CE, you just need to check its <a href="https://github.com/OCA">Github repository</a>. Also they have a tool called <a href="https://github.com/OCA/OpenUpgrade">Openupgrade</a> that helps to migrate Odoo databases when we want to upgrade to a new version</p><p>I hope that I was helpful</p><p>Othmane Ghandi, With love ❤</p><p>You can find me easily in <a href="https://www.linkedin.com/in/othmane-ghandi/">Linkedin</a>, <a href="https://twitter.com/GHANDIOthmane">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d21d8777e43d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Odoo in HTTPS using Nginx & Certbot]]></title>
            <link>https://medium.com/@othmane.ghandi/running-odoo-in-https-using-nginx-certbot-90ef2f3e5ccb?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/90ef2f3e5ccb</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[web-server]]></category>
            <category><![CDATA[certbot]]></category>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[odoo]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Thu, 06 Feb 2020 10:47:05 GMT</pubDate>
            <atom:updated>2020-02-06T11:18:46.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*YVNNG37aaSNVo59Dj4RAAw.png" /><figcaption>Odoo in https using nginx and certbot</figcaption></figure><p>Normally you can run your odoo server with any open port inside your server, you just need to specify it in your Odoo Config (by default is 8069). In this case, we are talking about http</p><p>Our concern is to add the “s” letter (stands for security) at the end of http (HTTPS) =&gt; you need to use the 443 port</p><p>Okey ! why we don’t just specify 443 port inside Odoo config ? and we get the connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*F52FRcomlrCh2zAhPZ3JAA.gif" /><figcaption>Thinking smart</figcaption></figure><p>The https is not about the port number (even if it’s the conventional port to use for this kind of communication) but more importantly the secure layer that is used on top of it, which give more protection to your data and communication. That’s why we use a web server like Nginx</p><h4>Why we use Nginx ?</h4><p>We are using here Nginx for many reasons:</p><p>1/ Nginx and the other web servers comes to implement the ssl layer, secure the communication, manage the data traffic and optimize performances. Is like a traffic cop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*Ka4Fe4fGovoWXLGGfzRB4Q.gif" /><figcaption>Traffic cop</figcaption></figure><p>2/ Is an open source Web server (there is a paid version named <strong>Nginx plus</strong>)</p><p>3/ Nginx has a good score in the<a href="https://www.rootusers.com/linux-web-server-performance-benchmark-2016-results/"> benchmarks measuring the web server performances</a></p><p>4/ Many people in Odoo community use it.</p><p>5/ This is my article, I can choose the tool :D</p><h4>Install &amp; setup Nginx in an ubuntu server :</h4><p>To install Nginx in ubuntu server is very easy, you just need to execute these commands:</p><pre>#&gt; sudo apt update<br>#&gt; sudo apt install nginx</pre><p>Once the installation finished, you can check its status by using this command:</p><pre>#&gt; sudo systemctl status nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*2Z9nw0qg9s6ly4zN8cRR1w.png" /></figure><p>You can check your installation by opening <a href="http://your_ip_address/">http://your_ip_address</a> or <em>localhost</em> in your browser</p><p>For more information you can refer to <a href="https://linuxize.com/post/how-to-install-nginx-on-ubuntu-18-04/">this good tutorial</a></p><h4>Run Odoo with Nginx :</h4><p>After installing Nginx you need to have an SSL certificate.</p><p>There is many Certificate Authorities (CA) that afford different type of SSL certificates. In our case we will use an open source one, afforded by Let’s Encrypt (free and open certificate authority)</p><p><strong>1/ Install certbot :</strong></p><pre>#&gt; sudo apt update<br>#&gt; sudo apt install certbot</pre><p><strong>2/ Generate Strong Dh (Diffie-Hellman) Group:</strong></p><pre>#&gt; sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048</pre><p><strong>3/ Map </strong><strong>.well-known/acme-challenge to </strong><strong>/var/lib/letsencrypt Directory:</strong></p><pre>#&gt; sudo mkdir -p /var/lib/letsencrypt/.well-known<br>#&gt; sudo chgrp www-data /var/lib/letsencrypt<br>#&gt; sudo chmod g+s /var/lib/letsencrypt</pre><p>we can use an Nginx snippet for the mapping and use later in our files</p><pre>#&gt; sudo nano /etc/nginx/snippets/letsencrypt.conf</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40bc901d23e9b06dc1a9f86fd8add485/href">https://medium.com/media/40bc901d23e9b06dc1a9f86fd8add485/href</a></iframe><p><strong>4/ Create a second snippet </strong><strong>ssl.conf which includes the chippers:</strong></p><pre>#&gt; sudo nano /etc/nginx/snippets/ssl.conf</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/579bddb4e001513c124962c8acf8a992/href">https://medium.com/media/579bddb4e001513c124962c8acf8a992/href</a></iframe><p><strong>5/ Create your domain nginx bloc:</strong></p><pre>sudo nano /etc/nginx/sites-available/your_domain.conf</pre><p>Add this code inside</p><pre>server {<br>  listen 80;<br>  server_name your.com www.your_domain.com;<br><br>  include snippets/letsencrypt.conf;<br>}</pre><p><strong>6/ Create a symbolic link of your file to sites-enabled folder:</strong></p><pre>sudo ln -s /etc/nginx/sites-available/your_domain.conf /etc/nginx/sites-enabled/</pre><p>sudo systemctl restart nginx</p><p>Obtain an SSL certificate by running Certbot:</p><pre>sudo certbot certonly --agree-tos --email test@example.com --webroot -w /var/lib/letsencrypt/ -d your_domain.com -d www.your_domain.com</pre><p>Now that you have the certificate files, you can edit your domain server block /etc/nginx/sites-available/your_domain.conf as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b1e6b54e981bbe1982e9010265b0318/href">https://medium.com/media/0b1e6b54e981bbe1982e9010265b0318/href</a></iframe><p><strong>NB:</strong> You need to change the 8069 port by the port that you are using &amp; your_domain.com by your real domain</p><p>Restart Nginx :</p><pre>sudo systemctl restart nginx</pre><h4>Useful Tips about Nginx &amp; Odoo :</h4><p><strong>1/</strong> In your Odoo config file you need to enable the proxy mode by adding : proxy_mode = True</p><p><strong>2/</strong> Enable the multi-processing mode by extending your Odoo config file:</p><pre>limit_memory_hard = 1677721600<br>limit_memory_soft = 629145600<br>limit_request = 8192<br>limit_time_cpu = 600<br>limit_time_real = 1200<br>max_cron_threads = 1<br>workers = 8</pre><p>You can check the <a href="https://www.odoo.com/documentation/11.0/setup/deploy.html#id5">official page</a> to know how do we get these numbers</p><p><strong>3/</strong> Normally Nginx allow <strong>1 MB</strong> of transfer/upload but you can increase it by adding inside /etc/nginx/nginx.conf:</p><pre>http {<br>    ...<br>    client_max_body_size <strong>XX M</strong>;<br>}</pre><p>Change<strong> XX </strong>by the size you want.<strong> Upload </strong>size can be a blocker when you try to add attatchments in Odoo greater then <strong>1MB</strong></p><p><strong>4/ Change the default HTML error_page with a personal one:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*dVabnWPnyYtcqe0qD6EcSw.png" /><figcaption>Not found page (Error page)</figcaption></figure><p>We can avoid this frightening error page by a personal and customized page. I will not explain better then <a href="https://medium.com/@reedrehg/odoo-down-for-maintenance-eef6b7de076c">this article</a></p><p>I hope that I was helpful</p><p>Othmane Ghandi, With love ❤</p><p>You can find me easily in <a href="https://www.linkedin.com/in/othmane-ghandi/">Linkedin</a>, <a href="https://twitter.com/GHANDIOthmane">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90ef2f3e5ccb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run Odoo with Docker]]></title>
            <link>https://medium.com/@othmane.ghandi/run-odoo-with-docker-5390b02309b3?source=rss-242880942b14------2</link>
            <guid isPermaLink="false">https://medium.com/p/5390b02309b3</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[erp]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Othmane Ghandi]]></dc:creator>
            <pubDate>Mon, 03 Feb 2020 20:11:24 GMT</pubDate>
            <atom:updated>2020-02-04T08:19:30.379Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s very annoying and time consuming for developers to spend hours, sometimes days (or even years, okey it’s a bit overboard :D ) to install all the dependencies of your application and third parties.</p><p>Imagine that this can happens for you in 2 servers running the same Operating System with the same version. I will let you imagine if we are talking about 2 different Operating Systems.</p><p>In the past, Virtual Machines (Vmware, VirtualBox …etc) was consiedered as the perfect solution to overcome this issue. But it turns out that these solutions are very greedy in term of using the real machine resources (RAM, CPU, disk space), which leads to a problem of efficiency. This problem is because of Virtual Machines architecture.</p><p>Our star of the day “docker” comes to give the same solution as Virtual Machines without impacting the performance and efficiency of the real machine. It’s kind of Lightweight Virtual Machine, thanks to its new architecture model</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NjyitbwN6fZhRPpH6CRNlQ.png" /><figcaption>Odoo &amp; Docker</figcaption></figure><h4><strong>What is Docker or Dockerize applications ?</strong></h4><p>In this part I’m just repeating what is explaining in the <a href="https://www.docker.com/resources/what-container">official website </a>in a different and succinct way. Dockerize your application is to have an isolated environment “container” that contains the packages up code and all its dependencies so the application runs quickly and reliably.</p><p>This <strong>container (Docker container)</strong> that hold your app can be saved as an <strong>image (Docker image) </strong>and used multiple time in different machines.</p><p>The Docker engine turns your image to a container in your machine so that you can use your app from this container.</p><p>we can create many containers from the same image.</p><p>For more information about what is docker and how it works, you will not find better then the <a href="https://docs.docker.com/get-started/">get started</a> in the official website</p><h4><strong>Difference between Dockers and Virtual machines</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*OH_jPfFxvV1tvlqayps9GQ.jpeg" /><figcaption>Containers vs VMs</figcaption></figure><p>Based on this illustrative picture we can easily tell that the big difference between the two, is that virtual machines use a whole OS for each VM, that’s why VM are very greedy in term of machine resources.</p><p>In the other hand containers “docker” doesn’t require a hardware hypervisor which decrease the need of machine resources.</p><p>For more detail you can check this <a href="https://www.aquasec.com/wiki/display/containers/Docker+Containers+vs.+Virtual+Machines">good article</a></p><h4>Docker usage for running Odoo</h4><p>At last, we arrive at the big question: How we can run Odoo in docker containers ?</p><p><strong>1/</strong> <strong>Setup your Docker engine and Docker Compose:</strong></p><p>You can install and setup your Docker ENV in the 3 OS, you have just to follow the official website instructions: <a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">Linux</a>, <a href="https://docs.docker.com/docker-for-windows/install/">Windows</a>, <a href="https://docs.docker.com/docker-for-mac/install/">Mac</a></p><p>For the rest of the article, I will assume that you successfully setup your Docker ENV</p><p><strong>2.a/ Create your own odoo image:</strong></p><p>Some people prefer to use their proper image for their containers. In this case you need to create your own Dockerfile like the <a href="https://github.com/odoo/docker/blob/d0360678214b8f70970a2369a5a6b37981ab2c45/12.0/Dockerfile">official Odoo docker file</a></p><p>Then you build your image from it using:</p><pre>docker image build -t image_name:tag</pre><blockquote>NB: You can also share your image in the Docker HUB</blockquote><p><strong>2.b/ Use an existing Odoo image:</strong></p><p>To save time and energy you can rely on preexisting images, like <a href="https://hub.docker.com/_/odoo">the one from Odoo S.A</a></p><p><strong>3/ Create the folder that will contain your project:</strong></p><pre>#&gt; mkdir -p ~/docker/odoo<br>#&gt; cd ~/docker/odoo<br>#&gt; touch docker-compose.yml<br>#&gt; mkdir ./config &amp;&amp; touch config/odoo.conf<br>#&gt; mkdir ./addons</pre><p><strong>4/ Fill </strong><strong>./docker-compose.yml with:</strong></p><pre>web:                           <br>  image: odoo:12.0                           <br>depends_on:                               <br>  - postgredb<br>ports:                             <br>  - 9000:8069<br>volumes:                             <br>  - ./config:/etc/odoo                             <br>  - ./addons:/mnt/extra-addons<br>environment:                             <br>  - HOST=db                             <br>  - USER=odoo                             <br>  - PASSWORD=odoo<br>postgredb:                           <br>  image: postgres:10<br>environment:                             <br>  - POSTGRES_PASSWORD=odoo                             <br>  - POSTGRES_USER=odoo                             <br>  - POSTGRES_DB=postgres</pre><p><strong>5/ Add the odoo.conf to </strong><strong>./config/odoo.conf:</strong></p><pre>[options]<br>admin_passwd = your_password<br>db_host = db                      <br>db_user = odoo                       <br>db_password = odoo                       <br>db_port = 5432</pre><p><strong>6/ Run the containers:</strong></p><p>Inside your folder, you can run your container using your docker-compose:</p><pre>#&gt; cd ~/docker/odoo<br>#&gt; docker-compose up</pre><p>If everything goes well (Normally it should be), you can check your browser and try to access to <a href="http://localhost:9000.">http://localhost:9000.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*ANKwmWlbbrum3TaPoxrTqg.png" /><figcaption>Odoo 12 first page</figcaption></figure><p>Congratulations ! you run Odoo inside Docker container</p><p>NB: There is still other features that can be used with docker that can give support your running apps. I will talk to it in another article</p><p>I hope that I was helpful</p><p>Othmane Ghandi, With love</p><p>You can find me easily in <a href="https://www.linkedin.com/in/othmane-ghandi/">Linkedin</a>, <a href="https://twitter.com/GHANDIOthmane">Twitter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5390b02309b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>