report sale square box global

This commit is contained in:
wilson gomez 2021-09-16 17:34:17 -05:00
parent d8768b613e
commit 67eb94f8aa
5 changed files with 267 additions and 198 deletions

View File

@ -27,5 +27,8 @@ def register():
agent.Agent,
module='sale_pos_frontend_rest', type_='model')
Pool.register(
sale.SaleForceDraft,
sale.SaleSquareBoxGlobal,
module='sale_pos_frontend_rest', type_='wizard')
Pool.register(
sale.SaleSquareBoxGlobalReport,
module='sale_pos_frontend_rest', type_='report')

View File

@ -2,19 +2,6 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:sale.sale:"
msgid "Error: %s"
msgstr "Error: %s"
msgctxt "error:sale.sale:"
msgid "The product '%(product)s' has no production bom"
msgstr "El producto '%(product)s' no tiene lista de materiales"
#, fuzzy
msgctxt "error:sale_pos.force_draft:"
msgid "The electronic invoice already exist!"
msgstr "La factura electronica ya existe!"
msgctxt "field:party.consumer,address:"
msgid "Address"
msgstr "Dirección de la Tienda"
@ -23,18 +10,6 @@ msgctxt "field:party.consumer,birthday:"
msgid "Birthday"
msgstr "Fecha de Nacimiento"
msgctxt "field:party.consumer,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
msgctxt "field:party.consumer,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgctxt "field:party.consumer,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:party.consumer,id_number:"
msgid "Id Number"
msgstr "Número Id"
@ -43,114 +18,55 @@ msgctxt "field:party.consumer,name:"
msgid "Name"
msgstr "Nombre del registro"
#, fuzzy
msgctxt "field:party.consumer,notes:"
msgid "Notes"
msgstr "Observaciones"
msgctxt "field:party.consumer,party:"
msgid "Party"
msgstr "Terceros"
msgctxt "field:party.consumer,phone:"
msgid "Phone"
msgstr "Teléfono"
msgctxt "field:party.consumer,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
msgctxt "field:product.product,id_reference:"
msgid "ID Reference Api"
msgstr ""
msgctxt "field:party.consumer,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
msgctxt "field:product.product,products_mix:"
msgid "Mix"
msgstr ""
msgctxt "field:party.consumer,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
#, fuzzy
msgctxt "field:product.product-mix.option,option:"
msgid "Product"
msgstr "Productos"
msgctxt "field:sale.delivery_men,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
msgctxt "field:sale.delivery_men,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgctxt "field:sale.delivery_men,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:sale.delivery_men,number_plate:"
msgid "Number Plate"
msgstr "Número de placa"
msgctxt "field:sale.delivery_men,party:"
msgid "Party"
msgstr "Terceros"
msgctxt "field:sale.delivery_men,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
msgctxt "field:sale.delivery_men,type_vehicle:"
msgid "Type Vehicle"
msgstr "Tipo de vehículo"
msgctxt "field:sale.delivery_men,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
msgctxt "field:sale.delivery_men,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:product.product-mix.option,product:"
msgid "Product"
msgstr "Producto"
msgctxt "field:sale.line,production:"
msgid "Production"
msgstr "Producciones"
msgctxt "field:sale.reservation,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
msgctxt "field:sale.reservation,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgctxt "field:sale.reservation,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:sale.reservation,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
msgctxt "field:sale.reservation,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
msgctxt "field:sale.reservation,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:sale.sale,consumer:"
msgid "Consumer"
msgstr ""
msgctxt "field:sale.sale,delivery_men:"
msgid "Delivery Men"
msgstr "Domiciliario"
msgctxt "field:sale.sale,delivery_time:"
msgid "Delivery Time (Min)"
msgstr "Tiempo de Entrega"
msgctxt "field:sale.sale,delivery_way:"
msgid "Delivery Way"
msgstr "Forma de Entrega"
#, fuzzy
msgctxt "field:sale.sale,kind:"
msgid "Kind Order"
msgstr "Clase"
msgctxt "field:sale.sale,pick_up_time:"
msgid "Pick Up Time"
msgstr "Hora de recogida"
msgctxt "field:sale.sale,order_status:"
msgid "Order Status"
msgstr ""
msgctxt "field:sale.sale,production_moves:"
msgid "Production Moves"
msgstr ""
msgctxt "field:sale.sale,productions:"
msgid "Productions"
@ -164,6 +80,21 @@ msgctxt "field:sale.sale,table_assigned:"
msgid "Table Assigned"
msgstr "Mesa Asignada"
#, fuzzy
msgctxt "field:sale.sale,waiting_time:"
msgid "Shipping Time"
msgstr "Hora de Envío"
#, fuzzy
msgctxt "field:sale.sale-stock.move,move:"
msgid "Stock Move"
msgstr "Movimiento de existencias"
#, fuzzy
msgctxt "field:sale.sale-stock.move,sale:"
msgid "Sale"
msgstr "Venta"
msgctxt "field:sale.shop,delivery_man:"
msgid "Delivery Man"
msgstr "Domiciliario"
@ -172,38 +103,6 @@ msgctxt "field:sale.shop,tables:"
msgid "Tables"
msgstr "Mesas"
msgctxt "field:sale.shop.delivery_men,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
msgctxt "field:sale.shop.delivery_men,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgctxt "field:sale.shop.delivery_men,delivery_men:"
msgid "Delivery Men"
msgstr "Domiciliario"
msgctxt "field:sale.shop.delivery_men,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:sale.shop.delivery_men,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
msgctxt "field:sale.shop.delivery_men,shop:"
msgid "Shop"
msgstr "Tienda"
msgctxt "field:sale.shop.delivery_men,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
msgctxt "field:sale.shop.delivery_men,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:sale.shop.table,active:"
msgid "Active"
msgstr "Activo"
@ -212,27 +111,10 @@ msgctxt "field:sale.shop.table,capacity:"
msgid "Capacity"
msgstr ""
msgctxt "field:sale.shop.table,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
msgctxt "field:sale.shop.table,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgctxt "field:sale.shop.table,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:sale.shop.table,name:"
msgid "Table Name"
msgstr "Nombre de la Mesa"
msgctxt "field:sale.shop.table,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
#, fuzzy
msgctxt "field:sale.shop.table,sale:"
msgid "Sale"
msgstr "Venta"
@ -245,18 +127,15 @@ msgctxt "field:sale.shop.table,state:"
msgid "State"
msgstr "Estado"
msgctxt "field:sale.shop.table,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
msgctxt "field:sale.shop.table,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "help:sale.sale,delivery_time:"
msgid "In Minutes"
msgstr "En Minutos"
#, fuzzy
msgctxt "help:sale.sale,waiting_time:"
msgid "In Minutes"
msgstr "En Minutos"
msgctxt "model:ir.action,name:"
msgid "Delivery Men"
msgstr "Domiciliario"
@ -265,6 +144,14 @@ msgctxt "model:ir.action,name:act_party_consumer"
msgid "Consumers"
msgstr "Consumidores"
msgctxt "model:ir.action,name:report_sale_square_box_global"
msgid "Report Square Box Global Daily"
msgstr "Cuadre de Caja Global"
msgctxt "model:ir.action,name:wizard_print_sale_square_box_global"
msgid "Sale Square Box Global Report"
msgstr "Cuadre de Caja Global"
msgctxt "model:ir.ui.menu,name:"
msgid "Delivery Men"
msgstr "Domiciliario"
@ -273,59 +160,86 @@ msgctxt "model:ir.ui.menu,name:menu_party_consumer"
msgid "Consumers"
msgstr "Consumidores"
msgctxt "model:ir.ui.menu,name:menu_sale_square_box_global"
msgid "Sale Square Box Global Report"
msgstr "Cuadre de Caja Global"
msgctxt "model:party.consumer,name:"
msgid "Party Consumer"
msgstr "Consumidor"
msgctxt "model:sale.delivery_men,name:"
msgid "Sale Delivery Men"
msgstr "Domiciliario"
msgctxt "model:product.product-mix.option,name:"
msgid "Product Mix Option"
msgstr ""
msgctxt "model:sale.reservation,name:"
msgid "Sale Reservation"
msgstr "Reservación"
msgctxt "model:sale.shop.delivery_men,name:"
msgid "Sale Shop - Delivery Men"
msgstr "Domiciliarios"
msgctxt "model:sale.sale-stock.move,name:"
msgid "Sale - Stock Move"
msgstr ""
msgctxt "model:sale.shop.table,name:"
msgid "Sale Shop Table"
msgstr "Mesas"
#, fuzzy
msgctxt "selection:sale.delivery_men,type_vehicle:"
msgctxt "selection:sale.sale,kind:"
msgid ""
msgstr "Punto de Orden"
msgctxt "selection:sale.delivery_men,type_vehicle:"
msgid "Bicycle"
msgstr "Bicicleta"
msgctxt "selection:sale.delivery_men,type_vehicle:"
msgid "Car"
msgstr "Carro"
msgctxt "selection:sale.delivery_men,type_vehicle:"
msgid "Motorcycle"
msgstr "Motocicleta"
#, fuzzy
msgctxt "selection:sale.sale,delivery_way:"
msgctxt "selection:sale.sale,kind:"
msgid "Delivery"
msgstr "Envío"
#, fuzzy
msgctxt "selection:sale.sale,kind:"
msgid "Take Away"
msgstr "Para Llevar"
msgctxt "selection:sale.sale,kind:"
msgid "To Table"
msgstr "A la Mesa"
#, fuzzy
msgctxt "selection:sale.sale,order_status:"
msgid ""
msgstr "Punto de Orden"
msgctxt "selection:sale.sale,delivery_way:"
msgid "Delivery"
msgstr "Domicilio"
#, fuzzy
msgctxt "selection:sale.sale,order_status:"
msgid "Cancelled"
msgstr "Cancelado"
msgctxt "selection:sale.sale,delivery_way:"
msgid "Table"
msgstr "Mesa"
msgctxt "selection:sale.sale,order_status:"
msgid "Commanded"
msgstr ""
msgctxt "selection:sale.sale,delivery_way:"
msgid "Take Away"
msgstr "Para llevar"
#, fuzzy
msgctxt "selection:sale.sale,order_status:"
msgid "Delivered"
msgstr "Entregado"
#, fuzzy
msgctxt "selection:sale.sale,order_status:"
msgid "Dispatched"
msgstr "Despachado"
#, fuzzy
msgctxt "selection:sale.sale,order_status:"
msgid "Draft"
msgstr "Borrador"
msgctxt "selection:sale.sale,order_status:"
msgid "In Preparation"
msgstr ""
#, fuzzy
msgctxt "selection:sale.sale,order_status:"
msgid "Rejected"
msgstr "Rechazado"
msgctxt "selection:sale.shop.table,state:"
msgid "Available"
@ -343,10 +257,23 @@ msgctxt "view:sale.line:"
msgid "Production"
msgstr "Producciones"
msgctxt "view:sale.shop:"
msgid "Delivery Man"
msgstr "Domiciliario"
#, fuzzy
msgctxt "view:sale.sale:"
msgid "Shipments"
msgstr "Albaranes"
msgctxt "view:sale.shop:"
msgid "Tables"
msgstr "Mesas"
#, fuzzy
msgctxt ""
"wizard_button:sale_pos_frontend_rest.sale_square_box_global,start,end:"
msgid "Cancel"
msgstr "Cancelar"
#, fuzzy
msgctxt ""
"wizard_button:sale_pos_frontend_rest.sale_square_box_global,start,print_:"
msgid "Print"
msgstr "Imprimir"

122
sale.py
View File

@ -9,8 +9,11 @@ from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.wizard import Wizard
from decimal import Decimal
from trytond.wizard import StateReport
from trytond.report import Report
from trytond.i18n import gettext
from .exceptions import PayValidationError, ProductionValidationWarning
from trytond.modules.sale_pos_frontend.sale import SaleSquareBox
KIND = [
('', ''),
@ -304,3 +307,122 @@ class SaleLine(metaclass=PoolMeta):
class Shop(metaclass=PoolMeta):
__name__ = 'sale.shop'
tables = fields.One2Many('sale.shop.table', 'shop', 'Tables')
class SaleSquareBoxGlobal(SaleSquareBox):
'Sale Square Box Global'
__name__ = 'sale_pos_frontend_rest.sale_square_box_global'
@classmethod
def __setup__(cls):
super(SaleSquareBoxGlobal, cls).__setup__()
cls.print_ = StateReport('sale_pos_frontend_rest.sale_square_box_global_report')
class SaleSquareBoxGlobalReport(Report):
'Square Box Global Report'
__name__ = 'sale_pos_frontend_rest.sale_square_box_global_report'
@classmethod
def __setup__(cls):
super(SaleSquareBoxGlobalReport, cls).__setup__()
@classmethod
def get_stament_cash(cls, statement):
Statement = Pool().get('account.statement')
if statement:
value = {
'statement': Statement(statement['id']),
'base': statement['total_money'] or 0,
'bills': sum(k['amount'] for k in statement['count_money.'] if float(k['bill']) >= 1000),
'coins': sum(k['amount'] for k in statement['count_money.'] if float(k['bill']) < 1000)
}
return value
@classmethod
def get_context(cls, records, header, data):
report_context = super().get_context(records, header, data)
pool = Pool()
Invoice = pool.get('account.invoice')
Company = pool.get('company.company')
Device = pool.get('sale.device')
company = Company(data['company'])
Statement = pool.get('account.statement')
Shop = pool.get('sale.shop')
# User = pool.get('res.user')
dom_statement = [
('date', '=', data['date']),
]
devices = Device.search([('shop', '=', data['shop'])])
device_ids = [d.id for d in devices]
dom_statement.append(('sale_device', 'in', device_ids))
if data['turn']:
dom_statement.append(('turn', '=', int(data['turn'])))
fields_statement = ['name', 'create_date', 'journal.kind', 'balance', 'count_money.bill', 'count_money.quantity', 'count_money.amount', 'total_money']
cash = None
statements = Statement.search_read(dom_statement, fields_names=fields_statement)
lst_statements = []
balance_statements = []
for st in statements:
kind = st['journal.']['kind']
if kind == 'cash':
cash = st
else:
balance_statements.append(st['balance'])
lst_statements.append(st)
statement_cash_before, = Statement.search_read([
('sale_device.shop', '=', data['shop']),
('journal.kind', '=', 'cash'),
('create_date', '<', cash['create_date']),
], fields_names=fields_statement,
limit=1, order=[('create_date', 'DESC')])
statement_cash_before = cls.get_stament_cash(statement_cash_before)
dom_invoices = [
('company', '=', data['company']),
('invoice_date', '=', data['date']),
('type', '=', 'out'),
('shop', '=', data['shop']),
('turn', '=', int(data['turn']))
]
fields_inv = ['number', 'invoice_type', 'total_amount', 'state', 'payment_term.payment_type', 'sales.residual_amount']
invoices = Invoice.search_read(dom_invoices, fields_names=fields_inv)
group_invoices = {'pos': [], 'pos_invoices': [],
'electronic': [], 'electronic_invoices': [],
'cancelled': [], 'cancelled_invoices': []}
credits = []
cash_by_pay = []
for invoice in invoices:
if invoice['sales.'][0]['residual_amount'] > 0:
if invoice['payment_term.']['payment_type'] == '2':
credits.append(invoice['sales.'][0]['residual_amount'])
else:
cash_by_pay.append(invoice['sales.'][0]['residual_amount'])
if invoice['state'] == 'cancelled':
group_invoices['cancelled'].append(invoice['total_amount'])
group_invoices['cancelled_invoices'].append(invoice)
elif invoice['invoice_type'] == '1':
group_invoices['electronic'].append(invoice['total_amount'])
group_invoices['electronic_invoices'].append(invoice)
else:
group_invoices['pos'].append(invoice['total_amount'])
group_invoices['pos_invoices'].append(invoice)
report_context['total_sale'] = sum(group_invoices['pos']) + sum(group_invoices['electronic'])
report_context['group_invoices'] = group_invoices
report_context['statement_cash_before'] = statement_cash_before
report_context['cash'] = cls.get_stament_cash(cash)
report_context['credits'] = sum(credits)
report_context['cash_by_pay'] = sum(cash_by_pay)
report_context['statements'] = lst_statements
report_context['balance_statements'] = balance_statements
report_context['data'] = data
report_context['company'] = company
report_context['shop'] = Shop(data['shop'])
return report_context

View File

@ -24,5 +24,22 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
<field name="inherit" ref="sale.sale_line_view_form"/>
<field name="name">sale_line_form</field>
</record>
<record model="ir.action.report" id="report_sale_square_box_global">
<field name="name">Report Square Box Global Daily</field>
<field name="model"></field>
<field name="report_name">sale_pos_frontend_rest.sale_square_box_global_report</field>
<field name="report">sale_pos_frontend_rest/square_box_global.ods</field>
<field name="template_extension">ods</field>
<field name="translatable">False</field>
</record>
<record model="ir.action.wizard" id="wizard_print_sale_square_box_global">
<field name="name">Sale Square Box Global Report</field>
<field name="wiz_name">sale_pos_frontend_rest.sale_square_box_global</field>
</record>
<menuitem parent="sale_pos.menu_sale_statement"
id="menu_sale_square_box_global" icon="tryton-print"
action="wizard_print_sale_square_box_global" sequence="100"/>
</data>
</tryton>

BIN
square_box_global.ods Normal file

Binary file not shown.