Skip to content

Instantly share code, notes, and snippets.

View drkpkg's full-sized avatar
🏠
Working from home

Felix Daniel Coca Calvimontes drkpkg

🏠
Working from home
View GitHub Profile
@drkpkg
drkpkg / city_state_example.rb
Created August 19, 2016 00:41
Ejemplo de como hacer consultas Json por paises, ciudades y estados.
def countries
#Obtiene todos los países para ser listados
render json: CS.countries
end
def cities
#Obtiene las ciudades por un estado y un país
render json: CS.cities(params[:state], params[:country])
end
@drkpkg
drkpkg / caesar.py
Created August 23, 2016 16:02
Cifrado cesar, bastante viejo supongo :P
#!/usr/bin/python2
import sys
def main(argv):
if (len(sys.argv) != 2):
sys.exit('Uso: caesar.py <entero>')
plaintext = list(raw_input('Mensage: '))
alphabet = list('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
@drkpkg
drkpkg / collatz.py
Last active September 12, 2016 17:05
Conjetura de collatz
class Collatz(object):
def __init__(self):
self.numbers = []
self.ways = 1
def solve(self, number):
self.numbers.clear()
self.ways = 0
def equilateral(a,b,c)
if(((a-b)+(b-c)+(a-c))==0)
return true
end
return false
end
def isoceles(a,b,c)
if(((a-b)+(b-c))==0 or ((a-b)+(a-c))==0)
return true
@drkpkg
drkpkg / test.js
Last active January 10, 2017 19:18
AHHHHH
//todo-spec.js
describe('4chin page', function() {
it('click in image', function() {
browser.ignoreSynchronization = true; // Non angular page
browser.driver.manage().window().maximize();
browser.get('http://boards.4chan.org/wg/thread/6813282/like-this');
var list = element.all(by.css('.fileThumb'));
list.each(function(elem){
elem.click();
@drkpkg
drkpkg / Sudoku.java
Last active May 12, 2017 00:32
Sudoku class
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){
<?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">
@drkpkg
drkpkg / size.py
Last active August 26, 2023 13:59
Dynamic size report invoice odoo
"""
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 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'
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):