Esempio n. 1
0
class OpenRegion(Wizard):
    "Open Region"
    __name__ = 'sale.reporting.region.open'

    start = StateTransition()
    country = StateAction('sale.act_reporting_country_time_series')
    subdivision = StateAction(
        'sale.act_reporting_country_subdivision_time_series')

    def transition_start(self):
        pool = Pool()
        Region = pool.get('sale.reporting.region')
        Country = pool.get('sale.reporting.country')
        Subdivision = pool.get('sale.reporting.country.subdivision')
        region = Region(Transaction().context['active_id'])
        record = Region.union_unshard(region.id)
        if isinstance(record, Country):
            return 'country'
        elif isinstance(record, Subdivision):
            return 'subdivision'

    def _do_action(self, action):
        pool = Pool()
        Region = pool.get('sale.reporting.region')
        region = Region(Transaction().context['active_id'])
        record = Region.union_unshard(region.id)
        data = {
            'id': record.id,
            'ids': [record.id],
        }
        action['name'] += ' (%s)' % record.rec_name
        return action, data

    do_country = _do_action
    do_subdivision = _do_action
    def do_print_(self, action):
        fiscalyear = (self.start.fiscalyear.id
                      if self.start.fiscalyear else None)
        if self.start.start_date:
            fiscalyear = None

        data = {
            'company': self.start.company.id,
            'fiscalyear': fiscalyear,
            'start_date': self.start.start_date,
            'end_date': self.start.end_date,
            'periods': [x.id for x in self.start.periods],
            'parties': [x.id for x in self.start.parties],
            'output_format': self.start.output_format,
            'partner_type': self.start.partner_type,
            'totals_only': self.start.totals_only,
            'grouping': self.start.grouping,
            'tax_type': self.start.tax_type,
        }

        if data['grouping'] == 'invoice':
            state_action = StateAction('account_jasper_reports.'
                                       'report_taxes_by_invoice_and_period')
            action = state_action.get_action()
        return action, data
class OpenEvaluations(Wizard):
    'Open Evaluations'
    __name__ = 'gnuhealth.evaluations.open'

    start = StateView('gnuhealth.evaluations.open.start',
                      'health_reporting.evaluations_open_start_view_form', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Open', 'select', 'tryton-ok', default=True),
                      ])
    select = StateTransition()
    open_doctor = StateAction('health_reporting.act_evaluations_doctor')
    open_specialty = StateAction('health_reporting.act_evaluations_specialty')
    open_sector = StateAction('health_reporting.act_evaluations_sector')

    def transition_select(self):
        return 'open_' + self.start.group_by

    def do_open_doctor(self, action):
        action['pyson_context'] = PYSONEncoder().encode({
            'start_date':
            self.start.start_date,
            'end_date':
            self.start.end_date,
        })
        return action, {}

    def do_open_specialty(self, action):
        action['pyson_context'] = PYSONEncoder().encode({
            'start_date':
            self.start.start_date,
            'end_date':
            self.start.end_date,
        })
        return action, {}

    def do_open_sector(self, action):
        action['pyson_context'] = PYSONEncoder().encode({
            'start_date':
            self.start.start_date,
            'end_date':
            self.start.end_date,
        })
        return action, {}

    def transition_open_doctor(self):
        return 'end'

    def transition_open_specialty(self):
        return 'end'

    def transition_open_sector(self):
        return 'end'
Esempio n. 4
0
class ExportShipmentStatus(Wizard):
    """
    Export Shipment Status Wizard

    Exports shipment status for sale orders related to current store view
    """
    __name__ = 'magento.wizard_export_shipment_status'

    start = StateView(
        'magento.wizard_export_shipment_status.start',
        'magento.wizard_export_shipment_status_view_start_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Continue', 'export_', 'tryton-ok', default=True),
        ])

    export_ = StateAction('sale.act_sale_form')

    def do_export_(self, action):
        """Handles the transition"""

        StoreView = Pool().get('magento.store.store_view')

        storeview = StoreView(Transaction().context.get('active_id'))

        sales = storeview.export_shipment_status_to_magento()

        action['pyson_domain'] = PYSONEncoder().encode([('id', 'in',
                                                         map(int, sales))])
        return action, {}

    def transition_export_(self):
        return 'end'
Esempio n. 5
0
class PrintReportTransfer(Wizard):
    'Print Report Transfer '
    __name__ = 'print_report_transfer'
    start = StateView(
        'print_report_transfer.start',
        'nodux_purchase_product_stock_one.print_transfer_report_start_view_form',
        [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Print', 'print_', 'tryton-print', default=True),
        ])
    print_ = StateAction('nodux_purchase_product_stock_one.report_transfer')

    def do_print_(self, action):
        if self.start.product:
            data = {
                'company': self.start.company.id,
                'all_products': self.start.all_products,
                'product': self.start.product.id,
                'date': self.start.date,
                'date_end': self.start.date_end,
            }
        else:
            data = {
                'company': self.start.company.id,
                'all_products': self.start.all_products,
                'product': None,
                'date': self.start.date,
                'date_end': self.start.date_end,
            }
        return action, data

    def transition_print_(self):
        return 'end'
class OpenTotal(Wizard):
    'Open Total'
    __name__ = 'nodux_electronic_invoice_auth.print_total'
    
    start = StateView('nodux_electronic_invoice_auth.print_total_voucher.start',
        'nodux_electronic_invoice_auth.print_total_voucher_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Print', 'print_', 'tryton-ok', default=True),
            ])
    print_ = StateAction('nodux_electronic_invoice_auth.report_total_voucher')
    
    def do_print_(self, action):
        if self.start.start_period:
            start_period = self.start.start_period.id
        else:
            start_period = None
        if self.start.end_period:
            end_period = self.start.end_period.id
        else:
            end_period = None
            
        if self.start.party:
            start_party = self.start.party.id
        else:
            start_party = None
        data = {
            'party': start_party,
            'fiscalyear': self.start.fiscalyear.id,
            'start_period': start_period,
            'end_period': end_period,
            }
        return action, data

    def transition_print_(self):
        return 'end'
Esempio n. 7
0
class OpenSamplesComparator(Wizard):
    'Samples Comparator'
    __name__ = 'lims.samples_comparator.open'

    start = StateTransition()
    ask = StateView('lims.samples_comparator.ask',
                    'lims_diagnosis.samples_comparator_ask_form', [
                        Button('Cancel', 'end', 'tryton-cancel'),
                        Button('Open', 'open_', 'tryton-ok', default=True),
                    ])
    open_ = StateAction('lims_diagnosis.act_samples_comparator')

    def transition_start(self):
        ResultsSample = Pool().get('lims.results_report.version.detail.sample')
        active_model = Transaction().context['active_model']
        if active_model == 'lims.results_report.version.detail.sample':
            sample = ResultsSample(Transaction().context['active_id'])
            self.ask.notebook = sample.notebook.id
            return 'open_'
        return 'ask'

    def do_open_(self, action):
        SamplesComparator = Pool().get('lims.samples_comparator')
        notebook = self.ask.notebook
        lines = [{'notebook_line': l.id} for l in notebook.lines]
        comparison = SamplesComparator.create([{
            'notebook': notebook.id,
            'lines': [('create', lines)],
        }])[0]
        action['res_id'] = [comparison.id]
        return action, {}

    def transition_open_(self):
        return 'end'
Esempio n. 8
0
class LabDeviceGenerateMaintenance(Wizard):
    'Generate Device Maintenance Calendar'
    __name__ = 'lims.lab.device.maintenance.generate'

    start_state = 'open'
    open = StateAction(
        'lims_device_maintenance.act_lab_device_maintenance_calendar_related')

    def do_open(self, action):
        pool = Pool()
        MaintenanceProgram = pool.get('lims.lab.device.maintenance.program')
        Maintenance = pool.get('lims.lab.device.maintenance')

        programs = MaintenanceProgram.browse(
            Transaction().context['active_ids'])
        maintenances = MaintenanceProgram.create_events(
            programs, MaintenanceProgram._create_maintenances)
        if maintenances:
            Maintenance.save(maintenances)
            Maintenance.pending(maintenances)

        action['pyson_domain'] = PYSONEncoder().encode([
            ('id', 'in', [m.id for m in maintenances]),
        ])
        return action, {}

    def transition_open(self):
        return 'end'
Esempio n. 9
0
class TestWizard(Wizard):
    'Test Wizard'
    __name__ = 'test.test_wizard'
    start = StateView('test.test_wizard.start',
        'tests.test_wizard_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Next', 'next_', 'tryton-next', default=True),
            ])
    next_ = StateTransition()
    action = StateAction('ir.act_menu_tree')

    @staticmethod
    def default_start(fields):
        return {
            'name': 'Test wizard',
            }

    @staticmethod
    def transition_next_():
        return 'action'

    @staticmethod
    def do_action(action):
        return action, {}

    @staticmethod
    def transition_action():
        return 'end'
class WithholdingOut(Wizard):
    'Withholding Out'
    __name__ = 'nodux_account_withholding_ec.out_withholding'
    #crear referencias:
    start = StateView('nodux_account_withholding_ec.out_withholding.start',
        'nodux_account_withholding_out_ec.out_withholding_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Withholding', 'withholdingOut', 'tryton-ok', default=True),
            ])
    withholdingOut = StateAction('nodux_account_withholding_out_ec.act_withholding_form')

    @classmethod
    def __setup__(cls):
        super(WithholdingOut, cls).__setup__()

    def do_withholdingOut(self, action):
        pool = Pool()
        Invoice = pool.get('account.invoice')

        invoices = Invoice.browse(Transaction().context['active_ids'])
        for invoice in invoices:
            if invoice.type != 'out':
                self.raise_user_error('No puede generar un comprobante de retencion de cliente desde Factura de Proveedor')

        out_withholding = Invoice.withholdingOut(invoices)

        data = {'res_id': [i.id for i in out_withholding]}
        if len(out_withholding) == 1:
            action['views'].reverse()

        return action, data
Esempio n. 11
0
class OpenJournalCash(Wizard):
    'Open Journal Cash'
    __name__ = 'account.journal.open_cash'
    start = StateView('account.journal.open_cash.start',
                      'account.journal_open_cash_start_view_form', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Open', 'open_', 'tryton-ok', default=True),
                      ])
    open_ = StateAction('account.act_journal_open_cash')

    def do_open_(self, action):
        pool = Pool()
        Lang = pool.get('ir.lang')

        lang, = Lang.search([
            ('code', '=', Transaction().language),
        ])

        action['pyson_context'] = PYSONEncoder().encode({
            'start_date':
            self.start.start_date,
            'end_date':
            self.start.end_date,
        })
        action['name'] += ' %s - %s' % (
            Lang.strftime(self.start.start_date, lang.code, lang.date),
            Lang.strftime(self.start.end_date, lang.code, lang.date))
        return action, {}
Esempio n. 12
0
class OpenMoveLineBalance(Wizard):
    'Open Type'
    __name__ = 'account.move.line.balance'

    start_state = 'open_'
    open_ = StateAction('current_account.act_move_line_balance')

    def do_open_(self, action):
        Party = Pool().get('party.party')

        party = Party(Transaction().context['active_id'])

        action['pyson_domain'] = PYSONEncoder().encode([
            ('party', '=', Transaction().context['active_id']),
            [
                'OR', ('account.type.payable', '=', True),
                ('account.type.receivable', '=', True)
            ],
        ])
        action['pyson_context'] = PYSONEncoder().encode({
            'party':
            Transaction().context['active_id'],
            'account_kind': ['payable', 'receivable'],
        })
        action['name'] = 'Cuenta corriente - %s' % (party.name)
        return action, {}
Esempio n. 13
0
class CreateInventories(Wizard):
    'Create Inventories'
    __name__ = 'stock.inventory.create'
    start = StateView(
        'stock.inventory.create.start',
        'stock_inventory_location.inventory_create_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Create', 'create_', 'tryton-ok', default=True),
        ])
    create_ = StateAction('stock.act_inventory_form')

    def get_inventory(self, location, Inventory):
        return Inventory(location=location,
                         date=self.start.date,
                         company=self.start.company,
                         empty_quantity=self.start.empty_quantity)

    def do_create_(self, action):
        pool = Pool()
        Inventory = pool.get('stock.inventory')

        inventories = [
            self.get_inventory(location, Inventory)
            for location in self.start.locations
        ]
        Inventory.save(inventories)

        if self.start.complete_lines:
            Inventory.complete_lines(inventories)

        data = {'res_id': [i.id for i in inventories]}
        return action, data
Esempio n. 14
0
class OpenSheetSample(Wizard):
    'Open Sheet Sample'
    __name__ = 'lims.planification.professional.open_sheet_sample'
    start_state = 'open_'
    open_ = StateAction('lims.act_lims_sample_list')

    def do_open_(self, action):
        pool = Pool()
        Sheet = pool.get('lims.analysis_sheet')
        Data = pool.get('lims.interface.data')

        sheet = Sheet(Transaction().context['active_id'])

        with Transaction().set_context(
                lims_interface_table=sheet.compilation.table.id):
            lines = Data.search([('compilation', '=', sheet.compilation.id)])
            samples = []
            for line in lines:
                nl = line.notebook_line
                if not nl:
                    continue
                if nl.sample.id not in samples:
                    samples.append(nl.sample.id)

        action['pyson_domain'] = [
            ('id', 'in', samples),
            ]
        action['pyson_domain'] = PYSONEncoder().encode(action['pyson_domain'])
        return action, {}
Esempio n. 15
0
class GenerateAdministrativeTask(Wizard):
    'Generate Administrative Tasks Calendar'
    __name__ = 'lims.administrative.task.generate'

    start_state = 'open'
    open = StateAction('lims_administrative_task.act_task')

    def do_open(self, action):
        pool = Pool()
        TaskProgram = pool.get('lims.administrative.task.program')
        AdministrativeTask = pool.get('lims.administrative.task')

        programs = TaskProgram.browse(Transaction().context['active_ids'])
        tasks = TaskProgram.create_events(programs, TaskProgram._create_tasks)
        if tasks:
            AdministrativeTask.save(tasks)
            AdministrativeTask.pending(tasks)

        action['pyson_domain'] = PYSONEncoder().encode([
            ('id', 'in', [t.id for t in tasks]),
        ])
        return action, {}

    def transition_open(self):
        return 'end'
Esempio n. 16
0
class PrintSalesmanReport(Wizard):
    'Print Sale Report'
    __name__ = 'nodux_sale_pos_salesman.print_sale_report'
    start = StateView(
        'nodux_sale_pos_salesman.print_sale_report.start',
        'nodux_sale_pos_salesman.print_sale_report_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Print', 'print_', 'tryton-print', default=True),
        ])
    print_ = StateAction('nodux_sale_pos_salesman.report_sale_report')

    def do_print_(self, action):
        if self.start.employee:
            data = {
                'company': self.start.company.id,
                'date': self.start.date,
                'date_end': self.start.date_end,
                'employee': self.start.employee.id,
                'paid': self.start.paid
            }
        else:
            data = {
                'company': self.start.company.id,
                'date': self.start.date,
                'employee': None,
                'date_end': self.start.date_end,
                'paid': self.start.paid
            }
        return action, data

    def transition_print_(self):
        return 'end'
Esempio n. 17
0
class OpenInvoice(Wizard):
    'Open Invoice'
    __name__ = 'project.open_invoice'
    start_state = 'open_'
    open_ = StateAction('account_invoice.act_invoice_form')

    def do_open_(self, action):
        pool = Pool()
        Work = pool.get('project.work')
        works = Work.search([
                ('parent', 'child_of', Transaction().context['active_ids']),
                ])
        invoice_ids = set()
        for work in works:
            if work.invoice_line and work.invoice_line.invoice:
                invoice_ids.add(work.invoice_line.invoice.id)
            for twork in work.timesheet_works:
                for timesheet_line in twork.timesheet_lines:
                    if (timesheet_line.invoice_line
                            and timesheet_line.invoice_line.invoice):
                        invoice_ids.add(timesheet_line.invoice_line.invoice.id)
            if work.invoiced_progress:
                for progress in work.invoiced_progress:
                    invoice_ids.add(progress.invoice_line.invoice.id)
        encoder = PYSONEncoder()
        action['pyson_domain'] = encoder.encode(
            [('id', 'in', list(invoice_ids))])
        action['pyson_search_value'] = encoder.encode([])
        return action, {}
Esempio n. 18
0
class ServiceUtilisationWizard(Wizard):
    '''Service Utilisation Report Wizard'''
    __name__ = 'healthjm_primarycare.report.service_utilisation.wizard'
    start = StateView(
        'healthjm_primarycare.report.service_utilisation.start',
        'health_jamaica_primarycare.report_service_utilisation_start', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Generate report',
                   'generate_report',
                   'tryton-ok',
                   default=True)
        ])

    generate_report = StateAction(
        'health_jamaica_primarycare.jmreport_service_utilisation')

    def transition_generate_report(self):
        return 'end'

    def do_generate_report(self, action):
        data = {
            'start_date': self.start.on_or_after,
            'end_date': self.start.on_or_after
        }

        if self.start.on_or_before:
            data['end_date'] = self.start.on_or_before

        if self.start.institution:
            data['institution'] = self.start.institution.id
        else:
            self.start.raise_user_error('required_institution')
            return 'start'

        return action, data
Esempio n. 19
0
class ExportMagentoInventory(Wizard):
    """
    Export Inventory Wizard

    Export product stock information to magento for the current website
    """
    __name__ = 'magento.wizard_export_inventory'

    start = StateView(
        'magento.wizard_export_inventory.start',
        'magento.wizard_export_magento_inventory_view_start_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Continue', 'export_', 'tryton-ok', default=True),
        ])

    export_ = StateAction('product.act_template_form')

    def do_export_(self, action):
        """
        Handles the transition
        """

        Channel = Pool().get('sale.channel')

        channel = Channel.get_current_magento_channel()

        product_templates = channel.export_inventory_to_magento()

        action['pyson_domain'] = PYSONEncoder().encode([
            ('id', 'in', map(int, product_templates))
        ])
        return action, {}

    def transition_export_(self):
        return 'end'
Esempio n. 20
0
class CheckImmunizationStatus(Wizard):
    'Check Immunization Status'
    __name__ = 'gnuhealth.check_immunization_status'

    start = StateView(
        'gnuhealth.check_immunization_status.init',
        'health.view_check_immunization_status', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Immunization Status', 'check_immunization_status',
                   'tryton-ok', True),
        ])
    check_immunization_status = StateAction(
        'health.report_immunization_status')

    def do_check_immunization_status(self, action):
        return action, self.get_info()

    def get_info(self):

        return {
            'patient_id': Transaction().context.get('active_id'),
            'immunization_schedule_id': self.start.immunization_schedule.id
        }

    def transition_check_immunization_status(self):
        return 'end'
Esempio n. 21
0
class CreateInvoice(Wizard):
    'Create Commission Invoice'
    __name__ = 'commission.create_invoice'
    start_state = 'ask'
    ask = StateView('commission.create_invoice.ask',
                    'commission.commission_create_invoice_ask_view_form', [
                        Button('Cancel', 'end', 'tryton-cancel'),
                        Button('OK', 'create_', 'tryton-ok', default=True),
                    ])
    create_ = StateAction('account_invoice.act_invoice_form')

    def get_domain(self):
        domain = [('invoice_line', '=', None)]
        if self.ask.from_:
            domain.append(('date', '>=', self.ask.from_))
        if self.ask.to:
            domain.append(('date', '<=', self.ask.to))
        if self.ask.type_ == 'in':
            domain.append(('agent.type_', '=', 'principal'))
        elif self.ask.type_ == 'out':
            domain.append(('agent.type_', '=', 'agent'))
        return domain

    def do_create_(self, action):
        pool = Pool()
        Commission = pool.get('commission')
        commissions = Commission.search(self.get_domain(),
                                        order=[('agent', 'DESC'),
                                               ('date', 'DESC')])
        Commission.invoice(commissions)
        invoice_ids = list({c.invoice_line.invoice.id for c in commissions})
        encoder = PYSONEncoder()
        action['pyson_domain'] = encoder.encode([('id', 'in', invoice_ids)])
        action['pyson_search_value'] = encoder.encode([])
        return action, {}
Esempio n. 22
0
class CreateInventories(Wizard):
    'Create Inventories'
    __name__ = 'stock.inventory.create'
    start = StateView(
        'stock.inventory.create.start',
        'stock_inventory_location.inventory_create_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Create', 'create_', 'tryton-ok', default=True),
        ])
    create_ = StateAction('stock.act_inventory_form')

    def do_create_(self, action):
        Inventory = Pool().get('stock.inventory')

        to_create = []
        for location in self.start.locations:
            to_create.append({
                'location': location.id,
                'date': self.start.date,
                'lost_found': self.start.lost_found.id,
                'company': self.start.company.id,
            })
        if to_create:
            inventories = Inventory.create(to_create)

        Inventory.complete_lines(inventories)

        data = {'res_id': [i.id for i in inventories]}
        return action, data
Esempio n. 23
0
class WizardGenerateResult(Wizard):
    'Generate Results'
    __name__ = 'wizard.generate.result'
    start_state = 'open_'
    open_ = StateAction('health_imaging.act_imaging_test_result_view')

    def do_open_(self, action):
        pool = Pool()
        Request = pool.get('gnuhealth.imaging.test.request')
        Result = pool.get('gnuhealth.imaging.test.result')

        request_data = []
        requests = Request.browse(Transaction().context.get('active_ids'))
        for request in requests:
            request_data.append({
                'patient': request.patient.id,
                'date': datetime.now(),
                'request_date': request.date,
                'requested_test': request.requested_test,
                'request': request.id,
                'doctor': request.doctor
            })
        results = Result.create(request_data)

        action['pyson_domain'] = PYSONEncoder().encode([
            ('id', 'in', [r.id for r in results])
        ])

        Request.requested(requests)
        Request.done(requests)
        return action, {}
Esempio n. 24
0
class CaseCountWizard(Wizard):
    __name__ = 'health_disease_notification.case_count_wizard'
    start = StateView(
        'gnuhealth.disease_notification.report.case_count_start',
        'health_disease_notification.view_form-case_count_start',
        [Button('Cancel', 'end', 'tryton-cancel'),
         Button('Generate report', 'generate_report', 'tryton-ok',
                default=True)])
    generate_report = StateAction(
        'health_disease_notification.reptnotif_case_count')

    def transition_generate_report(self):
        return 'end'

    def do_generate_report(self, action):
        data = {'start_date': self.start.on_or_after,
                'end_date': self.start.on_or_after,
                'state': self.start.state}

        if self.start.on_or_before:
            data['end_date'] = self.start.on_or_before

        # if self.start.institution:
        #     data['institution'] = self.start.institution.id
        # else:
        #     self.start.raise_user_error('required_institution')
        #     return 'start'

        return action, data
Esempio n. 25
0
class OpenTopDiseases(Wizard):
    'Open Top Diseases'
    __name__ = 'gnuhealth.top_diseases.open'

    start = StateView('gnuhealth.top_diseases.open.start',
                      'health_reporting.top_diseases_open_start_view_form', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Open', 'open_', 'tryton-ok', default=True),
                      ])
    open_ = StateAction('health_reporting.act_top_diseases_form')

    def do_open_(self, action):
        action['pyson_context'] = PYSONEncoder().encode({
            'start_date':
            self.start.start_date,
            'end_date':
            self.start.end_date,
            'group':
            self.start.group.id if self.start.group else None,
            'number_records':
            self.start.number_records,
        })
        return action, {}

    def transition_open_(self):
        return 'end'
Esempio n. 26
0
class GetRenumerationBill(Wizard):
    '''Get TA/DA Bill for employee'''
    
    __name__ = 'exam.get_renumeration_bill'

    start_state = 'details'
    details = StateView(
        'exam.get_renumeration_bill.view',
        'exam_section.form_get_renumeration_bill',
        [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('OK', 'save_details', 'tryton-go-next', default=True)
        ]
    )
    save_details = StateTransition()
    fill = StateAction('exam_section.act_renumeration_bill')

    def transition_save_details(self):
        Employee = Pool().get('exam.employees')
        current_employee = Employee.search([
                ('employee', '=', self.details.employee),
                ('exam', '=', self.details.exam)
            ])[0]
        self.details.renumeration_bill = \
            current_employee.renumeration_bill    
        return 'fill'        
    
    def do_fill(self, action):
        action['pyson_domain'] = PYSONEncoder().encode([
            ('id', '=', self.details.renumeration_bill.id)
        ])
        return action, {}
Esempio n. 27
0
class EnterLines(Wizard):
    'Enter Lines'
    __name__ = 'timesheet.line.enter'
    start = StateView('timesheet.line.enter.start',
                      'timesheet.line_enter_start_view_form', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Enter', 'enter', 'tryton-ok', default=True),
                      ])
    enter = StateAction('timesheet.act_line_form')

    def do_enter(self, action):
        date = self.start.date
        date = Date(date.year, date.month, date.day)
        action['pyson_domain'] = PYSONEncoder().encode([
            ('employee', '=', self.start.employee.id),
            ('company', '=', self.start.employee.company.id),
            ('date', '=', date),
        ])
        action['pyson_context'] = PYSONEncoder().encode({
            'employee':
            self.start.employee.id,
            'company':
            self.start.employee.company.id,
            'date':
            date,
        })
        action['name'] += " - " + self.start.employee.rec_name
        return action, {}

    def transition_enter(self):
        return 'end'
Esempio n. 28
0
class Checkout(Wizard):
    "Stripe Checkout"
    __name__ = 'account.payment.stripe.checkout'
    start_state = 'checkout'
    checkout = StateAction('account_payment_stripe.url_checkout')

    def do_checkout(self, action):
        pool = Pool()
        Payment = pool.get('account.payment')
        Customer = pool.get('account.payment.stripe.customer')
        context = Transaction().context
        active_model = context['active_model']
        active_id = context['active_id']
        if active_model == Payment.__name__:
            Model = Payment
        elif active_model == Customer.__name__:
            Model = Customer
        else:
            raise ValueError("Invalid active_model: %s" % active_model)
        record = Model(active_id)
        database = Transaction().database.name
        action['url'] = action['url'] % {
            'hostname': HOSTNAME,
            'database': database,
            'model': active_model,
            'id': record.stripe_checkout_id,
        }
        return action, {}
Esempio n. 29
0
class SummaryReport(Wizard):
    'Open Institution Summary Report'
    __name__ = 'gnuhealth.summary.report.open'

    start = StateView('gnuhealth.summary.report.open.start',
        'health_reporting.summary_report_open_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Open', 'open_', 'tryton-ok', default=True),
            ])
    
    open_ = StateAction('health_reporting.report_summary_information')

    def fill_data(self):
        return {
            'institution': (self.start.institution.id
                    if self.start.institution else None),
            'start_date': self.start.start_date,
            'end_date': self.start.end_date,
            'demographics': self.start.demographics,
            'patient_evaluations': self.start.patient_evaluations,
        }
    
    def do_open_(self, action):
        return action, self.fill_data()
            
    def transition_open_(self):
        return 'end'
Esempio n. 30
0
class ProductsByLocations(Wizard):
    'Products by Locations'
    __name__ = 'stock.products_by_locations'
    start = StateView('stock.products_by_locations.start',
                      'stock.products_by_locations_start_view_form', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Open', 'open', 'tryton-ok', True),
                      ])
    open = StateAction('stock.act_products_by_locations')

    def do_open(self, action):
        pool = Pool()
        Location = pool.get('stock.location')
        Lang = pool.get('ir.lang')

        context = {}
        context['locations'] = Transaction().context.get('active_ids')
        date = self.start.forecast_date or datetime.date.max
        context['stock_date_end'] = Date(date.year, date.month, date.day)
        action['pyson_context'] = PYSONEncoder().encode(context)

        locations = Location.browse(context['locations'])

        for code in [Transaction().language, 'en_US']:
            langs = Lang.search([
                ('code', '=', code),
            ])
            if langs:
                break
        lang = langs[0]
        date = Lang.strftime(date, lang.code, lang.date)

        action['name'] += ' - (%s) @ %s' % (','.join(l.name
                                                     for l in locations), date)
        return action, {}
Esempio n. 31
0
 def __init__(self):
     StateAction.__init__(self, None)