Skip to content

Instantly share code, notes, and snippets.

@umiphos
umiphos / WSDL_bad_zeep_error.py
Created March 2, 2019 22:46
This is a current error we have when we consult the SUNAT service without propper logging, the error replicates if we try to consume the WSDL without WSSE
from zeep import Client, Settings
from zeep.plugins import HistoryPlugin
from zeep.wsse.username import UsernameToken
settings = Settings(strict=False, xml_huge_tree=True)
history = HistoryPlugin()
client = Client(wsdl='https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService?wsdl',
wsse=UsernameToken('MODDATOS','MODDATOS'), settings=settings, plugins=[history])
@umiphos
umiphos / nullification_of_an_invoice.py
Last active April 22, 2019 21:58
Forced cancellation of an invoice in odoo via server action
for rec in records:
move_id = rec.move_id
# move_id.line_ids.remove_move_reconcile()
update_posted_state = rec.journal_id.update_posted
rec.journal_id.write({'update_posted': True})
# move_id.button_cancel()
# This action will delete any move_id that we have
rec.action_cancel()
rec.write({'state': 'cancel'})
@umiphos
umiphos / odoo_download_file.py
Created March 25, 2019 23:00 — forked from yasmanycastillo/odoo_download_file.py
Odoo: How to download a file immediately from wizard
# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
from odoo.addons.web.controllers.main import serialize_exception,content_disposition
import base64
class Binary(http.Controller):
@http.route('/web/binary/download_document', type='http', auth="public")
@umiphos
umiphos / replacer.sh
Created April 3, 2019 00:04
Used when we need to change a variable name with sh in a LOT of files at once
#!/bin/sh
grep -rl --exclude-dir=.git $1 |xargs sed -i 's/'$1'/'$2'/g'
@umiphos
umiphos / spotify_keybindings
Created April 8, 2019 16:32 — forked from jbonney/spotify_keybindings
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
Archivo replacer
https://gist.github.com/umiphos/54658fafa9d70d9f58363a5bb96fe208
./replacer.sh "account\.invoice" "account\.move"
./replacer.sh "AccountInvoice" "AccountMove"
Esto se queda tal cual
account.group_account_invoice
<cac:TaxCategory>
<cbc:ID schemeID="UN/ECE 5305" schemeName="Tax Category Identifier" schemeAgencyName="United Nations Economic Commission for Europe">S</cbc:ID>
<cac:TaxScheme>
<cbc:ID>1000</cbc:ID>
<cbc:Name>IGV</cbc:Name>
</cac:TaxScheme>
</cac:TaxCategory>
@umiphos
umiphos / XML_with_error.xml
Last active August 19, 2019 04:43
XML con error, demostrando diferencias
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
<u:Timestamp u:Id="_0">
<u:Created>2019-08-19T04:18:21.605Z</u:Created>
<u:Expires>2019-08-19T04:23:21.605Z</u:Expires>
</u:Timestamp>
</o:Security>
</s:Header>
@umiphos
umiphos / IGV.xml
Last active May 30, 2022 09:05
XML Generados
<?xml version="1.0" encoding="ISO-8859-1"?>
<Invoice xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent>
<ds:Signature Id="SignVX">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
@umiphos
umiphos / getStatus(status=0).xml
Last active October 25, 2019 21:10
getStatus
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
<u:Timestamp u:Id="_0">
<u:Created>2019-10-25T15:43:25.305Z</u:Created>
<u:Expires>2019-10-25T15:48:25.305Z</u:Expires>
</u:Timestamp>
</o:Security>
</s:Header>