Add monitoring
This commit is contained in:
parent
408b7cd17e
commit
bfc18d24ae
|
@ -59,6 +59,7 @@ def register():
|
|||
invoice.Invoice,
|
||||
invoice.InvoiceLine,
|
||||
quality.PhytoMovesStart,
|
||||
quality.PurchaseMonitoringStart,
|
||||
module='farming', type_='model')
|
||||
Pool.register(
|
||||
purchase.PurchaseFarming,
|
||||
|
@ -68,6 +69,7 @@ def register():
|
|||
sale.SaleForceDraft,
|
||||
sale.GroupingSales,
|
||||
quality.PhytoMoves,
|
||||
quality.PurchaseMonitoring,
|
||||
module='farming', type_='wizard')
|
||||
Pool.register(
|
||||
purchase.PurchaseFarmingReport,
|
||||
|
@ -78,4 +80,5 @@ def register():
|
|||
charge.DispatchControlReport,
|
||||
quality.ExportationPhytosanitaryReport,
|
||||
quality.PhytoMovesReport,
|
||||
quality.PurchaseMonitoringReport,
|
||||
module='farming', type_='report')
|
||||
|
|
File diff suppressed because it is too large
Load Diff
83
quality.py
83
quality.py
|
@ -47,6 +47,7 @@ class QualityTest(ModelSQL, ModelView):
|
|||
('quality', 'Quality'),
|
||||
('phytosanitary', 'Phytosanitary')
|
||||
], 'Kind', required=True)
|
||||
kind_string = kind.translated('kind')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -473,3 +474,85 @@ class PhytoMovesReport(Report):
|
|||
report_context['records'] = records_
|
||||
report_context['company'] = Company(company_id)
|
||||
return report_context
|
||||
|
||||
|
||||
class PurchaseMonitoringStart(ModelView):
|
||||
'Purchase Monitoring Start'
|
||||
__name__ = 'farming.purchase_monitoring.start'
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
date_ = fields.Date("Date", required=True)
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
|
||||
class PurchaseMonitoring(Wizard):
|
||||
'Purchase Monitoring'
|
||||
__name__ = 'farming.purchase_monitoring'
|
||||
start = StateView('farming.purchase_monitoring.start',
|
||||
'farming.purchase_monitoring_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
])
|
||||
print_ = StateReport('farming.purchase_monitoring.report')
|
||||
|
||||
def do_print_(self, action):
|
||||
data = {
|
||||
'company': self.start.company.id,
|
||||
'date': self.start.date_,
|
||||
}
|
||||
return action, data
|
||||
|
||||
def transition_print_(self):
|
||||
return 'end'
|
||||
|
||||
|
||||
class PurchaseMonitoringReport(Report):
|
||||
'Purchase Monitoring Report'
|
||||
__name__ = 'farming.purchase_monitoring.report'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
company_id = Transaction().context.get('company')
|
||||
Company = pool.get('company.company')
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
purchases = Purchase.search([
|
||||
('delivery_date', '=', data['date']),
|
||||
('ica_certicate', '!=', None),
|
||||
('state', 'in', ['confirmed', 'processing', 'done']),
|
||||
], order=[('id', 'ASC')]
|
||||
)
|
||||
|
||||
records_ = []
|
||||
_append = records_.append
|
||||
for purc in purchases:
|
||||
phyto = None
|
||||
for ship in purc.shipments:
|
||||
phyto = ship.phyto
|
||||
if not phyto:
|
||||
continue
|
||||
for line in purc.lines:
|
||||
rec_in = {
|
||||
'date': purc.delivery_date,
|
||||
'supplier': purc.ica_certicate.farm,
|
||||
'doc': phyto.number,
|
||||
'reference': line.product.template.name,
|
||||
'quantity': line.quantity,
|
||||
'returned_qty': line.returned_qty,
|
||||
'qty_checked': line.qty_checked,
|
||||
'analysis': [],
|
||||
}
|
||||
for qa in line.quality_analysis:
|
||||
rec_in['analysis'].append({
|
||||
'returned_qty': qa.returned_qty,
|
||||
'test_kind': qa.test.kind_string,
|
||||
'test': qa.test.name,
|
||||
'action': qa.action,
|
||||
})
|
||||
_append(rec_in)
|
||||
report_context['records'] = records_
|
||||
report_context['company'] = Company(company_id)
|
||||
return report_context
|
||||
|
|
21
quality.xml
21
quality.xml
|
@ -258,5 +258,26 @@ this repository contains the full copyright notices and license terms. -->
|
|||
sequence="3" id="menu_farming_phyto_moves_report"
|
||||
action="wizard_print_phyto_moves_report"/>
|
||||
|
||||
<record model="ir.action.report" id="report_purchase_monitoring">
|
||||
<field name="name">Purchase Monitoring Report</field>
|
||||
<field name="model"></field>
|
||||
<field name="report_name">farming.purchase_monitoring.report</field>
|
||||
<field name="report">farming/purchase_monitoring.fods</field>
|
||||
<field name="template_extension">ods</field>
|
||||
<field name="translatable">False</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="purchase_monitoring_start_view_form">
|
||||
<field name="model">farming.purchase_monitoring.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">purchase_monitoring_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_print_purchase_monitoring_report">
|
||||
<field name="name">Purchase Monitoring Report</field>
|
||||
<field name="wiz_name">farming.purchase_monitoring</field>
|
||||
</record>
|
||||
<menuitem name="Purchase Monitoring" parent="farming.menu_reports"
|
||||
sequence="4" id="menu_farming_purchase_monitoring_report"
|
||||
action="wizard_print_purchase_monitoring_report"/>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.16
|
||||
version=6.0.17
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?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="date_"/>
|
||||
<field name="date_"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
</form>
|
Loading…
Reference in New Issue