<?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 Alfatih Ridho NT on Medium]]></title>
        <description><![CDATA[Stories by Alfatih Ridho NT on Medium]]></description>
        <link>https://medium.com/@alfatihridhont?source=rss-2eac5403880e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yoViel1GM_lwtJZ9.jpg</url>
            <title>Stories by Alfatih Ridho NT on Medium</title>
            <link>https://medium.com/@alfatihridhont?source=rss-2eac5403880e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:22:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alfatihridhont/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[Flask- Chapter 6: Auth & Register User]]></title>
            <link>https://medium.com/@alfatihridhont/flask-chapter-6-auth-register-user-c0e294c716f7?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0e294c716f7</guid>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[flask-login]]></category>
            <category><![CDATA[flask]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Mon, 25 Jul 2022 07:54:39 GMT</pubDate>
            <atom:updated>2022-07-25T07:54:39.469Z</atom:updated>
            <content:encoded><![CDATA[<p>In previous chapter we already learn about database and ORM, and we already create table for user. Now in this chapter we will create register and login mechanism.</p><p>Install flask-login, we use this extension to manage user login.</p><pre>pip install flask-login</pre><p>lets declare flask login in our __init__.py file. /apps/__init__.py.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/186da25090ace331619f008c60de094e/href">https://medium.com/media/186da25090ace331619f008c60de094e/href</a></iframe><p>After this go to models.py class, we need to inherit usermixin class into User class. Also we need 2 functions, hash password and check hash password. We need to hash our password before we store the data into our db, because we want to secure our data. And also we need to create function that can compare password from form view into db.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/184e1ee921889ca557b81628fdb95d80/href">https://medium.com/media/184e1ee921889ca557b81628fdb95d80/href</a></iframe><p>Yap, now we finish playing in models.py. Now lets create form for this register and login. Create a file called form.py and place it under auth folder apps/auth/forms.py. And we need to install email validator extension to use email validator flask wtf form.</p><pre>pip install email_validator</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62bc593f50ff24fbd023563afa3c2010/href">https://medium.com/media/62bc593f50ff24fbd023563afa3c2010/href</a></iframe><p>Now lets create template for login and register templates/auth/login.html and templates/auth/register.html. For login and register templates, we will inherit from layout.html, because we don’t want header menu for login and register.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90337a837c6626c71d3db7c8516638ae/href">https://medium.com/media/90337a837c6626c71d3db7c8516638ae/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d867ca3c6e4ffd18e48a3c22870257a/href">https://medium.com/media/0d867ca3c6e4ffd18e48a3c22870257a/href</a></iframe><p>Now we have template for register and login, now lets create routes for register, login and logout. apps/auth/routes.py. In routes we will add flash message to return error or success for register or login user.</p><p>flash(message, message category), for message category, we will use bootstrap alerts category. <a href="https://getbootstrap.com/docs/4.6/components/alerts/">Click here</a> for more detail bootstrap alert category.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2043439a4c97a17605c010d0b36400b9/href">https://medium.com/media/2043439a4c97a17605c010d0b36400b9/href</a></iframe><p>Don’t forget to create __init__.py inside auth folder and register blueprint.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ebba89625a39117d26801f772f680d6/href">https://medium.com/media/5ebba89625a39117d26801f772f680d6/href</a></iframe><p>After that lets modify layout.html to display our flash message. templates/layout.html.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5805c7cc47ecc4802dd039eaa841bf44/href">https://medium.com/media/5805c7cc47ecc4802dd039eaa841bf44/href</a></iframe><p>and we will add new menu inside header menu for logout menu.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e1594353221ccbbd442d845413b6918/href">https://medium.com/media/0e1594353221ccbbd442d845413b6918/href</a></iframe><p>Ok now we have register and login mechanism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*uYHaXGa241sE9uc1b-ch0g.png" /><figcaption>Login Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*esNp_MUQM4M4oStjchSi5g.png" /><figcaption>Register Page</figcaption></figure><p>Now lets add login required in all routes of todo module, so user has to login before accessing index page, tag page etc. apps/todo/routes.py.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7c677d0bce34c433745f6d75b048dc6/href">https://medium.com/media/b7c677d0bce34c433745f6d75b048dc6/href</a></iframe><p><strong>Filter data by current user and add user id when input data</strong></p><p>For todo data and tag data, I want it filter base on user. So when user add new todo and tag data, we also include id of authenticated user. And when fetch the data we will filter the data based on authenticated user.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83d1708825f906ee6c12156d3b514318/href">https://medium.com/media/83d1708825f906ee6c12156d3b514318/href</a></iframe><p>When displaying tags in form todo we want to filter by current user too.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c75c53fbb8f1c1d2c4d46b76706fa24/href">https://medium.com/media/8c75c53fbb8f1c1d2c4d46b76706fa24/href</a></iframe><p>Ok guys, that is it for auth and register. Source code : <a href="https://github.com/trvlprogrammer/flask_tutorial/tree/chapter_6">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0e294c716f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flask- Chapter 5: Templates & Form]]></title>
            <link>https://medium.com/@alfatihridhont/flask-chapter-5-templates-form-73f3539beb8f?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/73f3539beb8f</guid>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[flask-sqlalchemy]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[flask-wtf]]></category>
            <category><![CDATA[flask]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Wed, 20 Jul 2022 07:37:03 GMT</pubDate>
            <atom:updated>2022-07-20T07:37:03.946Z</atom:updated>
            <content:encoded><![CDATA[<h3>Templates</h3><p>We already have /todo route that return string “Hi, this is todo page!”. Now I will create a route index and return html view. So, how we do it? first we will create a folder called templates, all templates will be placed in this folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*OYPzm2h1h48QPOLpLc9j0g.png" /><figcaption>templates</figcaption></figure><p>Before we create template for index view, we will create our layout template. Layout template is the base template, so other template can inherit from layout template. In this chapter I will also use bootstrap 4 to make my view looks good. You can learn more about bootstrap <a href="https://getbootstrap.com/">here</a>.</p><ol><li>layout.html will be base template</li><li>header.html will be header template that inherit layout.html (header will be menu header)</li><li>todo/index.html will be template for index html that inherit to header.html</li></ol><p>The reason I split header and layout because not all template need header, like login and register page don’t need header menu.</p><p>And for your information, html template will be rendered with jinja2 so we can parse variable, object, do for loop and if else. Awesome right!</p><ul><li>layout.html, in this template we define everything for html and in this template we also include link from bootstrap so we can use bootstrap class. And if you have custom css or js you can include it too in this file.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9b6022fd82c6c6d274c55efc6547b5e/href">https://medium.com/media/e9b6022fd82c6c6d274c55efc6547b5e/href</a></iframe><ul><li>header.html, in this file we will inherit from layout.html and put our menu in here.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7449d398adb3d91abffb27a496b375a9/href">https://medium.com/media/7449d398adb3d91abffb27a496b375a9/href</a></iframe><p>You may confuse what is this code bellow means.</p><pre>{% block header %}</pre><pre>{% endblock header %}</pre><p>It means the code from header.html will be placed in this block when inherit layout.html. You will see code like this a lot when we develop this app.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d9a97b1f3994d341574a809f6dbcfae/href">https://medium.com/media/8d9a97b1f3994d341574a809f6dbcfae/href</a></iframe><p>Now we already have the html templates, lets go to todo/routes.py. and create new routes for index like code bellow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c40304a8051b7b3b22d10da8fc3523dd/href">https://medium.com/media/c40304a8051b7b3b22d10da8fc3523dd/href</a></iframe><p>Now open your browser and hit this url <a href="http://localhost:5000/index">http://localhost:5000/index</a>, you will see something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*FJHhmOaRb4zSbZEjsApjyA.png" /><figcaption>todo/index</figcaption></figure><p>Yap, we just create a template to display todo data, and using ORM to get all data from database. Now lets move to FORM so we can input the data.</p><h3>FORM</h3><p>We need form to input our data, In flask we can use flask extension called flask-wtf. Flask wtf will help use manage form easily. So lets install flask wtf form. Activate your virtual environment and install flask-wtf.</p><pre>pip install Flask-WTF</pre><p>Create a file forms.py inside apps/todo folder. In this file we will define our form for todo.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1aaac8c021486b077c07b93796cd6f3/href">https://medium.com/media/c1aaac8c021486b077c07b93796cd6f3/href</a></iframe><p>When user hit /index route, I want user can input todo data. So, we will add form in index.html. See code bellow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd1bd8d25be9a1647313d2a9c15f21d9/href">https://medium.com/media/fd1bd8d25be9a1647313d2a9c15f21d9/href</a></iframe><p>You may wondering why I need to check if there is a form? because later I will create new route called archive, and archive menu use the same template with index page. But in archive page, I don’t parse form so user can not create new todo in there.</p><p>Now lets move to routes.py. First we will check if form validate or not, if yes we will insert the data to database using ORM. If not, we will select all data from database and return all data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/377dc96e38665ddaa8541df56bbb0a03/href">https://medium.com/media/377dc96e38665ddaa8541df56bbb0a03/href</a></iframe><p>And for many2many field views, there is a special treatment to show the data. So I will add a new file inside static folder called static/widget.js. Because when user want to chose tags, I want the tags selection like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*S_w0SbsM0eP1dJKZW38p1w.png" /><figcaption>Tags</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0217c2280d4ba78ffd40ac9cdf5bf4d/href">https://medium.com/media/c0217c2280d4ba78ffd40ac9cdf5bf4d/href</a></iframe><p>And don’t forget to include widget.js in our layout.html</p><pre>&lt;script src=&quot;{{ url_for(&#39;static&#39;, filename=&#39;widget.js&#39;) }}&quot;&gt;&lt;/script&gt;</pre><pre>##place this code at scipt script</pre><p>Now we have form for todo and also display todo’s data. Now lets insert tag data manually through database, because we don’t have tag form yet.</p><pre>insert into tag(name) values (&#39;tag1&#39;),(&#39;tag2&#39;),(&#39;tag2&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*mw1IRlT-v6ZaUywZtfQmVg.png" /><figcaption>index</figcaption></figure><p>Ok, we just have everything. After this I will add new menu called archive and this menu will display todo with active = false data, and also I will ada 2 button to archive and unarchive todo data and button for delete todo.</p><p>First I will create 2 routes, one for set archive unarchive and one for delete. See code bellow :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05daa2eb5f63a8864fac781aa819a70d/href">https://medium.com/media/05daa2eb5f63a8864fac781aa819a70d/href</a></iframe><p>And in index.html we will add 2 buttons, we will add if else to set the button string to archive or unarchive.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb39835c019e46ee76c00220decf9a72/href">https://medium.com/media/fb39835c019e46ee76c00220decf9a72/href</a></iframe><p>Now we have thing like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*JjdBxc9H_x0Lh60yoUzQVg.png" /><figcaption>index</figcaption></figure><p>Now at index page, I only want to display todo with active = true, and I will add new menu called archive. In this menu I will only show data with active = false.</p><p>lets add filter_by(active = True) in index route</p><pre>@bp.route(&quot;/&quot;,methods=[&#39;GET&#39;,&#39;POST&#39;])<br>@bp.route(&quot;/index&quot;,methods=[&#39;GET&#39;,&#39;POST&#39;])<br>def index():<br>      #***<br>      todos = Todo.query.filter_by(active=True).all()<br>      #***</pre><p>And we create new route for archive and only show todo data with active = false. And for archive route I don’t parse form, because I don’t want user to input todo form in this route.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d90174ae776d3d9cc1741959f5ee3e8/href">https://medium.com/media/0d90174ae776d3d9cc1741959f5ee3e8/href</a></iframe><p>Now add new menu archive in header.html</p><pre>&lt;li class=&quot;nav-item active&quot;&gt;</pre><pre>&lt;a class=&quot;nav-link&quot; href=&quot;{{url_for(&#39;todo.todo_archive&#39;)}}&quot;&gt;Archive&lt;/a&gt;</pre><pre>&lt;/li&gt;</pre><p>Now we have todo menu and archive menu like picture bellow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*lfw_rYljezRZG5ZvOFXWNw.png" /><figcaption>Todo menu</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*PrpkNu4zoTl31qKaxlhCWQ.png" /><figcaption>Archive menu</figcaption></figure><p>Ok, we have menu for todo and archive, but we still need one menu for tag. So I want you to create tag menu, and display all tag there with one button delete, so user can delete the tag. For tag you can place it in todo folder.</p><p>Source Code : <a href="https://github.com/trvlprogrammer/flask_tutorial/tree/chapter_5">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73f3539beb8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flask- Chapter 4: Database & ORM]]></title>
            <link>https://medium.com/@alfatihridhont/flask-chapter-4-database-orm-786f16fd3b59?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/786f16fd3b59</guid>
            <category><![CDATA[sqlalchemy]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[flask-sqlalchemy]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 10:50:06 GMT</pubDate>
            <atom:updated>2022-07-18T11:36:29.299Z</atom:updated>
            <content:encoded><![CDATA[<p>When you create an application and the application want to store data, means the application need a database to store the data. In flask you can chose to use SQL or NonSql.</p><p>This chapter will cover for SQL(MySQL &amp; PostgreSQL).</p><p>First you need to install python library to connect to MySQL or PostgreSQL depends on database that you have in your machine.</p><p>MySQL :</p><pre>pip install pymysql</pre><p>PostgreSQL:</p><pre>pip install psycopg2</pre><p>Ok, we just install the library, then What? after this we need to install migration library and ORM(Object-relational mapping) library. In this chapter we will use Flask-Migrate and Flask-SQLAlchemy as ORM.</p><p>Flask-Migrate :</p><pre>pip install Flask-Migrate</pre><p>Flask-SQLAlchemy:</p><pre>pip install Flask-SQLAlchemy</pre><p>Now open your postgres or mysql gui and create a database called todolist_apps.</p><p>Yess!! now we have everything. Now lets define migration and database in file apps/__init__.py. And define the configuration for database connection in config.py.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24e06bde488a2f9369241846b86a57fa/href">https://medium.com/media/24e06bde488a2f9369241846b86a57fa/href</a></iframe><p>Ok, now lets add new config in config.py for database connection.</p><pre>SQLALCHEMY_DATABASE_URI = os.environ.get(&#39;DATABASE_URL&#39;, &#39;&#39;).replace(</pre><pre>&#39;postgres://&#39;, &#39;postgresql://&#39;) or \</pre><pre>&#39;sqlite:///&#39; + os.path.join(basedir, &#39;app.db&#39;)</pre><p>why replacing postgres with postgresql? In case you want to deploy the application at heroku later. And if you don’t have postgresql or mysql on your machine the application will automatically create sqlite database inside root directory. Now lets create variable in .env file.</p><p>postgresql:</p><pre>DATABASE_URL=postgresql+psycopg2://{database user}:{database password}@{database ip}:{port database}/{database name}</pre><pre>Example :<br>DATABASE_URL=postgresql+psycopg2://flask:flask@localhost:5432/todolist_apps</pre><p>mysql:</p><pre>DATABASE_URL=mysql+pymysql://{database user}:{database password}@{database ip}:{port database}/{database name}</pre><pre>Example :<br>DATABASE_URL=mysql+pymysql://flask:flask@localhost:3306/todolist_apps</pre><p>After this, lets create a file called models.py inside apps folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*oO4keBrbgn8olAundsw3Ow.png" /><figcaption>models.py</figcaption></figure><p>For this chapter we will create a table called todo and todo has column</p><ol><li>id (integer auto increment)</li><li>description(string limit 140 character, because todo don’t need that much description)</li><li>date_todo(date time utc without time zone)</li><li>active(boolean)</li></ol><p>If you wanna know more about column type, you can open documentation <a href="https://flask-sqlalchemy.palletsprojects.com/en/2.x/models/">here.</a></p><p>Now lets move to models.py files and define our table and column.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ecd068322d5ea040dac58bc92e2f77c/href">https://medium.com/media/1ecd068322d5ea040dac58bc92e2f77c/href</a></iframe><p>After this don’t forget to import models.py in apps/__init__.py. See code __init__.py above.</p><p>Yeah we almost done. Now activated your python virtual environment and move to root folder of the application and run these commands:</p><pre>flask db init &gt; initiated database and create new folder inside root folder called migrations</pre><pre>flask db migrate -m &quot;first migration todo table&quot; &gt; create a migration file with description first migration todo table</pre><pre>flask db upgrade &gt; apply the migration into database</pre><p>After running commands above check your database, and make sure it has new table called todo and column like we define before.</p><h3>Database relation</h3><p><strong>One2many relation</strong>. For easy example, one user can have many todo. In our code, lets define a user table in models.py. Table user will have column like these :</p><ul><li>id (integer auto increment)</li><li>username (string)</li><li>password(string)</li><li>todos(one2many relation to table todo)</li><li>tags(one2many relation to table tag)</li></ul><p><strong>Many2one relation</strong>. For example many todos only have 1 author. This is the opposite of one2many relation. When we create one2many relation we need to declare many2one relation too. For this example we will add new column in todo table called user_id(many2one to user table) integer.</p><p><strong>Many2many relation</strong>. Easy example, many todos can have many tags. For this example we need to create a new table call tag, Tag table will have column like this:</p><ul><li>id (integer auto increment)</li><li>name (string)</li><li>user_id (integer many2one to user table)</li></ul><p>After create table tag, we need to create another table to save tag id and todo id. This is a many2many table relation for todo and tag.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0000c1d7c1d6abcb1c10f4c9e61de75c/href">https://medium.com/media/0000c1d7c1d6abcb1c10f4c9e61de75c/href</a></iframe><p>And now lets run migration and upgrade command to see the result.</p><pre>flask db migrate -m &quot;relation table&quot;</pre><pre>flask db upgrade </pre><h3><strong>ORM</strong></h3><p>ORM will help you will help you when doing CRUD(create, read, update, delete). With ORM it will be easy todo CRUD.</p><ol><li>Create. When we want to store the data in database we will run create function. For example we have todo table like we made before, to store the data to database we will run this code</li></ol><pre>from apps.models import Todo<br>from apps import db</pre><pre>todo = (description=&quot;this is description&quot;, active=true)#define value #for todo column<br>db.session.add(todo) #add value<br>db.session.commit() #commit to database</pre><p>2. Read. To display the data we need to read data in our database. For example, we will read data for todo table. There are 2 ways to read the data, read all and filter.</p><p>For read all data :</p><pre>from apps.models import Todo<br>from apps import db</pre><pre>Todo.query.all() #get all data in todo table</pre><p>For filter data :</p><pre>from apps.models import Todo<br>from apps import db</pre><pre>Todo.query.filter_by(active=True).all()#Will get the data with #active = true</pre><p>3. Update. For example I want to update todo data. First I will find the data, change the value and commit to database.</p><pre>from apps.models import Todo<br>from apps import db</pre><pre>todo = Todo.query.filter_by(id=1) #get todo data with id = 1<br>todo.description = &quot;new description&quot; #update value for description<br>db.session.commit() #commit to database</pre><p>4. Delete. Same as update, First find the data, delete and commit to database.</p><pre>from apps.models import Todo<br>from apps import db</pre><pre>Todo.query.filter_by(id=1).delete() #get data todo with id = 1 and #delete it</pre><pre>db.session.commit() #commit to database</pre><p>Remember this, when you do create, update and delete don’t forget to commit to database. db.session.commit()</p><p>This example CRUD in todos route with dummy data.</p><ul><li>Create <a href="http://localhost:5000/create">http://localhost:5000/create</a></li><li>Read <a href="http://localhost:5000/read">http://localhost:5000/r</a>ead</li><li>Update <a href="http://localhost:5000/update/3">http://localhost:5000/update/3</a></li><li>Delete <a href="http://localhost:5000/delete/3">http://localhost:5000/delete/3</a></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d009fa46ec83b02145cebcc3dce99408/href">https://medium.com/media/d009fa46ec83b02145cebcc3dce99408/href</a></iframe><p>Ok guys, I hope you get the idea of database and ORM. See you on next chapter.</p><p>Source code : <a href="https://github.com/trvlprogrammer/flask_tutorial/tree/chapter_4">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=786f16fd3b59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flask- Chapter 3: Configuration]]></title>
            <link>https://medium.com/@alfatihridhont/flask-chapter-3-configuration-591d6839a6cf?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/591d6839a6cf</guid>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 03:53:52 GMT</pubDate>
            <atom:updated>2022-07-18T03:53:52.935Z</atom:updated>
            <content:encoded><![CDATA[<p>In application there is always a config file, and config file should be dynamic. It means we just adjust the config file without touching other files.</p><p>For config file we use a file with extension .env and config.py. These 2 files located inside root folder :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*EFBYdlX6MnfHnGtKYoCylg.png" /><figcaption>.env file and config.py</figcaption></figure><p>For this example we will create config for SECRET_KEY. Now lets move to .env file and create SECRET_KEY variable and assign value for it.</p><pre>SECRET_KEY=this-is-super-secret</pre><p>After that we move to config.py. in this file we will create class Config and a variable called SECRET_KEY , and we will assign the value from .env file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9bc334bd82272f9c4c37aea5a74f9aeb/href">https://medium.com/media/9bc334bd82272f9c4c37aea5a74f9aeb/href</a></iframe><p>Now we lets move to apps/__init__.py to import config.py file and let flask app read and apply the configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69c55123ef3d8affb2e6e4512a1ea034/href">https://medium.com/media/69c55123ef3d8affb2e6e4512a1ea034/href</a></iframe><p>Everytime you have new configuration you can add it in .env file and define the configuration in config.py file. You can adjust the value inside .env file based on environment application(development, production, testing).</p><p>Source code : <a href="https://github.com/trvlprogrammer/flask_tutorial/tree/chapter_3">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=591d6839a6cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flask- Chapter 2: Blueprints]]></title>
            <link>https://medium.com/@alfatihridhont/flask-chapter-2-blueprints-8542b4431ea7?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8542b4431ea7</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[flask]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 09:18:25 GMT</pubDate>
            <atom:updated>2022-07-15T09:21:09.644Z</atom:updated>
            <content:encoded><![CDATA[<p>Flask has a feature called blueprints, with blueprint we can manage our application to be modular. But why we need modular application when we can write entire code in single file?</p><p>Well, sure you can write the code in single file, but in this real world we need application that scalable and work with collaboration. When you write everything in single file it will make you in trouble when maintain the application because everything is in one file.</p><p>For example you have todo list application, inside your application you have user management and todo management, with flask blueprint we will make it modular per apps, app auth and app todo. See tree source file bellow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*Spr2gDp44Yd6stJzKUTOJA.png" /><figcaption>tree source application</figcaption></figure><p>apps folder containing the app/module of the application, static folder(static file like js, css, etc), templates(view template html).Explanation for picture above:</p><ol><li>Auth folder is a module contain things that related to user, login and register.</li><li>Todo folder is a module for our main apps, It’s related to todo list.</li><li>Templates folder contain views for the application, inside this folder we can make sub directory for each app. Like auth folder is for auth template like login and register. Making sub directory for each module make the file more organized and tidy. And with jinja2 we can inherit template, that is why we have layout.html and header.html for parent template.</li><li>Static folder containing static file like css file, javascript file and etc.\</li></ol><p>As you can see in picture above you might wondering why there is always file __init__.py and routes.py. Don’t worry, I will explain this.</p><ol><li>In python when directory containing file __init__.py python will thread this directory as module, this is exactly what we want. In our module we will register our blueprints inside file __init__.py.</li><li>routes.py containing routes for each module. For example module auth has route /login and /register , these routes we will define in routes.py inside auth module. In file apps/__init__.py we will register all blueprints here and define the apps.</li></ol><p>Lets create a route for todo module. apps/todo/routes</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c1fed3cbfbf90c1a8e97a415fe481d5/href">https://medium.com/media/5c1fed3cbfbf90c1a8e97a415fe481d5/href</a></iframe><p>After that we can register the routes in apps/todo/__init__.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88e4cbcfb6722860612d6ede97f3d77e/href">https://medium.com/media/88e4cbcfb6722860612d6ede97f3d77e/href</a></iframe><p>That is it, we just create 1 module named todo, and todo has 1 route /todo that return string. And after this how we register this module to our main apps? ok, lets see code bellow. apps/__init__.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e248b93e91362ff0e47fb3890afb6a23/href">https://medium.com/media/e248b93e91362ff0e47fb3890afb6a23/href</a></iframe><p>Alright we just have 1 complete application. But before we run the application, lets call the application in flask main file like <a href="https://medium.com/@alfatihridhont/flask-chapter-1-what-is-flask-67b784c67116">chapter 1</a>. Our main flask file is run.py, so lets call the application inside the run.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee89ef477a5150a07dd4ce22899928bb/href">https://medium.com/media/ee89ef477a5150a07dd4ce22899928bb/href</a></iframe><p>Yess, we just finished everything. Now lest run the application. You can run it with console :</p><pre>python run.py</pre><p>Or running it with flask command :</p><pre>flask run</pre><p>Now the application is running, go to your browser hit url :</p><pre><a href="http://localhost:5000/todos">http://localhost:5000/todos</a></pre><p>Ok, that is it for Chapter 2. Thank you.</p><p>Source Code : <a href="https://github.com/trvlprogrammer/flask_tutorial/tree/chapter_2">Github</a></p><p>Chapter 3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8542b4431ea7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flask- Chapter 1 : What is Flask?]]></title>
            <link>https://medium.com/@alfatihridhont/flask-chapter-1-what-is-flask-67b784c67116?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/67b784c67116</guid>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 06:19:27 GMT</pubDate>
            <atom:updated>2022-07-15T09:19:32.008Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flask- Chapter 1 : What is Flask?</h3><p>Flask is web micro framework based on python programming language. You can develop Flask freely, like you can choose the library(which one that you prefer), database(SQL or NonSQL), structure apps, etc.</p><p>Lets get started with Flask.</p><ol><li>Make sure you have python 3 on your machine. Install virtual environment and create virtual environment.</li></ol><pre>pip3 install virtualenv</pre><p>Windows</p><pre>python3 -m virtualenv env &gt;&gt; install virtual environment</pre><pre>env\Scripts\activate &gt;&gt; activate virtual environment</pre><p>linux / Mac</p><pre>python3 -m virtualenv env &gt;&gt; install virtual environment</pre><pre>source env/bin/activate  &gt;&gt; activate virtual environment</pre><p>2. After activate the virtual environment, lets install flask library:</p><pre>pip3 install flask</pre><p>3. Simple flask script, with this script you will see hello world on your browser when you run the application and browse localhost:5000 on your browser.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b419c302a338bf4d31a564cee5583fc6/href">https://medium.com/media/b419c302a338bf4d31a564cee5583fc6/href</a></iframe><p>4. Run flask code</p><p>Run direct with python. In this example my file name is run.py</p><pre>python3 run.py</pre><p>Or using flask command. First create a file .flaskenv and define your flask file FLASK_APP=your file name. With this flask will know what file to execute.</p><pre>FLASK_APP=run.py #run.py is you flask main script</pre><p>And to run your flask just type on your console:</p><pre>flask run <br>#this command will run your flask application and execute file that you define in FLASK_APP inside .flaskenv file</pre><p>Alright, That is it for chapter 1. You also can download the source code here :</p><p><a href="https://github.com/trvlprogrammer/flask_tutorial/tree/chapter_1">Github</a></p><p><a href="https://medium.com/@alfatihridhont/flask-chapter-2-blueprints-8542b4431ea7">Chapter 2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67b784c67116" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO IMPLEMENT ODOO PAYROLL]]></title>
            <link>https://medium.com/@alfatihridhont/how-to-implement-odoo-payroll-22ebbf1fb868?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/22ebbf1fb868</guid>
            <category><![CDATA[odoo-12]]></category>
            <category><![CDATA[payroll]]></category>
            <category><![CDATA[odoo-implementation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[odoo]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Sun, 12 Jan 2020 08:23:16 GMT</pubDate>
            <atom:updated>2020-01-12T08:23:16.537Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YcrTC6g60rySIOy19sX_Hg.png" /></figure><p>In this article i will show you how to implement payroll module. There are several step to implement this.</p><ol><li>Install Payroll Module.</li></ol><ul><li>Go to apps menu ,search payroll accounting and install. When installing payroll accounting it will automatically install payroll module and also invoicing module. If you just want payroll module without invoicing just install payroll module.</li></ul><p>2. Set Salary Rules.</p><ul><li>First go to Settings menu -&gt; Users &amp; Companies -&gt; select a user and give access to payroll menu as manager.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*uCOUD_kXapuUi-mAWgkebg.png" /><figcaption>Access payroll as manager.</figcaption></figure><ul><li>Go to Payroll menu -&gt; Configuration -&gt; Salary rules. Create new salary rules and define the rules.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6SoWFCzQ_o5y9Uo5XCDu1Q.png" /><figcaption>Salary rules form view.</figcaption></figure><p>As you can see in the form view, you need to fill some fields.</p><ul><li>Name : The salary rule name.</li><li>Category : Category for the salary rule (Allowance, Deduction, Gross, Net and etc)</li><li>Conditions : You can specify condition for the salary rules, but usually you can set it to true. It means the rules always be executed.</li><li>Computation : You can choose Fixed amount, Percentage or Python code. If you choose Fixed amount you can specify the quantity, for example you want the quantity of meal voucher based on how many days the employee’s working. See screenshot bellow.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6uuphbTBqKzGJNfoCHKpyw.png" /><figcaption>Salary Rules Fixed Amount.</figcaption></figure><p>For percentage you can specify percentage based on what component, for examlpe i will make percentage base on basic salary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWDOvrlBkIj4DU9KEVRfpA.png" /><figcaption>Salary Rules Percentage.</figcaption></figure><p>For python code you can use python code for computation and also you can use several object python that provided by odoo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*YfegZDMS4CdK8_qQPrygWQ.png" /><figcaption>Object that provided by odoo.</figcaption></figure><p>For example i want use basic salary from contract. I just need to browse the contract object and get the value from wage field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtY18jz7i471BlaofnuXqw.png" /><figcaption>Python code salary rules.</figcaption></figure><p>When you define a salary rule, you need to be carefull for the sequesnce, sequence is important in odoo payroll. When you define deduction category, make sure sequence for deduction category always greater than gross category and bellow net category. I know its lil bit confusing, but little practice will make you understand.</p><p>Contibution register : You can specify the contribution Register.</p><p>Accounting Tab : In this tab you can specify chart of account for the salary rules.</p><p>Input tab : If you want your salary rule have and input, you can define it here.</p><p>Child Rules Tab : You can give child rules for salary rules here.</p><p>3. Set Salary Structures.</p><ul><li>Go to Payroll Menu -&gt; Configuration -&gt; Salary Structures.</li><li>Create a new salary structue.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgagQ-9KXrYIlfRw5YcKRw.png" /><figcaption>Salary Structure.</figcaption></figure><p>For example i made marketing executive structure, for the parent structure i have base for new structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0eS6P9JrJD2PQnavZLHdeg.png" /><figcaption>Base for new structure.</figcaption></figure><p>In base for new structure i already define some rules like basic salary, gross and net. So whenever i want to create new structure i dont have to define basic, gross and net in salary rules, i just need to choose base for new structure as parent. After that i just need add some specific rules in salary rules tab.</p><p>4. Set employee’s Contract.</p><ul><li>Go to Employee menu -&gt; contract and create new contract for each employee, after created new contract change the state of contract to be running.</li><li>In contract you can specify salary wage, salary structure and etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NLVFobYVKEG7GIQ48RRkhQ.png" /><figcaption>Employee’s Contracts.</figcaption></figure><p>5. Generate Payslip.</p><ul><li>Go to Payroll menu, odoo has 2 ways to generate the payslip, you can generate single payslip or you can generate payslip per bacth(group). if you want to generate single payslip , go to payslip menu and create the payslip and specify the periode. After that click compute button, and you will see the computation in salary computation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5y_wC92Rd_IZOsi1i1eHkA.png" /><figcaption>Payslip.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwBMRWtgVbFrJzgY_GMfkw.png" /><figcaption>Computation Payslip.</figcaption></figure><p>If you want to generate group payslip (payslip batch), go to payslip batches menu. Create new payslip batch, click button generate paysllip and choose the employee.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TlBF6RJi5u2frwt00StZ3Q.png" /><figcaption>Payslip Batch.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5ZD3JNK9cQjuf2wJ_OCVQ.png" /><figcaption>Payslip Batch.</figcaption></figure><p>After finish compute the salary, you can confirm the salary and it will automatically create a new journal accounting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BE1p6N8zSbAG7gBPGpH4zQ.png" /><figcaption>Payslip.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JC0ZBRiA-mWTPzg7mmLAMA.png" /><figcaption>Journal Accounting.</figcaption></figure><p>Ok guys, that is it all, if you have some questions feel free to ask. I will answer it as soon as possible. Thank You for reading this article :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22ebbf1fb868" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO CREATE EMAIL TEMPLATE IN ODOO 12]]></title>
            <link>https://medium.com/@alfatihridhont/how-to-create-email-template-in-odoo-12-e126e52f9671?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e126e52f9671</guid>
            <category><![CDATA[odoo-development]]></category>
            <category><![CDATA[odoo-12]]></category>
            <category><![CDATA[odoo-customization]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[odoo]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Sat, 09 Nov 2019 11:43:20 GMT</pubDate>
            <atom:updated>2019-11-09T11:43:20.962Z</atom:updated>
            <content:encoded><![CDATA[<p>HOW TO CREATE EMAIL TEMPLATE IN ODOO 12</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YcrTC6g60rySIOy19sX_Hg.png" /></figure><p>Hey folks!! in this article i will show you how to create XML email template in odoo and parse the data from current record to the template using jinja2.</p><ol><li>Create new module “python odoo-bin scaffold yourmodulename”.</li><li>Give dependency, in this tutorial i will create email template for Employee. So i need to give depency to HR module.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*scYfnQwWiHM753xNg37XpA.png" /><figcaption>dependecy to HR module in __manifest__.py.</figcaption></figure><p>3. Create new XML file and paste file bellow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9edb478ea8f76399960ea98a53d679e5/href">https://medium.com/media/9edb478ea8f76399960ea98a53d679e5/href</a></iframe><p>Explanation for the code above :</p><ul><li>name : Name for the email template.</li><li>email_from : Show the email is sent from which email.</li><li>subject : The email subject.</li><li>partner_to : Partner email.</li><li>model_id : Define this template belongs to which model.</li><li>auto_delete : If this set to true, after odoo send this email it will delete the email. If false odoo will keep the email after sent it.</li><li>lang : Is to make sure to send this email with correct language.</li><li>body_html : Is the body email, you can use inline css to in this body email.</li></ul><p>By calling ${} jinja2 knows this part of XML should be parsed. So what is ${object} ? It means the object of this email, in this first step i defined this template email belongs to hr.employee object’s. So using ${object} you can browse data from hr.employee, like employee name ${object.name}, employee email ${object.work_email} and etc.</p><p>Install the module, enter to debug mode and go to Settings-&gt;email-&gt;templates and find the template that we created before. Click preview to see the email template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SZ_lJTTaL9hj1lEtBdAPtg.png" /><figcaption>Preview Email Template.</figcaption></figure><p>Ok guys, that is it. Easy right? Thanks for reading this article, have a great day :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e126e52f9671" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make your own custom snippets for website in odoo 11]]></title>
            <link>https://medium.com/@alfatihridhont/how-to-make-your-own-custom-snippets-for-website-in-odoo-11-bd48eccdd04d?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd48eccdd04d</guid>
            <category><![CDATA[odoo-implementation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[odoo-development]]></category>
            <category><![CDATA[odoo-customization]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Thu, 22 Aug 2019 01:54:21 GMT</pubDate>
            <atom:updated>2019-08-22T01:54:21.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wT2ZmjIu6hkUQKBi18e7Vg.png" /></figure><p>Hey folks, in this article i will show you how to make your own custom snippets for website, it&#39;s pretty simple, we just have to inherit the main template and define our own template. ok let&#39;s get started.</p><ol><li>Make new module, as always type on your terminal &quot;python odoo-bin scaffold website_snippets yourfolder/&quot;.</li><li>Create new file called snippets.xml inside our views folder, in this file we will define our snippets. In this tutorial i just make my snippets from bootstrap code. Things you have to know, first define your id template and then you html and css class template, see code below.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6c025f3a743215382e3d208d61ed352/href">https://medium.com/media/b6c025f3a743215382e3d208d61ed352/href</a></iframe><p>3. Create a new xml file inside our views folder to inherit the main template and call the snippets template that we made before, first inherit the main template, call our own snippets template and give thumbnail for the snippets template. See code bellow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9dd4f7e1d95c3777705ac205054e68f/href">https://medium.com/media/b9dd4f7e1d95c3777705ac205054e68f/href</a></iframe><p>3. Open your __manifest__.py file and add dependencies to website module and dont forget to call our 2 xml files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*X979pO4kyUQfYVhCY0xLpQ.png" /><figcaption>__manifest__.py</figcaption></figure><p>4. Install the module and go to website menu and click button go to website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*MrEWbhdjM5rfmYOEeJa8mQ.png" /><figcaption>Website menu.</figcaption></figure><p>5. In website view click edit and you can see the new snippets that we made before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*E5gNBxzozqSG-QnoMwdMMA.png" /><figcaption>Edit website.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wT2ZmjIu6hkUQKBi18e7Vg.png" /><figcaption>The new snippets.</figcaption></figure><p>That is it all guys, pretty simple right? thank you for reading this article, have a nice day :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd48eccdd04d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO MAKE CUSTOM REPORT IN ODOO 11]]></title>
            <link>https://medium.com/@alfatihridhont/how-to-make-custom-report-in-odoo-11-3fcc6d9873ba?source=rss-2eac5403880e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fcc6d9873ba</guid>
            <category><![CDATA[openerp]]></category>
            <category><![CDATA[odoo-customization]]></category>
            <category><![CDATA[odoo]]></category>
            <category><![CDATA[odoo-implementation]]></category>
            <category><![CDATA[odoo-development]]></category>
            <dc:creator><![CDATA[Alfatih Ridho NT]]></dc:creator>
            <pubDate>Tue, 23 Jul 2019 02:14:12 GMT</pubDate>
            <atom:updated>2019-07-23T02:14:12.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*twX9X2HM-BJ8l1frCf5HMg.png" /></figure><p>Hey folks! in this article i will show you how to make custom report in odoo 11. it&#39;s pretty easy to make your own report. For example i will make new module that inherit to module project, so we will make report for task.</p><ol><li>Create new module &quot;python odoo-bin scaffold yourmodulename /yourdirectory&quot;, for me i will make it “python odoo-bin scaffold task_report /addons”</li><li>Create new xml file inside views folder, for example report_project_task.xml .</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/305e079e14872cde100fe0bbfa23a97c/href">https://medium.com/media/305e079e14872cde100fe0bbfa23a97c/href</a></iframe><p>As you can see code above,</p><ul><li>First, we have to define unique id template.</li><li>Second, call report template web.html_container.</li><li>Third, define iteration for docs(model_object).</li><li>Fourth, call template web.external_layout.</li><li>After that you can do your own things.</li></ul><p>3. Create new file inside views folder, for example task_report_view.xml and the name of the file has to start with your_module_name_. In this file we will define about the report that we created before. This file responsible to tell system that we have new report and where to put the report, report name, file name and etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b84817b2632bd18e64015f55efc788c/href">https://medium.com/media/7b84817b2632bd18e64015f55efc788c/href</a></iframe><p>as you can see at code above, define the model for this report, report type, report name, and report name file.</p><p>4. Adding dependency, and define your new xml file in your __manifest__.py file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*ajjf-82AGuzJqORO3vISkg.png" /><figcaption>__manifest__.py</figcaption></figure><p>5. Install/Upgrade your module and you can see the report at the form task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*VQyKIzVeTTGrYrApM5vUWQ.png" /><figcaption>Task form view.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*9QL0RaijdqkzWMYYHN7JSA.png" /><figcaption>Result report.</figcaption></figure><p>Ok guys, that is it all, pretty easy right? Thank you for reading this article, have a nice day :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fcc6d9873ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>