Skip to content

Instantly share code, notes, and snippets.

View josemoralesp's full-sized avatar

Jose Antonio Morales Ponce josemoralesp

View GitHub Profile
WITH payments AS(
SELECT
p.id,
p.name,
p.payment_date,
p.payment_type,
p.partner_type,
s.name AS partner,
p.currency_id,
p.amount,
SELECT
i.id,
i.number,
att1.datas_fname,
att1.store_fname
FROM
account_invoice AS i
JOIN
ir_attachment AS att1 ON (i.id = att1.res_id AND att1.res_model = 'account.invoice' AND att1.l10n_mx_edi_uuid IS NOT NULL)
LEFT OUTER JOIN
Payment = env['account.payment']
payments = []
for record in records.filtered(lambda a: a.state == 'open'):
payment = Payment.search([('communication', '=', record.l10n_mx_edi_cfdi_uuid)])
if payment:
payments.append((payment.id, payment.name, record.number))
raise Warning('%s' % payments)
WITH a AS (
SELECT
aml.payment_id,
aml.id,
aml.debit::numeric(12,2),
aml.credit::numeric(12,2),
aml.amount_currency::numeric(12,2)
FROM account_move_line aml
INNER JOIN account_account aa ON aa.id = aml.account_id
INNER JOIN account_account_type aat ON aat.id = aa.user_type_id AND aat.type = 'receivable'
DROP FUNCTION IF EXISTS float_round(amount float, rounding float, rounding_method varchar);
CREATE OR REPLACE FUNCTION float_round(amount float, rounding float, rounding_method varchar)
RETURNS float AS $$
DECLARE
normalized_value float;
epsilon_magnitude float;
epsilon float;
rounded_value float;
sign float;
BEGIN
SELECT DISTINCT
so.name,
p.name,
pt.name,
acc.name,
aml.credit,
aml.debit,
c.name,
aml.date
FROM
WITH 90s AS (
SELECT
s.amz_instance_id, ap.id as id, %s as period,
SUM(sl.product_uom_qty) qty, SUM(sl.price_subtotal) amount
FROM sale_order_line sl
JOIN sale_order s ON
sl.order_id = s.id AND s.date_order >= %s
AND s.amz_instance_id in %s
JOIN amazon_product_ept ap ON
ap.instance_id = s.amz_instance_id AND
qty_available = env['stock.quant']._get_available_quantity(record.product_id, record.location_id)
if qty_available:
qty_needed = record.product_uom._compute_quantity(record.product_uom_qty, record.product_id.uom_id)
real_qty = record.product_id.uom_id._compute_quantity(qty_available, record.product_uom)
if qty_needed > qty_available:
new_move = record.copy({'ordered_qty': real_qty, 'product_uom_qty': real_qty, 'state': 'confirmed', 'procure_method': 'make_to_stock', 'created_purchase_line_id': False, 'picking_id': record.picking_id.id})
#raise Warning('%s' % record.picking_id.name)
remaining = record.product_uom_qty - real_qty
record.write({'ordered_qty': remaining, 'product_uom_qty': remaining})
# -*- coding: utf-8 -*-
import logging
from odoo import SUPERUSER_ID, api
_logger = logging.getLogger(__name__)
def remove_website(cr):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
WITH partner_move AS (
SELECT
p.partner_id,
m.id
FROM
stock_move AS m
INNER JOIN
purchase_order_line AS pl ON pl.id=m.purchase_line_id
INNER JOIN
purchase_order AS p ON p.id=pl.order_id