Exemplo n.º 1
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'
Exemplo n.º 2
0
class RequestPatientImagingTest(Wizard):
    'Request Patient Imaging Test'
    __name__ = 'gnuhealth.patient.imaging.test.request'

    start = StateView(
        'gnuhealth.patient.imaging.test.request.start',
        'health_imaging.patient_imaging_test_request_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Request', 'request', 'tryton-ok', default=True),
        ])
    request = StateTransition()

    def transition_request(self):
        ImagingTestRequest = Pool().get('gnuhealth.imaging.test.request')
        Sequence = Pool().get('ir.sequence')
        Config = Pool().get('gnuhealth.sequences')

        config = Config(1)
        request_number = Sequence.get_id(config.imaging_request_sequence.id)
        imaging_tests = []
        for test in self.start.tests:
            imaging_test = {}
            imaging_test['request'] = request_number
            imaging_test['requested_test'] = test.id
            imaging_test['patient'] = self.start.patient.id
            if self.start.doctor:
                imaging_test['doctor'] = self.start.doctor.id
            imaging_test['date'] = self.start.date
            imaging_test['urgent'] = self.start.urgent
            imaging_tests.append(imaging_test)
        ImagingTestRequest.create(imaging_tests)

        return 'end'
class RequestPatientLabTest(Wizard):
    'Request Patient Lab Test'
    __name__ = 'gnuhealth.patient.lab.test.request'

    start = StateView('gnuhealth.patient.lab.test.request.start',
        'health_lab.patient_lab_test_request_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Request', 'request', 'tryton-ok', default=True),
            ])
    request = StateTransition()

    def transition_request(self):
        PatientLabTest = Pool().get('gnuhealth.patient.lab.test')
        Sequence = Pool().get('ir.sequence')
        Config = Pool().get('gnuhealth.sequences')

        config = Config(1)
        request_number = Sequence.get_id(config.lab_request_sequence.id)
        lab_tests = []
        for test in self.start.tests:
            lab_test = {}
            lab_test['request'] = request_number
            lab_test['name'] = test.id
            lab_test['patient_id'] = self.start.patient.id
            if self.start.doctor:
                lab_test['doctor_id'] = self.start.doctor.id
            lab_test['date'] = self.start.date
            lab_test['urgent'] = self.start.urgent
            lab_tests.append(lab_test)
        PatientLabTest.create(lab_tests)

        return 'end'
Exemplo n.º 4
0
class PrintIncomeStatement(Wizard):
    'Income Statement Balance'
    __name__ = 'print.income_statement'

    start = StateView(
        'print.income_statement.start',
        'account_report.print_income_statement_start_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Print', 'print_', 'tryton-print', default=True),
        ])
    print_ = StateReport('income_statement.report')

    def do_print_(self, action):
        start_date = self.start.start_date
        end_date = self.start.end_date
        start_date = Date(start_date.year, start_date.month, start_date.day)
        end_date = Date(end_date.year, end_date.month, end_date.day)
        data = {
            'company': self.start.company.id,
            'account': self.start.account.id,
            #'fiscalyear': self.start.fiscalyear.name,
            'start_date': self.start.start_date,
            'end_date': self.start.end_date,
            'omit_zero': self.start.omit_zero,
        }
        action['pyson_context'] = PYSONEncoder().encode({
            'company':
            self.start.company.id,
            'start_date':
            start_date,
            'end_date':
            end_date,
        })
        return action, data
Exemplo n.º 5
0
class QuoteMove(Wizard):
    'Tmi Quote Move'
    __name__ = 'tmi.move.quote'
    
    start_state = 'default'
    default = StateView('tmi.move.quote.default',
        'tmi.tmi_move_quote_default_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Ok', 'cancel', 'tryton-ok', default=True),
            ])
    cancel = StateTransition()

    def transition_cancel(self):
        pool = Pool()
        Move = pool.get('tmi.move')
        Line = pool.get('tmi.move.line')

        moves = Move.browse(Transaction().context['active_ids'])

        for move in moves: 
            description = move.description

        # Write update move state
        Move.write(moves, {
                'description': description, 
                'state': 'draft',
                })
        return 'end' 
class CreateChart(Wizard):
    'Create Chart'
    __name__ = 'analytic_account.create_chart'

    start = StateView('analytic_account.create_chart.start',
        'analytic_account_chart_template.create_chart_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('OK', 'account', 'tryton-ok', default=True),
            ])
    account = StateView('analytic_account.create_chart.account',
        'analytic_account_chart_template.create_chart_account_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Create', 'create_account', 'tryton-ok', default=True),
            ])
    create_account = StateTransition()

    def transition_create_account(self):
        Config = Pool().get('ir.configuration')

        with Transaction().set_context(language=Config.get_language(),
                company=self.account.company.id):
            account_template = self.account.account_template
            company = self.account.company

            # Create accounts
            template2account = {}
            account_template.create_account(
                company.id,
                template2account=template2account)
        return 'end'
Exemplo n.º 7
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'
Exemplo n.º 8
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'
Exemplo n.º 9
0
class HandlePurchaseCancellationException(Wizard):
    'Handle Purchase Cancellation Exception'
    __name__ = 'purchase.request.handle.purchase.cancellation'

    start = StateView('purchase.request.handle.purchase.cancellation.start',
                      'purchase_request.handle_purchase_cancellation_start', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Reset to draft', 'reset', 'tryton-clear'),
                          Button('Cancel Request',
                                 'cancel_request',
                                 'tryton-delete',
                                 default=True),
                      ])
    reset = StateTransition()
    cancel_request = StateTransition()

    def transition_reset(self):
        pool = Pool()
        PurchaseRequest = pool.get('purchase.request')

        requests = PurchaseRequest.browse(Transaction().context['active_ids'])
        for request in requests:
            request.purchase_line = None
        PurchaseRequest.update_state(requests)
        return 'end'

    def transition_cancel_request(self):
        pool = Pool()
        PurchaseRequest = pool.get('purchase.request')

        requests = PurchaseRequest.browse(Transaction().context['active_ids'])
        for request in requests:
            request.exception_ignored = True
        PurchaseRequest.update_state(requests)
        return 'end'
Exemplo n.º 10
0
class SplitMove(Wizard):
    'Split Move'
    __name__ = 'stock.move.split'
    start = StateView('stock.move.split.start',
        'stock_split.split_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Split', 'split', 'tryton-ok', default=True),
            ])
    split = StateTransition()

    def default_start(self, fields):
        pool = Pool()
        Move = pool.get('stock.move')
        default = {}
        move = Move(Transaction().context['active_id'])
        default['uom'] = move.uom.id
        default['unit_digits'] = move.unit_digits
        default['uom_category'] = move.uom.category.id
        return default

    def transition_split(self):
        pool = Pool()
        Move = pool.get('stock.move')
        move = Move(Transaction().context['active_id'])
        move.split(self.start.quantity, self.start.uom, self.start.count)
        return 'end'
Exemplo n.º 11
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
Exemplo n.º 12
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'
Exemplo n.º 13
0
class ShipmentUnassignManual(Wizard):
    "Manual Unassign Shipment"
    __name__ = 'stock.shipment.unassign.manual'
    start = StateTransition()
    show = StateView('stock.shipment.unassign.manual.show',
        'stock_assign_manual.shipment_unassign_manual_show_view_form', [
            Button("Cancel", 'end', 'tryton-cancel'),
            Button("Unassign", 'unassign', 'tryton-ok', default=True),
            ])
    unassign = StateTransition()

    def transition_start(self):
        moves = self.record.assign_moves
        if any(m.state == 'assigned' for m in moves):
            return 'show'
        return 'end'

    def default_show(self, fields):
        moves = self.record.assign_moves
        move_ids = [m.id for m in moves if m.state == 'assigned']
        return {
            'assigned_moves': move_ids,
            }

    def transition_unassign(self):
        moves = []
        quantities = []
        for m in self.show.moves:
            moves.append(m.move)
            quantities.append(m.unassigned_quantity)
        self.record.unassign(moves, quantities)
        return 'end'
Exemplo n.º 14
0
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'
Exemplo n.º 15
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, {}
Exemplo n.º 16
0
class AgreementWizard(Wizard):
    'Agreement Wizard'
    _name = 'auroville_assets.agreement_wizard'

    start = StateView('auroville_assets.wizard1',
                      'auroville_assets.assets_wizard_form1', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Next', 'assets', 'tryton-go-next', True),
                      ])
    assets = StateView('auroville_assets.wizard2',
                       'auroville_assets.assets_wizard_form2', [
                           Button('Cancel', 'end', 'tryton-cancel'),
                           Button('New agreement', 'add', 'tryton-ok', True),
                       ])

    add = StateTransition()

    def transition_add(self, session):
        people_obj = Pool().get('auroville.people')
        assets_obj = Pool().get('auroville.assets')
        user_obj = Pool().get('res.user')

        values = session.data['start'].copy()
        print values

        values = session.data['assets'].copy()
        print values
        #people_id = people_obj.create(values)

        user = user_obj.browse(Transaction().user)
        return 'end'
Exemplo n.º 17
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'
Exemplo n.º 18
0
class SendMessage(Wizard):
    'Send Message'
    __name__ = 'twilio.send_message'
    start_state = 'start'
    start = StateView(
        'twilio.send_message.start',
        'twilio_messages.send_message_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Send', 'send', 'tryton-ok', default=True)
        ])
    send = StateTransition()

    def transition_send(self):
        pool = Pool()
        Message = pool.get('twilio.message')

        message = Message(
            from_=self.start.from_,
            to=self.start.to,
            body=self.start.body,
            resource=self.start.resource
            )
        message.save()
        message.send()

        return 'end'
Exemplo n.º 19
0
class CompanyConfig(Wizard):
    'Configure Company'
    __name__ = 'company.company.config'
    start = StateView('company.company.config.start',
        'company.company_config_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('OK', 'company', 'tryton-ok', True),
            ])
    company = StateView('company.company',
        'company.company_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Add', 'add', 'tryton-ok', True),
            ])
    add = StateTransition()

    def transition_add(self):
        User = Pool().get('res.user')

        self.company.save()
        users = User.search([
                ('main_company', '=', None),
                ])
        User.write(users, {
                'main_company': self.company.id,
                'company': self.company.id,
                })
        return 'end'
class MiPagoCustomerWizard(Wizard):
    'Dunning MiPago Customer'
    __name__ = 'account.dunning.mipago.customer_wizard'
    start = StateView(
        'account.dunning.mipago.customer_wizard.start',
        'account_dunning_mipago.mipago_customer_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Process', 'customer', 'tryton-ok', default=True),
        ])
    customer = StateReport('account.dunning.mipago.customer_report')

    def do_customer(self, action):
        pool = Pool()
        Dunning = pool.get('account.dunning')
        dunnings = Dunning.search([])
        ids = list(
            set([
                d.party.id for d in dunnings
                if not d.blocked and d.party and d.level.mipago
            ]))
        if ids:
            return action, {
                'id': ids[0],
                'ids': ids,
            }
Exemplo n.º 21
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'
Exemplo n.º 22
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'
Exemplo n.º 23
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, {}
Exemplo n.º 24
0
class ModifyCostPrice(Wizard):
    "Modify Cost Price"
    __name__ = 'product.modify_cost_price'
    start = StateView('product.modify_cost_price.start',
                      'stock.product_modify_cost_price_start_form', [
                          Button("Cancel", 'end', 'tryton-cancel'),
                          Button("OK", 'modify', default=True),
                      ])
    modify = StateTransition()

    def transition_modify(self):
        pool = Pool()
        Product = pool.get('product.product')
        Template = pool.get('product.template')
        Revision = pool.get('product.cost_price.revision')
        Date = pool.get('ir.date')
        context = Transaction().context
        today = Date.today()
        revisions = []
        costs = defaultdict(list)
        if context['active_model'] == 'product.product':
            recompute_cost_price = Product.recompute_cost_price
            products = records = Product.browse(context['active_ids'])
            for product in products:
                revision = self.get_revision(Revision)
                revision.product = product
                revision.template = product.template
                revisions.append(revision)
                if ((product.cost_price_method == 'fixed'
                     and revision.date == today) or product.type == 'service'):
                    cost = revision.get_cost_price(product.cost_price)
                    costs[cost].append(product)
                    records.remove(product)
        elif context['active_model'] == 'product.template':
            recompute_cost_price = Template.recompute_cost_price
            templates = records = Template.browse(context['active_ids'])
            for template in templates:
                revision = self.get_revision(Revision)
                revision.template = template
                revisions.append(revision)
                if ((template.cost_price_method == 'fixed'
                     and revision.date == today) or product.type == 'service'):
                    for product in template.products:
                        cost = revision.get_cost_price(product.cost_price)
                        costs[cost].append(product)
                    records.remove(template)
        Revision.save(revisions)
        if costs:
            Product.update_cost_price(costs)
        if records:
            start = min((r.date for r in revisions), default=None)
            recompute_cost_price(records, start=start)
        return 'end'

    def get_revision(self, Revision):
        return Revision(
            company=Transaction().context.get('company'),
            date=self.start.date,
            cost_price=self.start.cost_price,
        )
Exemplo n.º 25
0
class Reasign347Record(Wizard):
    """
    Reasign AEAT 347 Records
    """
    __name__ = "aeat.347.reasign.records"
    start = StateView(
        'aeat.347.reasign.records.start',
        'aeat_347.aeat_347_reasign_start_view', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Reasign', 'reasign', 'tryton-ok', default=True),
        ])
    reasign = StateTransition()
    done = StateView('aeat.347.reasign.records.end',
                     'aeat_347.aeat_347_reasign_end_view', [
                         Button('Ok', 'end', 'tryton-ok', default=True),
                     ])

    def transition_reasign(self):
        Invoice = Pool().get('account.invoice')
        cursor = Transaction().connection.cursor()
        invoice_ids = Transaction().context['active_ids']
        invoices = Invoice.browse(invoice_ids)

        value = self.start.aeat347_operation_key
        invoice = Invoice.__table__()
        # Update to allow to modify key for posted invoices
        cursor.execute(*invoice.update(columns=[
            invoice.aeat347_operation_key,
        ],
                                       values=[value],
                                       where=In(invoice.id, invoice_ids)))

        Invoice.create_aeat347_records(invoices)
        return 'done'
Exemplo n.º 26
0
class ChangeSampleDiagnostician(Wizard):
    'Change Sample Diagnostician'
    __name__ = 'lims.notebook.change_diagnostician'

    start = StateView(
        'lims.notebook.change_diagnostician.start',
        'lims_diagnosis.notebook_change_diagnostician_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Change', 'change', 'tryton-ok', default=True),
        ])
    change = StateTransition()

    def transition_change(self):
        pool = Pool()
        Notebook = pool.get('lims.notebook')
        Sample = pool.get('lims.sample')

        samples_ids = set()
        for notebook in Notebook.browse(Transaction().context['active_ids']):
            samples_ids.add(notebook.fraction.sample.id)
        samples = Sample.browse(list(samples_ids))
        diagnostician = (self.start.diagnostician
                         and self.start.diagnostician.id or None)
        Sample.write(samples, {'diagnostician': diagnostician})
        return 'end'
Exemplo n.º 27
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
Exemplo n.º 28
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'
Exemplo n.º 29
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, {}
Exemplo n.º 30
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