Skip to content

Instantly share code, notes, and snippets.

View 3mrdev's full-sized avatar
👨‍💻
Messing things up

Amr Abd-Alkrim 3mrdev

👨‍💻
Messing things up
View GitHub Profile
@3mrdev
3mrdev / odoo-server
Created June 8, 2022 18:41
Odoo background service example for Ubuntu Linux. Put it in /etc/init.d path
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enterprise Business Applications
# Description: ODOO Business Applications
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/odoo/odoo-server/odoo-bin
NAME=odoo-server
DESC=odoo-server
@3mrdev
3mrdev / config.php
Created June 9, 2022 00:08
Odoo XMLRPC Example using PHP
<?php
// like import file
require_once('lib/ripcord.php');
// define variables to use in future
$url = "http://localhost:8015";
$db = "o14_api";
$username = "admin";
$password = "admin";
@3mrdev
3mrdev / component.js
Created June 9, 2022 00:25
Odoo OWL Component Example + Owl Component Inheritance (Patching Owl Components)
odoo.define('my.component', function (require) {
"use strict";
const { Component, useState } = owl;
const { xml } = owl.tags;
const { patch } = require('web.utils');
// import { patch } from "@web/core/utils/patch";
class MyComponent extends Component {
@3mrdev
3mrdev / view_inherit.xml
Created June 9, 2022 16:36
Odoo view inheritance through XPath
<record id="your_model_view_form_firebits" model="ir.ui.view">
<field name="name">your_model.view.form.inherit.firebits</field>
<field name="model">your_model</field>
<field name="priority" eval="25"/>
<field name="inherit_id" ref="your_model_view_external_id"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('your_class')]" position="inside">
# your field
</xpath>
</field>
@3mrdev
3mrdev / list_view_button.js
Last active June 11, 2022 06:59
Add a new button in top of the list view in Odoo when clicked it will call a method in your model
odoo.define('your_module.new_button', function (require) {
"use strict";
/**
* Button 'Create' is replaced by Custom Button
**/
var core = require('web.core');
var ListController = require('web.ListController');
ListController.include({
renderButtons: function($node) {
@3mrdev
3mrdev / index.html
Created July 23, 2022 13:38
FireBits Odoo app store description template
<section class="oe_container oe_dark">
<div class="col-md-12">
<h2 class="oe_slogan" style="font-size: 35px;color:#781E4F"><b>Odoo 15</b></h2>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
@3mrdev
3mrdev / utils.py
Last active August 13, 2022 15:59
Controller to expose Odoo binary data to readable files extensions to be displayed on browsers and executed by urls in web page (Images/Audio/PDFs..etc)
# -*- coding: utf-8 -*-
import json
import logging
import base64
from odoo import http, tools, _
from odoo.http import request
_logger = logging.getLogger(__name__)
class UtilsApi(http.Controller):
@3mrdev
3mrdev / score.py
Created September 21, 2022 19:57
Get Top Users By Country Odoo (work in progress)
# Import required modules
from lxml import html
import requests
import json
class Utils():
cookies = {'session_id': ''}
def getUsers(self):
@3mrdev
3mrdev / account_move.py
Created October 8, 2022 13:43
How to create an invoice from any model in Odoo
def create_invoice(self):
move_dict = {
'narration': "Name",
'ref': name,
'journal_id': journal_id.id,
'date': date,
}
line_ids = []
@3mrdev
3mrdev / sequence.py
Created October 8, 2022 16:25
How to make odoo sequence ?
class your_model_class_name (models.Model):
_name = "your_model_name"
@api.model
def create(self, vals):
if vals.get('seq', 'New') == 'New':
vals['seq'] = self.env['ir.sequence'].next_by_code('example.seq') or '/'
newId = super(your_model_class_name, self).create(vals)
return newId