changeset 1178:83f26d207cb0

Update health services wizard to be Tryton 3.0 compatible on the invoice generation
author Luis Falcon <falcon@gnu.org>
date Thu, 06 Feb 2014 15:38:49 +0000
parents 33e45da63c55
children 92408378aa66 1e2d49d5bfd7
files tryton/health_services/wizard/wizard_health_services.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health_services/wizard/wizard_health_services.py
+++ b/tryton/health_services/wizard/wizard_health_services.py
@@ -60,6 +60,7 @@
         HealthService = Pool().get('gnuhealth.health_service')
         Invoice = Pool().get('account.invoice')
         Party = Pool().get('party.party')
+        Journal = Pool().get('account.journal')
 
         services = HealthService.browse(Transaction().context.get(
             'active_ids'))
@@ -72,8 +73,21 @@
             invoice_data = {}
             invoice_data['description'] = service.desc
             invoice_data['party'] = service.patient.name.id
+            invoice_data['type'] = 'out_invoice'
             invoice_data['account'] = \
                 service.patient.name.account_receivable.id
+            
+            journals = Journal.search([
+                ('type', '=', 'revenue'),
+                ], limit=1)
+
+            if journals:
+                journal, = journals
+            else:
+                journal = None
+
+            invoice_data['journal'] = journal.id
+
             party_address = Party.address_get(service.patient.name,
                 type='invoice')
             if not party_address:
@@ -81,6 +95,7 @@
             invoice_data['invoice_address'] = party_address.id 
             invoice_data['reference'] = service.name
 
+
             if not service.patient.name.customer_payment_term:
                 self.raise_user_error('no_payment_term')