Skip to content

Instantly share code, notes, and snippets.

View altela's full-sized avatar

Altela Eleviansyah Pramardhika altela

View GitHub Profile
version: '3.3'
services:
# Web Application Service Definition
# --------
#
# All of the information needed to start up an odoo web
# application container.
web:
image: odoo:12.0
@altela
altela / odoo.conf
Created July 29, 2023 14:28
Odoo 16 Docker Config
[options]
addons_path = /mnt/extra-addons
db_user = odoo
db_password = odoo
logfile = /etc/odoo/odoo-server.log
@altela
altela / docker-compose-16.yml
Created July 29, 2023 14:18
Odoo 16 Docker Compose
version: '3.3'
services:
# Web Application Service Definition
# --------
#
# All of the information needed to start up an odoo web
# application container.
web:
image: odoo:16
@altela
altela / sequence_create.py
Created May 7, 2022 03:31
Odoo Create Sequence Number Generator
# First you need to define a create method for the sequence number
class ExampleClass(models.Model):
_rec_name = 'sequence_number'
@api.model
def create(self, vals):
if vals.get('sequence_number', 'New') == 'New':
vals['sequence_number'] = self.env['ir.sequence'].next_by_code('mysequence.model') or 'New'
result = super(ExampleClass, self).create(vals)
return result
@altela
altela / stock_quant_create.py
Created May 7, 2022 03:01
Odoo Create Stock Quant
# this block will create a stock_quant
# stock_quant is an on hand quantity inside certain location
create_quant = self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product_id.id,
'location_id': self.location_destination.id,
'quantity': 0,
})
@altela
altela / stock_move_create.py
Last active May 7, 2022 03:01
Odoo Create Stock Move
# this block will create a stock move
# its recommended to put this inside a button method that checking availability
# ._action_confirm() will make this stock_move state to be confirmed
# ._action_assign() will assign this stock_move and reserve the available stock
stock_move = self.env['stock.move'].create({
'name': 'stock_move_name',
'location_id': self.location_source.id,
'location_dest_id': self.location_destination.id,
'product_id': self.product.id,
@altela
altela / orm_search.py
Last active June 23, 2023 14:08
Odoo ORM .search
# .search usability is to find object inside a model
# this block below means "search product_id with value 5 inside sale_order table"
# in postgresql query this ORM block equal to "SELECT * FROM sale_order_lines WHERE product_id = 5"
# then show all result using FOR iteration, preventing singleton error
for result in self.env['sale.order.lines'].search([('product_id', '=', 5)]):
product_id = int(result.product_id) # Get result.product_id and assign in to product_id inside current class
price_unit = int(result.price_unit) # Get result.price_unit and assign in to price_unit inside current class
print(product_id)
print(price_unit)
@altela
altela / dictionary_with_list.py
Last active May 7, 2022 02:34
Find Record in Dictionary Using a List
lower_case = "thequickfoxjumpedoverthelazydog"
# Created a new dictionary
lexicon = {
"a": "61",
"b": "62",
"c": "63",
"d": "64",
"e": "65",
"f": "66",
@altela
altela / for_iteration.py
Last active May 7, 2022 02:18
Python FOR Iteration tricks
# Add character inside list
list_numbers = ['001','002','003']
add_percent = [pulled + "%" for pulled in list_numbers]
print(add_percent)
# The result will be ['001%','002%','003%']
# Split each words with space
# Example 1
the_string = 'silly walks'
for ix in range(len(the_string)):
@altela
altela / query_check_odoo_version.sql
Last active May 7, 2022 03:04
Check Odoo Version from SQL
/* Check odoo version from sql : */
SELECT latest_version FROM ir_module_module WHERE name = 'base';
/* Check module license wheter it's Community or Enterprise ver " */
SELECT license, count(*) FROM ir_module_module where state = 'installed' group by license;