mirror of
https://bitbucket.org/presik/trytonpsk-purchase_co.git
synced 2023-12-14 06:43:05 +01:00
fix report purchase detailed
This commit is contained in:
parent
1f80eb4ffe
commit
5464a87870
3 changed files with 74 additions and 26 deletions
98
purchase.py
98
purchase.py
|
@ -332,45 +332,91 @@ class PurchasesDetailedReport(Report):
|
|||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
InvoiceLine = pool.get('account.invoice.line')
|
||||
Company = pool.get('company.company')
|
||||
fields_names = [
|
||||
'number', 'description', 'party.name', 'untaxed_amount',
|
||||
'party.id_number', 'state', 'tax_amount', 'total_amount',
|
||||
'currency.code', 'purchases.description', 'purchases.number'
|
||||
'currency.code'
|
||||
]
|
||||
|
||||
fields_names_detailed = [
|
||||
'product.rec_name', 'product.type', 'product.categories.name', 'quantity', 'unit_price',
|
||||
]
|
||||
|
||||
fields = Purchase.fields_get(fields_names=['operation_center'])
|
||||
if 'operation_center' in fields.keys():
|
||||
fields_names.append('operation_center.name')
|
||||
fields_names.append('purchases.operation_center.name')
|
||||
|
||||
if data['invoiced']:
|
||||
title = 'INFORME DE COMPRAS'
|
||||
fields_names.append('invoice_date')
|
||||
dom_ = [
|
||||
('company', '=', data['company']),
|
||||
('invoice_date', '>=', data['start_date']),
|
||||
('invoice_date', '<=', data['end_date']),
|
||||
('type', '=', 'in'),
|
||||
('purchases', '!=', None),
|
||||
]
|
||||
records = Invoice.search_read(dom_, fields_names=fields_names)
|
||||
else:
|
||||
fields_names.append('purchase_date')
|
||||
title = 'INFORME DE ORDENES DE COMPRAS'
|
||||
|
||||
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')
|
||||
])
|
||||
if 'operation_center' in fields.keys():
|
||||
fields_names.append('purchases.operation_center.name')
|
||||
fields_names_detailed.append('invoice.purchases.operation_center.name')
|
||||
if data['detailed']:
|
||||
fields_add = ['invoice.party.name', 'invoice.party.id_number', 'invoice.purchases.number', 'invoice.purchases.purchase_date']
|
||||
fields_names_detailed.extend(fields_add)
|
||||
dom_ = [
|
||||
('invoice.company', '=', data['company']),
|
||||
('invoice.invoice_date', '>=', data['start_date']),
|
||||
('invoice.invoice_date', '<=', data['end_date']),
|
||||
('invoice.type', '=', 'in'),
|
||||
('invoice.purchases', '!=', None),
|
||||
]
|
||||
records = InvoiceLine.search_read(dom_, fields_names=fields_names_detailed)
|
||||
else:
|
||||
fields_add=['invoice_date', 'purchases.description', 'purchases.number']
|
||||
fields_names.extend(fields_add)
|
||||
|
||||
dom_ = [
|
||||
('company', '=', data['company']),
|
||||
('invoice_date', '>=', data['start_date']),
|
||||
('invoice_date', '<=', data['end_date']),
|
||||
('type', '=', 'in'),
|
||||
('purchases', '!=', None),
|
||||
]
|
||||
records = Invoice.search_read(dom_, fields_names=fields_names)
|
||||
else:
|
||||
title = 'INFORME DE ORDENES DE COMPRAS'
|
||||
if 'operation_center' in fields.keys():
|
||||
fields_names_detailed.append('purchase.operation_center.name')
|
||||
fields_names.append('operation_center.name')
|
||||
|
||||
|
||||
if data['detailed']:
|
||||
fields_add = ['purchase.party.name', 'purchase.party.id_number', 'purchase.number', 'purchase.purchase_date']
|
||||
fields_names_detailed.extend(fields_add)
|
||||
dom_ = [
|
||||
('purchase.company', '=', data['company']),
|
||||
('purchase.purchase_date', '>=', data['start_date']),
|
||||
('purchase.purchase_date', '<=', data['end_date']),
|
||||
]
|
||||
records = PurchaseLine.search_read(dom_, fields_names=fields_names_detailed)
|
||||
else:
|
||||
fields_names.append('purchase_date')
|
||||
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')
|
||||
])
|
||||
|
||||
states = {
|
||||
'posted': 'contabilizado',
|
||||
'paid': 'pagada',
|
||||
'draft': 'borrador',
|
||||
'done': 'finalizado',
|
||||
'processing': 'procesada',
|
||||
'quotation': 'cotizacion',
|
||||
}
|
||||
|
||||
report_context['records'] = records
|
||||
report_context['types'] = {'goods': 'bienes', 'service': 'servicios', 'assets': 'activos'}
|
||||
report_context['states'] = states
|
||||
report_context['company'] = Company(data['company'])
|
||||
report_context['data'] = data
|
||||
report_context['title'] = title
|
||||
|
|
|
@ -20,6 +20,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="model"></field>
|
||||
<field name="report_name">purchase_co.analytic.report</field>
|
||||
<field name="report">purchase_co/analytic_report.fods</field>
|
||||
<field name="template_extension">ods</field>
|
||||
<field name="translatable">False</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="purchase_analytic_start_view_form">
|
||||
<field name="model">purchase_co.analytic.start</field>
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue