add translation and report sale for channels

This commit is contained in:
Camilo Sarmiento 2020-09-24 18:34:59 -05:00
parent 896e25702f
commit e5077443f7
6 changed files with 792 additions and 3 deletions

View File

@ -12,9 +12,14 @@ def register():
web_channel.SaleWebChannel,
mercado_libre.MercadoLibre,
sale.Sale,
sale.SaleForChannelStart,
party.Party,
product.Template,
module='sale_web_channel', type_='model')
Pool.register(
sale.SaleUploadInvoice,
sale.SaleForChannel,
module='sale_web_channel', type_='wizard')
Pool.register(
sale.SaleForChannelReport,
module='sale_web_channel', type_='report')

639
locate/es.po Normal file
View File

@ -0,0 +1,639 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:sale.web_channel.mercado_libre:"
msgid "Product Not Found"
msgstr ""
msgctxt "field:party.party,id_reference:"
msgid "ID Reference Api"
msgstr ""
msgctxt "field:product.template,id_reference:"
msgid "ID Reference Api"
msgstr ""
msgctxt "field:sale.sale,channel:"
msgid "channel"
msgstr "Canal"
msgctxt "field:sale.sale,document_invoice:"
msgid "Document Invoice"
msgstr ""
msgctxt "field:sale.sale,id_reference:"
msgid "Id Reference Api"
msgstr ""
msgctxt "field:sale.sale,is_paymented:"
msgid "Is Paymented"
msgstr ""
msgctxt "field:sale.sale,pack_id:"
msgid "Pack ID"
msgstr ""
msgctxt "field:sale.sale,products_string:"
msgid "Products String"
msgstr ""
msgctxt "field:sale.sale,tracking_number:"
msgid "Tracking Number"
msgstr ""
msgctxt "field:sale.sale,uploaded_invoice:"
msgid "uploaded Invoice"
msgstr ""
msgctxt "field:sale.web_channel,access_token:"
msgid "Access Token"
msgstr ""
msgctxt "field:sale.web_channel,app_id:"
msgid "Application ID"
msgstr ""
msgctxt "field:sale.web_channel,authorization_code:"
msgid "Authorization Code"
msgstr ""
msgctxt "field:sale.web_channel,bonus_product:"
msgid "Bonus Product"
msgstr ""
msgctxt "field:sale.web_channel,channel_name:"
msgid "Channel"
msgstr "Canal"
msgctxt "field:sale.web_channel,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
msgctxt "field:sale.web_channel,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgctxt "field:sale.web_channel,creation_time:"
msgid "Creation Time"
msgstr ""
msgctxt "field:sale.web_channel,freight_product:"
msgid "Freight Product"
msgstr ""
msgctxt "field:sale.web_channel,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:sale.web_channel,invoice_type:"
msgid "Type Invoice"
msgstr "Tipo de Factura"
msgctxt "field:sale.web_channel,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
msgctxt "field:sale.web_channel,redirect_uri:"
msgid "Redirect URI"
msgstr ""
msgctxt "field:sale.web_channel,refresh_token:"
msgid "Refresh Token"
msgstr ""
msgctxt "field:sale.web_channel,report:"
msgid "Report"
msgstr "Reporte"
msgctxt "field:sale.web_channel,secret_key:"
msgid "Secret Key"
msgstr ""
msgctxt "field:sale.web_channel,state:"
msgid "State"
msgstr "Estado"
msgctxt "field:sale.web_channel,status_token:"
msgid "Status Token"
msgstr ""
msgctxt "field:sale.web_channel,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
msgctxt "field:sale.web_channel,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:sale.web_channel.mercado_libre,access_token:"
msgid "Access Token"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,app_id:"
msgid "Application ID"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,authorization_code:"
msgid "Authorization Code"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,bonus_product:"
msgid "Bonus Product"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,channel_name:"
msgid "Channel"
msgstr "Canal"
msgctxt "field:sale.web_channel.mercado_libre,create_date:"
msgid "Create Date"
msgstr "Fecha de Creación"
msgctxt "field:sale.web_channel.mercado_libre,create_uid:"
msgid "Create User"
msgstr "Usuario de creción"
msgctxt "field:sale.web_channel.mercado_libre,creation_time:"
msgid "Creation Time"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,freight_product:"
msgid "Freight Product"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:sale.web_channel.mercado_libre,invoice_type:"
msgid "Type Invoice"
msgstr "Tipo de Factura"
msgctxt "field:sale.web_channel.mercado_libre,rec_name:"
msgid "Record Name"
msgstr "Nombre del registro"
msgctxt "field:sale.web_channel.mercado_libre,redirect_uri:"
msgid "Redirect URI"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,refresh_token:"
msgid "Refresh Token"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,report:"
msgid "Report"
msgstr "Reporte"
msgctxt "field:sale.web_channel.mercado_libre,secret_key:"
msgid "Secret Key"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,state:"
msgid "State"
msgstr "Estado"
msgctxt "field:sale.web_channel.mercado_libre,status_token:"
msgid "Status Token"
msgstr ""
msgctxt "field:sale.web_channel.mercado_libre,write_date:"
msgid "Write Date"
msgstr "Modificado por Usuario"
msgctxt "field:sale.web_channel.mercado_libre,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:sale_web_channel.sale_for_channel.start,channels:"
msgid "Channel"
msgstr "Canal"
msgctxt "field:sale_web_channel.sale_for_channel.start,end_date:"
msgid "End Date"
msgstr "Fin"
msgctxt "field:sale_web_channel.sale_for_channel.start,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:sale_web_channel.sale_for_channel.start,include_canceled:"
msgid "Include Canceled"
msgstr "Incluir Canceladas"
msgctxt "field:sale_web_channel.sale_for_channel.start,shop:"
msgid "Shop"
msgstr "Tienda"
msgctxt "field:sale_web_channel.sale_for_channel.start,start_date:"
msgid "Start Date"
msgstr "Inicio"
msgctxt "model:ir.action,name:act_sale_upload_invoice"
msgid "Sale Upload Invoice"
msgstr ""
msgctxt "model:ir.action,name:act_sale_web_channel"
msgid "Channels"
msgstr "Canales"
msgctxt "model:ir.action,name:sale_for_channel_report"
msgid "Sale For Channel"
msgstr "Reporte De Ventas Por Canal"
msgctxt "model:ir.action,name:wizard_sale_for_channel"
msgid "Sale For Channel Report"
msgstr "Reporte De Ventas Por Canal"
msgctxt "model:ir.ui.menu,name:menu_sale_for_channel"
msgid "Sale For Channel Report"
msgstr "Reporte De Ventas Por Canal"
msgctxt "model:ir.ui.menu,name:menu_web_channel"
msgid "Channels"
msgstr "Canales"
msgctxt "model:sale.web_channel,name:"
msgid "Web Channel"
msgstr ""
msgctxt "model:sale.web_channel.mercado_libre,name:"
msgid "MercadoLibre"
msgstr ""
msgctxt "model:sale_web_channel.sale_for_channel.start,name:"
msgid "Sale For Channel Start"
msgstr "Reporte De Ventas Por Canal"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "$"
msgstr "$"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "%"
msgstr "%"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "("
msgstr "("
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid ")"
msgstr ")"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid ","
msgstr ","
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "-"
msgstr "-"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "/"
msgstr "/"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "/for"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "00/00/0000"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "00:00:00"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "???"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "CAJA"
msgstr "CAJA"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "CANAL"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "CANALES:"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "CLIENTE"
msgstr "CLIENTE"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "DESDE"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "HASTA"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "HORA"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "IMPUESTO"
msgstr "IMPUESTO"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "NUMERO"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "No"
msgstr "No"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "Página"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "REPORTE DE"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "SUBTOTAL (BASE)"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "SUCURSAL"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "TOTAL"
msgstr "TOTAL"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "TRYTON ERP"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "VENDEDOR"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "VENTA POR CANAL"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "channels"
msgstr "Canales"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "company"
msgstr "empresa"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "end_date"
msgstr "Fecha Final"
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "for each='sale in records'"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.channel"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.create_date - datetime.timedelta(hours=5)"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.number"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.party.name"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.sale_device and sale.sale_device.name"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.salesman and sale.salesman.party.name"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.sequence"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.shop and sale.shop.name"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.tax_amount"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.total_amount"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "sale.untaxed_amount"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "shop"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "start_date"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "tax_amount"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "total_amount"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "untaxed_amount"
msgstr ""
msgctxt "report:sale_web_channel.sale_for_channel_report:"
msgid "€"
msgstr ""
msgctxt "selection:sale.web_channel,channel_name:"
msgid "IFood"
msgstr ""
msgctxt "selection:sale.web_channel,channel_name:"
msgid "Melhous"
msgstr ""
msgctxt "selection:sale.web_channel,channel_name:"
msgid "Mercado Libre"
msgstr ""
msgctxt "selection:sale.web_channel,channel_name:"
msgid "Rappi"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid ""
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Computador"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Exportacion"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Factura por Contingencia DIAN"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Factura por Contingencia Facturador"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Manual"
msgstr "Manual"
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Nota Crédito Eléctronica"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Nota Débito Eléctronica"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "POS"
msgstr ""
msgctxt "selection:sale.web_channel,invoice_type:"
msgid "Venta Electronica"
msgstr ""
msgctxt "selection:sale.web_channel,state:"
msgid "Active"
msgstr "Activo"
msgctxt "selection:sale.web_channel,state:"
msgid "Draft"
msgstr "Borrador"
msgctxt "selection:sale.web_channel,state:"
msgid "Finished"
msgstr "Terminado"
msgctxt "selection:sale.web_channel,status_token:"
msgid "Active"
msgstr "Activo"
msgctxt "selection:sale.web_channel,status_token:"
msgid "Expired"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,channel_name:"
msgid "IFood"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,channel_name:"
msgid "Melhous"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,channel_name:"
msgid "Mercado Libre"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,channel_name:"
msgid "Rappi"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid ""
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Computador"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Exportacion"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Factura por Contingencia DIAN"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Factura por Contingencia Facturador"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Manual"
msgstr "Manual"
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Nota Crédito Eléctronica"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Nota Débito Eléctronica"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "POS"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,invoice_type:"
msgid "Venta Electronica"
msgstr ""
msgctxt "selection:sale.web_channel.mercado_libre,state:"
msgid "Active"
msgstr "Activo"
msgctxt "selection:sale.web_channel.mercado_libre,state:"
msgid "Draft"
msgstr "Borrador"
msgctxt "selection:sale.web_channel.mercado_libre,state:"
msgid "Finished"
msgstr "Terminado"
msgctxt "selection:sale.web_channel.mercado_libre,status_token:"
msgid "Active"
msgstr "Activo"
msgctxt "selection:sale.web_channel.mercado_libre,status_token:"
msgid "Expired"
msgstr ""
msgctxt "view:sale.web_channel:"
msgid "Active"
msgstr "Activo"
msgctxt "view:sale.web_channel:"
msgid "Draft"
msgstr "Borrador"
msgctxt "view:sale.web_channel:"
msgid "Finished"
msgstr "Terminado"
msgctxt "wizard_button:sale_web_channel.sale_for_channel,start,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:sale_web_channel.sale_for_channel,start,print_:"
msgid "Print"
msgstr "Imprimir"

115
sale.py
View File

@ -1,9 +1,12 @@
from trytond.model import fields
from trytond.model import fields, ModelView
from trytond.pool import PoolMeta, Pool
from trytond.transaction import Transaction
from trytond.wizard import (
Wizard, StateTransition)
from trytond.wizard import (Wizard, StateView, Button, StateReport,
StateTransition)
from trytond.report import Report
from trytond.transaction import Transaction
from trytond.pyson import Eval
__all__ = ['Sale']
@ -70,6 +73,112 @@ class SaleUploadInvoice(Wizard):
return 'end'
class SaleForChannelStart(ModelView):
'Sale For Channel Start'
__name__ = 'sale_web_channel.sale_for_channel.start'
company = fields.Many2One('company.company', 'Company', required=True)
shop = fields.Many2One('sale.shop', 'Shop', required=True, domain=[
('company', '=', Eval('company'))
])
channels = fields.Many2Many('sale.web_channel', None, None, 'Channel')
start_date = fields.Date('Start Date', required=True)
end_date = fields.Date('End Date', required=True)
include_canceled = fields.Boolean('Include Canceled')
@staticmethod
def default_company():
return Transaction().context.get('company')
class SaleForChannel(Wizard):
'Sale For Channel'
__name__ = 'sale_web_channel.sale_for_channel'
start = StateView('sale_web_channel.sale_for_channel.start',
'sale_web_channel.sale_for_channel_start_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-ok', default=True),
])
print_ = StateReport('sale_web_channel.sale_for_channel_report')
def do_print_(self, action):
report_context = {
'company': self.start.company.id,
'company_name': self.start.company.rec_name,
'shop': self.start.shop.id,
'shop_name': self.start.shop.name,
'channel': [],
'start_date': self.start.start_date,
'end_date': self.start.end_date,
'include_canceled': self.start.include_canceled,
}
report_context['channels'] = [{'id': c.id, 'name': c.rec_name} for c in self.start.channels]
return action, report_context
def transition_print_(self):
return 'end'
class SaleForChannelReport(Report):
'Sale For Channel Report'
__name__ = 'sale_web_channel.sale_for_channel_report'
@classmethod
def get_context(cls, records, data):
report_context = super(SaleForChannelReport, cls).get_context(records, data)
pool = Pool()
Sale = pool.get('sale.sale')
channel_ids = [c['id'] for c in data['channels']]
channel_names = [c['name'] for c in data['channels']]
shop_id = data['shop']
shop_name = data['shop_name']
company_name = data['company_name']
dom_sales = [
('shop', '=', shop_id),
('sale_date', '>=', data['start_date']),
('sale_date', '<=', data['end_date']),
]
states_sale = ['processing', 'done']
if data['include_canceled']:
states_sale.append('cancel')
dom_sales.append(('state', 'in', states_sale))
if channel_ids:
dom_sales.append(
('channel', 'in', channel_ids)
)
sales = Sale.search(dom_sales, order=[('sale_date', 'DESC')])
untaxed_amount_ = []
tax_amount_ = []
total_amount_ = []
total_amount_ = []
sequence = 0
for sale in sales:
sequence += 1
setattr(sale, 'sequence', sequence)
if not hasattr(sale, 'sale_device'):
setattr(sale, 'sale_device', None)
untaxed_amount_.append(sale.untaxed_amount)
tax_amount_.append(sale.tax_amount)
total_amount_.append(sale.total_amount)
report_context['records'] = sales
report_context['total_amount'] = sum(total_amount_)
report_context['tax_amount'] = sum(tax_amount_)
report_context['untaxed_amount'] = sum(untaxed_amount_)
report_context['start_date'] = data['start_date']
report_context['end_date'] = data['end_date']
report_context['shop'] = shop_name
report_context['channels'] = ', '.join(channel_names)
report_context['company'] = company_name
return report_context
# class Invoice(metaclass=PoolMeta):
# __name__ = 'account.invoice'
# salesman = fields.Many2One('company.employee', 'Salesman',

View File

@ -38,5 +38,24 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">sale_pos_form</field>
</record>
<record model="ir.action.report" id="sale_for_channel_report">
<field name="name">Sale For Channel</field>
<field name="model"></field>
<field name="report_name">sale_web_channel.sale_for_channel_report</field>
<field name="report">sale_web_channel/sale_channels.ods</field>
</record>
<record model="ir.ui.view" id="sale_for_channel_start_view_form">
<field name="model">sale_web_channel.sale_for_channel.start</field>
<field name="type">form</field>
<field name="name">sale_for_channel_start_view_form</field>
</record>
<record model="ir.action.wizard" id="wizard_sale_for_channel">
<field name="name">Sale For Channel Report</field>
<field name="wiz_name">sale_web_channel.sale_for_channel</field>
</record>
<menuitem parent="sale.menu_reporting" id="menu_sale_for_channel"
action="wizard_sale_for_channel"/>
</data>
</tryton>

BIN
sale_channels.ods Normal file

Binary file not shown.

View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!-- This file is part sale_shop module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
<form>
<label name="company"/>
<field name="company" widget="selection"/>
<label name="shop"/>
<field name="shop" widget="selection"/>
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
<field name="end_date"/>
<newline/>
<field name="channels" colspan="4"/>
<label name="include_canceled"/>
<field name="include_canceled"/>
</form>