<commit_before>from odoo import api, fields, models, _, exceptions
import base64
from datetime import datetime
import xlsxwriter


class ProductProduct(models.Model):
    _inherit = 'product.product'

    def cron_stock_catalog(self):
        headers = ["ID", "Proveedor principal", "Referencia interna", "Fabricando", "Entrante", "Stock cocina",
                   "Stock real", "Stock disponible", "Ventas en los últimos 60 días con stock",
                   "Cant. pedido más grande", "Días de stock restantes", "Stock en playa",
                   "Media de margen de últimas ventas", "Cost Price", "Último precio de compra",
                   "Última fecha de compra", "Reemplazado por", "Estado"]

        domain = [('custom', '=', False), ('type', '!=', 'service'), ('seller_id.name', 'not ilike', 'outlet')]

        fields = ["id", "seller_id", "code", "qty_in_production", "incoming_qty", "qty_available_wo_wh",
                  "qty_available", "virtual_stock_conservative", "last_sixty_days_sales", "biggest_sale_qty",
                  "remaining_days_sale", "qty_available_input_loc", "average_margin",
                  "standard_price", "last_purchase_price", "last_purchase_date", "replacement_id", "state"]
        rows = []
        translate_state = {"draft": "En desarrollo", "sellable": "Normal", "end": "Fin del ciclo de vida",
                           "obsolete": "Obsoleto", "make_to_order": "Bajo pedido"}

        products = self.env['product.product'].search_read(domain, fields)
        for product in products:
            product_fields = []
            for field in fields:
                if product[field] is False:
                    product_fields.append("")
                elif field in ('seller_id', 'replacement_id'):
                    product_fields.append(product[field][1])
                elif field == 'state':
                    product_fields.append(translate_state[product[field]])
                elif field == 'average_margin':
                    product_fields.append(round(product[field], 2))
                else:
                    product_fields.append(product[field])
            rows.append(product_fields)

        file_b64 = self.generate_xls(headers, rows)
        self.send_email(file_b64, "stock_diary",
                        "stock_catalog_{}.xlsx"
                        .format(datetime.now().strftime('%m%d')),
                        "cron_stock_catalog.email_template_purchase_stock_catalog")

    def cron_product_valuation(self, to_date=False):
        headers = ["ID", "Nombre del Producto", "Marca", "Categoria", "Proveedores", "Cantidad", "Valor"]
<commit_msg>[IMP] cron_stock_catalog: cambiado campos en el informe<commit_after>from odoo import api, fields, models, _, exceptions
import base64
from datetime import datetime
import xlsxwriter


class ProductProduct(models.Model):
    _inherit = 'product.product'

    def cron_stock_catalog(self):
        headers = ["ID", "Último Proveedor", "Referencia interna", "Fabricando", "Entrante", "Stock cocina",
                   "Stock real", "Stock disponible", "Ventas en los últimos 60 días con stock",
                   "Cant. pedido más grande", "Días de stock restantes", "Stock en playa",
                   "Media de margen de últimas ventas", "Cost Price", "Último precio de compra",
                   "Última fecha de compra", "Reemplazado por", "Estado"]

        domain = [('custom', '=', False), ('type', '!=', 'service'), ('seller_id.name', 'not ilike', 'outlet')]

        fields = ["id", "last_supplier_id", "code", "qty_in_production", "incoming_qty", "qty_available_wo_wh",
                  "qty_available", "virtual_stock_conservative", "last_sixty_days_sales", "biggest_sale_qty",
                  "remaining_days_sale", "qty_available_input_loc", "average_margin",
                  "standard_price", "last_purchase_price", "last_purchase_date", "replacement_id", "state"]
        rows = []
        translate_state = {"draft": "En desarrollo", "sellable": "Normal", "end": "Fin del ciclo de vida",
                           "obsolete": "Obsoleto", "make_to_order": "Bajo pedido"}

        products = self.env['product.product'].search_read(domain, fields + ["seller_id"])
        for product in products:
            product_fields = []
            for field in fields:
                if product[field] is False:
                    if field != "last_supplier_id" or product["seller_id"] is False:
                        product_fields.append("")
                    else:
                        product_fields.append(product["seller_id"][1])
                elif field in ('last_supplier_id', 'replacement_id'):
                    product_fields.append(product[field][1])
                elif field == 'state':
                    product_fields.append(translate_state[product[field]])
                elif field == 'average_margin':
                    product_fields.append(round(product[field], 2))
                else:
                    product_fields.append(product[field])
            rows.append(product_fields)

        file_b64 = self.generate_xls(headers, rows)
        self.send_email(file_b64, "stock_diary",
                        "stock_catalog_{}.xlsx"
                        .format(datetime.now().strftime('%m%d')),
                        "cron_stock_catalog.email_template_purchase_stock_catalog")

    def cron_product_valuation(self, to_date=False):
        headers = ["ID", "Nombre del Producto", "Marca", "Categoria", "Proveedores", "Cantidad", "Valor"]

{'fraction_non_alphanumeric': 0.1267351721651343, 'fraction_numerical': 0.0037858301784748512, 'mean_word_length': 2.463171036204744, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1365283', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1580, 'n_words': 366}