sudo apt install git wget nodejs npm python3 build-essential libzip-dev python3-dev libxslt1-dev python3-pip libldap2-dev python3-wheel libsasl2-dev python3-venv python3-setuptools node-less libjpeg-dev xfonts-75dpi xfonts-base libpq-dev libffi-dev fontconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libraries | |
import os | |
# Define function to detect GPU | |
def detect_gpu(): | |
# Use lspci command to list PCI devices | |
result = os.popen("lspci | grep -i 'vga\|3d\|2d'").read() | |
# Extract GPU information from lspci output | |
if result: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Custom decorator | |
def check_origin_and_token(func): | |
@functools.wraps(func) | |
def secure_func(self, **kwargs): | |
headers = http.request.httprequest.headers | |
origin = '{}://{}'.format(headers.environ['wsgi.url_scheme'], headers['Host']) | |
_logger.info('New request from Origin:{}'.format(origin)) | |
if 'X-Token' not in headers: | |
_logger.error('X-Token not found in headers') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [4, 5, [6, [8, 9]], 10] | |
arr2 = [] | |
def do_array(a, b): | |
print(a) | |
for i in a: | |
if(isinstance(i, list)): | |
do_array(i, b) | |
else: | |
b.append(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductTemplateKit(models.Model): | |
_inherit = 'product.template' | |
international_code = fields.Char('Codigo Internacional') | |
is_kit = fields.Boolean( | |
string='Es kit', | |
default=False) | |
product_combo_ids = fields.One2many('product.combo', 'product_parent_id', 'Combo de productos') | |
class ProductCombo(models.Model): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This came up with a huge problem for days, but i resolve it. | |
# The main problem is the limitation in form in odoo. Mostly of this are not in the official documentation, | |
# so maybe you will feel a bit blind sometimes, but I feel you bro. | |
# Basically works for partner_id relation for many2one | |
# PART ONE | |
# Create a class res_partner.py | |
class ResPartner(models.Model): | |
"""This part is the easy part, @api.model overrides to name_get (optional) and name_search.""" | |
_inherit = 'res.partner' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Dynamic size in account_invoice report | |
Just send the account_invoice_line_id take the len() and multiply it with 7 (millimeters) | |
This example is simulating the paper of a supermarket invoice, the default size in my country is 24 millimeters for a correct | |
format, but you can change it! | |
How it works: You need pass this method inside the qweb report sending the lines. | |
""" | |
#Qweb | |
<t t-esc="o.change_size_page(o.lines)"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<openerp> | |
<data> | |
<!-- Vista de formulario --> | |
<record model="ir.ui.view" id="contadesk_fv_factura_form"> | |
<field name="name">Virtual Invoice</field> | |
<field name="model">contadesk.factura.virtual</field> | |
<field name="type">form</field> | |
<field name="arch" type="xml"> | |
<form string="Virtual Invoice" version="7.0" create="0"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sudoku; | |
import java.util.LinkedList; | |
public class Sudoku { | |
public void DoSudoku(int [][] board, int row, int column) { | |
if(isFinish(board)){showBoard(board); return;} | |
if(row >= board.length) return; | |
if(column >= board[row].length){ |
NewerOlder