mirror of
https://bitbucket.org/presik/trytonpsk-purchase_co.git
synced 2023-12-14 06:43:05 +01:00
minor fix report purchase detailed and add report analytic
This commit is contained in:
parent
d8dc97c8e4
commit
2665aee752
10 changed files with 909 additions and 1 deletions
10
__init__.py
10
__init__.py
|
@ -10,4 +10,14 @@ def register():
|
|||
purchase.Configuration,
|
||||
purchase.Purchase,
|
||||
purchase.Line,
|
||||
purchase.PurchaseAnalyticStart,
|
||||
purchase.PurchaseDetailedStart,
|
||||
module='purchase_co', type_='model')
|
||||
Pool.register(
|
||||
purchase.PurchaseDetailed,
|
||||
purchase.PurchaseAnalytic,
|
||||
module='purchase_co', type_='wizard')
|
||||
Pool.register(
|
||||
purchase.PurchaseAnalyticReport,
|
||||
purchase.PurchaseDetailedReport,
|
||||
module='purchase_co', type_='report')
|
||||
|
|
BIN
analytic_report.ods
Normal file
BIN
analytic_report.ods
Normal file
Binary file not shown.
BIN
detailed_report.ods
Normal file
BIN
detailed_report.ods
Normal file
Binary file not shown.
509
locale/es.po
Normal file
509
locale/es.po
Normal file
|
@ -0,0 +1,509 @@
|
|||
#
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:purchase.configuration,all_warehouse:"
|
||||
msgid "All Warehouse"
|
||||
msgstr "Todas las Bodegas"
|
||||
|
||||
msgctxt "field:purchase.configuration,reference_required:"
|
||||
msgid "Reference Required"
|
||||
msgstr "Referencia Requerida"
|
||||
|
||||
msgctxt "field:purchase.line,stock_quantity:"
|
||||
msgid "Stock Quantity"
|
||||
msgstr "Cantidad en Bodega"
|
||||
|
||||
msgctxt "field:purchase.purchase_detailed.start,detailed:"
|
||||
msgid "Detailed"
|
||||
msgstr "Detallado"
|
||||
|
||||
msgctxt "field:purchase.purchase_detailed.start,invoiced:"
|
||||
msgid "Invoiced"
|
||||
msgstr "Compras Facturadas"
|
||||
|
||||
msgctxt "field:purchase_report.analytic.start,company:"
|
||||
msgid "Company"
|
||||
msgstr "Empresa"
|
||||
|
||||
msgctxt "field:purchase_report.analytic.start,end_date:"
|
||||
msgid "End Date"
|
||||
msgstr "Fin"
|
||||
|
||||
msgctxt "field:purchase_report.analytic.start,start_date:"
|
||||
msgid "Start Date"
|
||||
msgstr "Inicio"
|
||||
|
||||
msgctxt "help:purchase.configuration,all_warehouse:"
|
||||
msgid "See quantity in all warehouse"
|
||||
msgstr "Ver cantidades de todas las bodegas"
|
||||
|
||||
msgctxt "help:purchase.purchase_detailed.start,detailed:"
|
||||
msgid "print report detailed"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "help:purchase.purchase_detailed.start,invoiced:"
|
||||
msgid "print purchase invoiced"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "model:ir.action,name:act_purchase_historic_by_product_tree"
|
||||
msgid "Purchase Historic By Product"
|
||||
msgstr "Compra Historica Por Producto"
|
||||
|
||||
msgctxt "model:ir.action,name:act_purchase_historic_by_product_variant_tree"
|
||||
msgid "Purchase Historic By Product"
|
||||
msgstr "Compra Historica Por Producto"
|
||||
|
||||
msgctxt "model:ir.action,name:report_purchase_analytic"
|
||||
msgid "Purchase Analytic Report"
|
||||
msgstr "Compras por Centros de Costos"
|
||||
|
||||
msgctxt "model:ir.action,name:report_purchase_detailed"
|
||||
msgid "Purchase Detailed"
|
||||
msgstr "Compra detallada"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_print_purchase_report_analytic"
|
||||
msgid "Wizard Purchase Analytic Report"
|
||||
msgstr "Compras por Centros de Costos"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_purchase_detailed"
|
||||
msgid "Print Purchase Detailed"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "model:ir.ui.menu,name:menu_print_purchase_detailed"
|
||||
msgid "Print Purchase Detailed"
|
||||
msgstr "Imprimir compras detalladas"
|
||||
|
||||
msgctxt "model:ir.ui.menu,name:menu_purchase_analytic_report"
|
||||
msgid "Purchase Analytic"
|
||||
msgstr "Compras por Centros de Costos"
|
||||
|
||||
msgctxt "model:purchase_report.analytic.start,name:"
|
||||
msgid "Purchase Analytic Report Start"
|
||||
msgstr "Compras por Centros de Costos"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "$"
|
||||
msgstr "$"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "("
|
||||
msgstr "("
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid ")"
|
||||
msgstr ")"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid ","
|
||||
msgstr ","
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "-"
|
||||
msgstr "-"
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "."
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "/"
|
||||
msgstr "/"
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "/for"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "0.00"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "00/00/0000"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "00:00:00"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "???"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "CENTRO DE OP."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "DESCRIPCION"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "ESTADO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "FECHA"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "FECHA FINAL:"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "FECHA INICIAL:"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "INFORME DE COMPRAS"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "MONEDA"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "No. ORDEN"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "Página"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "TERCERO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "TRYTON ERP"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "VALOR BRUTO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "VALOR DESCUENTO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "VALOR IMPUESTOS"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "VALOR NETO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "data['end_date']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "data['start_date']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "for each='purchase in records'"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.currency.name"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.description"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid ""
|
||||
"purchase.lines[0].operation_center and "
|
||||
"purchase.lines[0].operation_center.name"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.number and purchase.number"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.party.name"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.purchase_date"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.state_string"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.tax_amount"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.total_amount"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "purchase.untaxed_amount"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase.purchase_detailed.report:"
|
||||
msgid "€"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "$"
|
||||
msgstr "$"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "("
|
||||
msgstr "("
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "($"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid ")"
|
||||
msgstr ")"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid ","
|
||||
msgstr ","
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "-"
|
||||
msgstr "-"
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "- pta"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "--"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "--)"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "/"
|
||||
msgstr "/"
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "/for"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "00/00/0000"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "00:00:00"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid ":"
|
||||
msgstr ":"
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "???"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "C.C."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "CANT. COMP."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "CANT. RECIB."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "CENTROS DE COSTOS"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "COMPAÑIA:"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "ENVIO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "ESTADO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "FACTURA"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "FECHA"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "IMPUESTO"
|
||||
msgstr "IMPUESTO"
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "INFORME DE COMPRAS POR"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "NIT /CC"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "P. UNIT FC"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "P. UNIT OC"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "PRODUCTO"
|
||||
msgstr "PRODUCTO"
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "Página"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "REF."
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "SUBTOTAL"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "TERCERO"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "TOTAL"
|
||||
msgstr "TOTAL"
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "UDM"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "company.rec_name"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "de"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "for each='line in records'"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['amount']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['analytic_account']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['description']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['full_amount']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['id_number']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['inv_unit_price']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['invoice_state']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['name']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['purchase_date']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['qty_received']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['quantity']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['reference']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['shipment_state']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['state']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['tax_amount']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['unit_name']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "line['unit_price']"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "pta"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "report:purchase_report.analytic.report:"
|
||||
msgid "€"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "wizard_button:purchase_report.analytic,start,end:"
|
||||
msgid "Cancel"
|
||||
msgstr "Cancelar"
|
||||
|
||||
msgctxt "wizard_button:purchase_report.analytic,start,print_:"
|
||||
msgid "Print"
|
||||
msgstr "Imprimir"
|
255
purchase.py
255
purchase.py
|
@ -1,11 +1,14 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from datetime import date, timedelta
|
||||
from decimal import Decimal
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields
|
||||
from trytond.model import fields, ModelView
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.report import Report
|
||||
from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
|
||||
|
||||
|
||||
class Configuration(metaclass=PoolMeta):
|
||||
|
@ -96,3 +99,253 @@ class Line(metaclass=PoolMeta):
|
|||
quantity += v
|
||||
quantity = quantity
|
||||
return quantity
|
||||
|
||||
|
||||
class PurchaseAnalyticStart(ModelView):
|
||||
'Purchase Analytic Report Start'
|
||||
__name__ = 'purchase_report.analytic.start'
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
start_date = fields.Date("Start Date", required=True)
|
||||
end_date = fields.Date("End Date", required=True)
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
@staticmethod
|
||||
def default_end_date():
|
||||
Date = Pool().get('ir.date')
|
||||
return Date.today()
|
||||
|
||||
|
||||
class PurchaseAnalytic(Wizard):
|
||||
'Purchase Analytic Report'
|
||||
__name__ = 'purchase_report.analytic'
|
||||
start = StateView('purchase_report.analytic.start',
|
||||
'purchase_co.purchase_analytic_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
])
|
||||
print_ = StateReport('purchase_report.analytic.report')
|
||||
|
||||
def do_print_(self, action):
|
||||
data = {
|
||||
'company': self.start.company.id,
|
||||
'start_date': self.start.start_date,
|
||||
'end_date': self.start.end_date,
|
||||
}
|
||||
return action, data
|
||||
|
||||
def transition_print_(self):
|
||||
return 'end'
|
||||
|
||||
|
||||
class PurchaseAnalyticReport(Report):
|
||||
__name__ = 'purchase_report.analytic.report'
|
||||
|
||||
@classmethod
|
||||
def compute_amount_tax(cls, line):
|
||||
Tax = Pool().get('account.tax')
|
||||
tax_list = Tax.compute(Tax.browse(line['taxes']),
|
||||
line['unit_price'] or Decimal('0.0'),
|
||||
line['quantity'] or 0.0)
|
||||
return sum([t['amount'] for t in tax_list], Decimal('0.0'))
|
||||
|
||||
@classmethod
|
||||
def _get_rec(cls, line):
|
||||
analytic_account = None
|
||||
if line['analytic_accounts.']:
|
||||
analytic_account = line['analytic_accounts.'][0]['account.']
|
||||
inv_unit_price = Decimal(0)
|
||||
if line['invoice_lines.']:
|
||||
inv_unit_price = line['invoice_lines.'][0]['unit_price']
|
||||
|
||||
value = {
|
||||
'reference': line['purchase.']['reference'],
|
||||
'purchase_date': line['purchase.']['purchase_date'],
|
||||
'state': line['purchase.']['state'],
|
||||
'shipment_state': line['purchase.']['shipment_state'],
|
||||
'invoice_state': line['purchase.']['invoice_state'],
|
||||
'id_number': line['purchase.']['party.']['id_number'],
|
||||
'name': line['purchase.']['party.']['name'],
|
||||
'warehouse': line['purchase.']['warehouse.']['name'],
|
||||
'description': line['description'],
|
||||
'unit_name': line['unit.']['name'],
|
||||
'quantity': line['quantity'],
|
||||
'unit_price': line['unit_price'],
|
||||
'analytic_account': analytic_account['code'] + ' ' + analytic_account['name'] if analytic_account else '',
|
||||
'taxes': list(line['taxes']),
|
||||
'qty_received': sum([r['quantity'] for r in line['moves.']]),
|
||||
'amount': line['amount'],
|
||||
'inv_unit_price': inv_unit_price
|
||||
}
|
||||
tax_amount = cls.compute_amount_tax(value)
|
||||
full_amount = value['amount'] + tax_amount
|
||||
value.update({
|
||||
'tax_amount': tax_amount,
|
||||
'full_amount': full_amount,
|
||||
})
|
||||
return value
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
fields_names = ['purchase.reference', 'purchase.purchase_date', 'purchase.party.id_number',
|
||||
'purchase.party.name', 'description', 'unit.name', 'quantity', 'unit_price',
|
||||
'purchase.state', 'purchase.shipment_state', 'purchase.invoice_state',
|
||||
'analytic_accounts.account.name', 'analytic_accounts.account.code', 'taxes',
|
||||
'invoice_lines.unit_price', 'moves.quantity', 'amount', 'purchase.warehouse.name'
|
||||
]
|
||||
|
||||
lines = PurchaseLine.search_read([
|
||||
('purchase.company', '=', data['company']),
|
||||
('purchase.purchase_date', '>=', data['start_date']),
|
||||
('purchase.purchase_date', '<=', data['end_date']),
|
||||
], fields_names=fields_names, order=[('purchase.purchase_date', 'ASC')])
|
||||
|
||||
records = []
|
||||
|
||||
records_append = records.append
|
||||
get_rec = cls._get_rec
|
||||
for line in lines:
|
||||
records_append(get_rec(line))
|
||||
|
||||
report_context['records'] = records
|
||||
report_context['company'] = Company(data['company'])
|
||||
return report_context
|
||||
|
||||
|
||||
class PurchaseDetailedStart(ModelView):
|
||||
'Purchase Detailed Start'
|
||||
__name__ = 'purchase.purchase_detailed.start'
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
start_date = fields.Date('Start Date', required=True)
|
||||
end_date = fields.Date('End Date', required=True)
|
||||
invoiced = fields.Boolean('Invoiced', help='print purchase invoiced')
|
||||
detailed = fields.Boolean('Detailed', help='print report detailed')
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
|
||||
class PurchaseDetailed(Wizard):
|
||||
'Purchase Detailed'
|
||||
__name__ = 'purchase.purchase_detailed'
|
||||
start = StateView('purchase.purchase_detailed.start',
|
||||
'purchase_co.print_purchase_detailed_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
])
|
||||
print_ = StateReport('purchase.purchase_detailed.report')
|
||||
|
||||
def do_print_(self, action):
|
||||
data = {
|
||||
'company': self.start.company.id,
|
||||
'start_date': self.start.start_date,
|
||||
'end_date': self.start.end_date,
|
||||
'invoiced': self.start.invoiced,
|
||||
'detailed': self.start.detailed,
|
||||
}
|
||||
return action, data
|
||||
|
||||
def transition_print_(self):
|
||||
return 'end'
|
||||
|
||||
|
||||
class PurchaseDetailedReport(Report):
|
||||
__name__ = 'purchase.purchase_detailed.report'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
|
||||
fields_names = [
|
||||
'number', 'description', 'party.name', 'untaxed_amount',
|
||||
'party.id_number', 'state', 'tax_amount', 'total_amount',
|
||||
]
|
||||
|
||||
lines = None
|
||||
|
||||
if data['invoiced']:
|
||||
title = 'INFORME DE COMPRAS'
|
||||
|
||||
fields_names.append('invoice_date')
|
||||
Invoiceline = pool.get('account.invoice.line')
|
||||
dom_invoice = [
|
||||
('company', '=', data['company']),
|
||||
('invoice.invoice_date', '>=', data['start_date']),
|
||||
('invoice.invoice_date', '<=', data['end_date']),
|
||||
('invoice.type', '=', 'in'),
|
||||
('origin', 'ilike', 'purchase.line%'),
|
||||
]
|
||||
fields_names_lines = ['id', 'invoice', 'origin.purchase.number']
|
||||
|
||||
fields = Invoiceline.fields_get(fields_names=['operation_center'])
|
||||
if 'operation_center' in fields.keys():
|
||||
fields_names_lines.append('operation_center.name')
|
||||
lines = Invoiceline.search_read(dom_invoice, fields_names=fields_names_lines)
|
||||
|
||||
operation_centers = {}
|
||||
invoices_ids = set()
|
||||
invoices_ids_add = invoices_ids.add
|
||||
oc_inv_update = operation_centers.update
|
||||
for v in lines:
|
||||
invoices_ids_add(v['invoice'])
|
||||
operation_center = ''
|
||||
if v['operation_center.']:
|
||||
operation_center = v['operation_center.']['name']
|
||||
purchase = v['origin.']['purchase.']['number']
|
||||
oc_inv_update({v['invoice']: {'operation_center': operation_center, 'purchase': purchase}})
|
||||
|
||||
records = Invoice.search_read(
|
||||
['id', 'in', invoices_ids], fields_names=fields_names)
|
||||
|
||||
else:
|
||||
fields_names.append('purchase_date')
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
Purchaseline = pool.get('purchase.line')
|
||||
|
||||
title = 'INFORME DE ORDENES DE COMPRAS'
|
||||
|
||||
dom_lines = [
|
||||
('purchase.company', '=', data['company']),
|
||||
('purchase.purchase_date', '>=', data['start_date']),
|
||||
('purchase.purchase_date', '<=', data['end_date']),
|
||||
]
|
||||
fields_names_lines = ['id', 'purchase']
|
||||
|
||||
fields = Purchaseline.fields_get(fields_names=['operation_center'])
|
||||
if 'operation_center' in fields.keys():
|
||||
fields_names_lines.append('operation_center.name')
|
||||
lines = Purchaseline.search_read(dom_lines, fields_names=fields_names_lines)
|
||||
operation_centers = {}
|
||||
purchase_ids = set()
|
||||
purchase_ids_add = purchase_ids.add
|
||||
oc_purchase_update = operation_centers.update
|
||||
for v in lines:
|
||||
purchase_ids_add(v['id'])
|
||||
operation_center = ''
|
||||
if v['operation_center.']:
|
||||
operation_center = v['operation_center.']['name']
|
||||
oc_purchase_update({v['purchase']: operation_center})
|
||||
|
||||
dom_purchases = [
|
||||
('company', '=', data['company']),
|
||||
('purchase_date', '>=', data['start_date']),
|
||||
('purchase_date', '<=', data['end_date']),
|
||||
]
|
||||
records = Purchase.search_read(dom_purchases, fields_names=fields_names,
|
||||
order=[('party.name', 'ASC'), ('purchase_date', 'ASC')]
|
||||
)
|
||||
|
||||
report_context['records'] = records
|
||||
report_context['data'] = data
|
||||
report_context['title'] = title
|
||||
report_context['operation_centers'] = operation_centers
|
||||
return report_context
|
||||
|
|
93
purchase.xml
93
purchase.xml
|
@ -14,5 +14,98 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="inherit" ref="purchase.purchase_line_view_form"/>
|
||||
<field name="name">purchase_line_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.report" id="report_purchase_analytic">
|
||||
<field name="name">Purchase Analytic Report</field>
|
||||
<field name="model"></field>
|
||||
<field name="report_name">purchase_report.analytic.report</field>
|
||||
<field name="report">purchase_report/analytic_report.ods</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="purchase_analytic_start_view_form">
|
||||
<field name="model">purchase_report.analytic.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">report_analytic_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_print_purchase_report_analytic">
|
||||
<field name="name">Wizard Purchase Analytic Report</field>
|
||||
<field name="wiz_name">purchase_report.analytic</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Purchase Analytic" parent="account_col.menu_purchase_reporting" sequence="20"
|
||||
action="wizard_print_purchase_report_analytic" id="menu_purchase_analytic_report"/>
|
||||
|
||||
<!-- <record model="ir.action.report" id="report_purchase_detailed_report">
|
||||
<field name="name">Detailed Report</field>
|
||||
<field name="model">purchase.purchase</field>
|
||||
<field name="report_name">purchase_report.detailed</field>
|
||||
<field name="report">purchase_co/detailed_report.ods</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="report_purchase_detailed_report_keyword">
|
||||
<field name="keyword">form_print</field>
|
||||
<field name="model">purchase.purchase,-1</field>
|
||||
<field name="action" ref="report_purchase_detailed_report"/>
|
||||
</record> -->
|
||||
<record model="ir.ui.view" id="purchase_historic_by_product_view_form">
|
||||
<field name="model">purchase.line</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">purchase_line_historic_by_product</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_purchase_historic_by_product_tree">
|
||||
<field name="name">Purchase Historic By Product</field>
|
||||
<field name="res_model">purchase.line</field>
|
||||
<field name="domain"
|
||||
eval="[('product.template', 'in', Eval('active_ids'))]"
|
||||
pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_purchase_historic_by_product_view">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view" ref="purchase_historic_by_product_view_form"/>
|
||||
<field name="act_window" ref="act_purchase_historic_by_product_tree"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_purchase_historic_by_product_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">product.template,-1</field>
|
||||
<field name="action" ref="act_purchase_historic_by_product_tree"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_purchase_historic_by_product_variant_tree">
|
||||
<field name="name">Purchase Historic By Product</field>
|
||||
<field name="res_model">purchase.line</field>
|
||||
<field name="domain" eval="[('product', 'in', Eval('active_ids'))]" pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_purchase_historic_by_product_variant_view">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view" ref="purchase_historic_by_product_view_form"/>
|
||||
<field name="act_window" ref="act_purchase_historic_by_product_variant_tree"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_purchase_historic_by_product_variant_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">product.product,-1</field>
|
||||
<field name="action" ref="act_purchase_historic_by_product_variant_tree"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="print_purchase_detailed_start_view_form">
|
||||
<field name="model">purchase.purchase_detailed.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">print_purchase_detailed_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_purchase_detailed">
|
||||
<field name="name">Print Purchase Detailed</field>
|
||||
<field name="wiz_name">purchase.purchase_detailed</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.report" id="report_purchase_detailed">
|
||||
<field name="name">Purchase Detailed</field>
|
||||
<field name="model">purchase.purchase</field>
|
||||
<field name="report_name">purchase.purchase_detailed.report</field>
|
||||
<field name="report">purchase_co/purchase_detailed.fods</field>
|
||||
<field name="template_extension">ods</field>
|
||||
<field name="translatable">True</field>
|
||||
</record>
|
||||
|
||||
<menuitem parent="account_col.menu_purchase_reporting" sequence="100" action="wizard_purchase_detailed"
|
||||
id="menu_print_purchase_detailed" icon="tryton-print"/>
|
||||
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
BIN
purchase_detailed.fods
Normal file
BIN
purchase_detailed.fods
Normal file
Binary file not shown.
17
view/print_purchase_detailed_start_form.xml
Normal file
17
view/print_purchase_detailed_start_form.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of 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"/>
|
||||
<group id="checkbox" col="-1" colspan="2">
|
||||
<label name="invoiced"/>
|
||||
<field name="invoiced" width="25"/>
|
||||
<label name="detailed"/>
|
||||
<field name="detailed" width="25"/>
|
||||
</group>
|
||||
<label name="start_date"/>
|
||||
<field name="start_date"/>
|
||||
<label name="end_date"/>
|
||||
<field name="end_date"/>
|
||||
</form>
|
14
view/purchase_line_historic_by_product.xml
Normal file
14
view/purchase_line_historic_by_product.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="purchase"/>
|
||||
<field name="party"/>
|
||||
<field name="date"/>
|
||||
<field name="product"/>
|
||||
<field name="description"/>
|
||||
<field name="quantity"/>
|
||||
<field name="unit_price"/>
|
||||
<field name="amount"/>
|
||||
<field name="unit_digits" tree_invisible="1"/>
|
||||
</tree>
|
12
view/report_analytic_start_form.xml
Normal file
12
view/report_analytic_start_form.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of 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"/>
|
||||
<newline/>
|
||||
<label name="start_date"/>
|
||||
<field name="start_date"/>
|
||||
<label name="end_date"/>
|
||||
<field name="end_date"/>
|
||||
</form>
|
Loading…
Reference in a new issue