class SubscriptionRecomputePrice(Wizard):
    'Subscription Recompute Price'
    __name__ = 'sale.subscription.recompute_price'

    start = StateView(
        'sale.subscription.recompute_price.start',
        'sale_subscription_recompute_price.recompute_price_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Recompute', 'recompute_', 'tryton-ok', default=True),
        ])
    recompute_ = StateTransition()

    def get_additional_args(self):
        method_name = 'get_additional_args_%s' % self.start.method
        if not hasattr(self, method_name):
            return {}
        return getattr(self, method_name)()

    def get_additional_args_fixed_amount(self):
        return {
            'unit_price': self.start.unit_price,
        }

    def get_additional_args_percentage(self):
        return {
            'percentage': self.start.percentage,
        }

    def transition_recompute_(self):
        pool = Pool()
        Line = pool.get('sale.subscription.line')

        method_name = 'recompute_price_by_%s' % self.start.method
        method = getattr(Line, method_name)
        if method:
            domain = [
                ('subscription.state', '=', 'running'),
                ('subscription', 'not in', self.start.subscriptions),
            ]
            if self.start.start_date:
                domain.append(('start_date', '<=', self.start.start_date))
            if self.start.services:
                services = [s.id for s in list(self.start.services)]
                domain.append(('service', 'in', services))
            method(Line.search(domain), **self.get_additional_args())
        return 'end'
Ejemplo n.º 2
0
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'
Ejemplo n.º 3
0
class WizardCombustible(Wizard):
    'Wizard Combustible'
    __name__ = 'oci.wizard.combustible'

    start = StateView('oci.desde.hasta.fechas', 'oci.oci_desde_hasta_fechas', [
        Button('Cancel', 'end', 'tryton-cancel'),
        Button('OK', 'print_', 'tryton-ok', default=True),
    ])

    print_ = StateReport('oci.report.combustible')

    def do_print_(self, action):
        data = {
            'fecha1': self.start.fecha1,
            'fecha2': self.start.fecha2,
        }
        return action, data
Ejemplo n.º 4
0
class InternalRelieveWizard(Wizard):
    __name__ = 'hrp_internal_delivery.internal_relieve_wizard'

    start = StateView('hrp_internal_delivery.internal_relieve',
        'hrp_internal_delivery.internal_relieve_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Create', 'create_', 'tryton-ok', default=True),
            ])
    create_ = StateAction('stock.act_internal_relieve')
    def do_create_(self, action):
        internal = Pool().get('hrp_internal_delivery.shipment.internal')
        data = {}
        for state_name,state in self.states.iteritems():
            if isinstance(state, StateView):
                data[state_name] = getattr(self, state_name)._default_values
        lv = {}
        lv['to_location'] = data['start']['to_location']
        lv['reference'] = data['start']['reference']
        lv['from_location'] = data['start']['from_location']
        lv['planned_date'] = data['start']['planned_date']
        lv['company'] = data['start']['company']
        lv['number'] = data['start']['number']
        lv['state'] = data['start']['state']
        Move = data['start']['moves']
        list = []
        for each in Move:
            dict = {}
            dict['starts'] = each['starts']
            dict['origin'] = each['origin']
            dict['to_location'] = each['to_location']
            dict['product'] = each['product']
            dict['from_location'] = each['from_location']
            dict['invoice_lines'] = each['invoice_lines']
            dict['is_direct_sending'] = each['is_direct_sending']
            dict['planned_date'] = each['planned_date']
            dict['company'] = each['company']
            dict['unit_price'] = each['unit_price']
            dict['currency'] = each['currency']
            dict['lot'] = each['lot']
            dict['uom'] = each['uom']
            dict['quantity'] = each['quantity']
            list.append(dict)
            lv['moves'] = [['create',list]]
            lv['effective_date'] = data['start']['effective_date']
        internal.create([lv])
        return action,{}
Ejemplo n.º 5
0
class CreateMoves(Wizard):
    'Create Moves'
    __name__ = 'account.asset.create_moves'
    start = StateView('account.asset.create_moves.start',
                      'account_asset.asset_create_moves_start_view_form', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('OK', 'create_moves', 'tryton-ok', True),
                      ])
    create_moves = StateTransition()

    def transition_create_moves(self):
        Asset = Pool().get('account.asset')
        assets = Asset.search([
            ('state', '=', 'running'),
        ])
        Asset.create_moves(assets, self.start.date)
        return 'end'
Ejemplo n.º 6
0
class AddKeys(Wizard):
    'Add Keys'
    __name__ = 'company.add_keys'
    start = StateView('company.add_keys.start',
            'account_electronic_invoice_ec.add_keys_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Add', 'accept', 'tryton-ok', default=True),
            ])
    accept = StateTransition()

    def transition_accept(self):
        pool = Pool()
        Company = pool.get('company.company')
        company = Company(Transaction().context['active_id'])
        if company:
            Company.write([company], {'contingency_keys': str(self.start.keys)})
        return 'end'
Ejemplo n.º 7
0
class CreatePeriods(Wizard):
    "Create Periods"
    __name__ = 'account.fiscalyear.create_periods'
    start = StateView(
        'account.fiscalyear.create_periods.start',
        'account.fiscalyear_create_periods_start_view_form', [
            Button("Cancel", 'end', 'tryton-cancel'),
            Button("Create", 'create_periods', 'tryton-ok', default=True),
        ])
    create_periods = StateTransition()

    def transition_create_periods(self):
        FiscalYear = Pool().get('account.fiscalyear')
        fiscalyear = FiscalYear(Transaction().context['active_id'])
        FiscalYear.create_period([fiscalyear], self.start.interval,
                                 self.start.end_day)
        return 'end'
class ProductionScheduleReportWizard(Wizard):
    'Generate Production Schedule Report Wizard'
    __name__ = 'report.production.schedule.wizard'

    start = StateView(
        'report.production.schedule.wizard.start',
        'production_report.report_production_schedule_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Generate', 'generate', 'tryton-ok', default=True),
        ]
    )
    generate = StateAction(
        'production_report.report_production_schedule'
    )

    def do_generate(self, action):
        """
        Return report action and the data to pass to it
        """
        Production = Pool().get('production')

        domain = [
            ('state', 'not in', ['request', 'cancel']),
            [
                'OR',
                ('effective_date', '>=', self.start.start_date),
                ('planned_date', '>=', self.start.start_date)
            ],
            [
                'OR',
                ('effective_date', '<=', self.start.end_date),
                ('planned_date', '<=', self.start.end_date)
            ],
        ]

        productions = Production.search(domain)

        data = {
            'productions': map(int, productions),
            'start_date': self.start.start_date,
            'end_date': self.start.end_date
        }
        return action, data

    def transition_generate(self):
        return 'end'
Ejemplo n.º 9
0
class CheckMandates(Wizard):
    'Check Mandates List'
    __name__ = 'condo.check_mandates'
    start_state = 'check'

    check = StateTransition()
    result = StateView(
        'condo.check_mandates.result',
        'condominium_payment_sepa.check_mandates_result',
        [Button('OK', 'end', 'tryton-ok', True)],
    )

    def transition_check(self):

        pool = Pool()
        Unit = pool.get('condo.unit')
        Mandate = pool.get('condo.payment.sepa.mandate')

        mandates = Mandate.search_read(
            [
                [
                    'OR',
                    ('company', 'in', Transaction().context.get('active_ids')),
                    ('company.parent', 'child_of', Transaction().context.get('active_ids')),
                ],
                ('state', 'not in', ('canceled',)),
                ('condoparties', '=', None),
            ],
            fields_names=['id'],
        )

        units = Unit.search_read(
            [
                'OR',
                ('company', 'in', Transaction().context.get('active_ids')),
                ('company.parent', 'child_of', Transaction().context.get('active_ids')),
            ],
            fields_names=['id'],
        )

        units_with_mandate = Unit.search_read(
            [
                [
                    'OR',
                    ('company', 'in', Transaction().context.get('active_ids')),
                    ('company.parent', 'child_of', Transaction().context.get('active_ids')),
                ],
                ('condoparties.mandate', '!=', None),
            ],
            fields_names=['id'],
        )

        self.result.mandates = [r['id'] for r in mandates]
        self.result.units = [r['id'] for r in units if r not in units_with_mandate]
        return 'result'

    def default_result(self, fields):
        return {'mandates': [p.id for p in self.result.mandates], 'units': [p.id for p in self.result.units]}
Ejemplo n.º 10
0
class CreateProductionRequest(Wizard):
    'Create Production Requests'
    __name__ = 'production.create_request'
    start = StateView(
        'production.create_request.start',
        'stock_supply_production.production_create_request_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Create', 'create_', 'tryton-ok', default=True),
        ])
    create_ = StateAction('stock_supply_production.act_production_request')

    @classmethod
    def __setup__(cls):
        super(CreateProductionRequest, cls).__setup__()
        cls._error_messages.update({
            'late_productions':
            'There are some late productions.',
        })

    @property
    def _requests_parameters(self):
        return {}

    def do_create_(self, action):
        pool = Pool()
        Date = pool.get('ir.date')
        Move = pool.get('stock.move')
        Production = pool.get('production')

        today = Date.today()
        if Move.search([
            ('from_location.type', '=', 'production'),
            ('to_location.type', '=', 'storage'),
            ('state', '=', 'draft'),
            ('planned_date', '<', today),
        ],
                       order=[]):
            self.raise_user_warning('%s@%s' % (self.__name__, today),
                                    'late_productions')

        Production.generate_requests(**self._requests_parameters)
        return action, {}

    def transition_create_(self):
        return 'end'
Ejemplo n.º 11
0
class OpenPediatricsGrowthChartsWHOReport(Wizard):
    'Open Pediatrics Growth Charts WHO Report'
    __name__ = 'gnuhealth.pediatrics.growth.charts.who.report.open'

    start = StateView(
        'gnuhealth.pediatrics.growth.charts.who.report.open.start',
        'health_pediatrics_growth_charts_who.growth_charts_who_open_start_view_form',
        [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Open', 'choose', 'tryton-ok', default=True),
        ])
    choose = StateTransition()
    print_wfa = StateAction(
        'health_pediatrics_growth_charts_who.report_pediatrics_growth_charts_who_wfa'
    )
    print_lhfa = StateAction(
        'health_pediatrics_growth_charts_who.report_pediatrics_growth_charts_who_lhfa'
    )
    print_bmifa = StateAction(
        'health_pediatrics_growth_charts_who.report_pediatrics_growth_charts_who_bmifa'
    )

    def transition_choose(self):
        if self.start.indicator == 'w-f-a':
            return 'print_wfa'
        elif self.start.indicator == 'l/h-f-a':
            return 'print_lhfa'
        else:
            return 'print_bmifa'

    def fill_data(self):
        return {
            'patient': Transaction().context.get('active_id'),
            'indicator': self.start.indicator,
            'measure': self.start.measure,
        }

    def do_print_wfa(self, action):
        return action, self.fill_data()

    def do_print_lhfa(self, action):
        return action, self.fill_data()

    def do_print_bmifa(self, action):
        return action, self.fill_data()
Ejemplo n.º 12
0
class BuyPostageWizard(Wizard):
    """Buy Postage Wizard
    """
    __name__ = 'buy.postage.wizard'

    start = StateView('buy.postage.wizard.view',
                      'shipping_endicia.endicia_buy_postage_wizard_view_form',
                      [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Buy Postage', 'buy_postage', 'tryton-ok'),
                      ])
    buy_postage = StateView(
        'buy.postage.wizard.view',
        'shipping_endicia.endicia_buy_postage_wizard_view_form', [
            Button('OK', 'end', 'tryton-ok'),
        ])

    def default_buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        EndiciaConfiguration = Pool().get('endicia.configuration')

        default = {}
        endicia_credentials = EndiciaConfiguration(1).get_endicia_credentials()

        buy_postage_api = BuyingPostageAPI(
            request_id=Transaction().user,
            recredit_amount=self.start.amount,
            requesterid=endicia_credentials.requester_id,
            accountid=endicia_credentials.account_id,
            passphrase=endicia_credentials.passphrase,
            test=endicia_credentials.is_test,
        )
        try:
            response = buy_postage_api.send_request()
        except RequestError, error:
            self.raise_user_error('error_label', error_args=(error, ))

        result = objectify_response(response)
        default['company'] = self.start.company
        default['amount'] = self.start.amount
        default['response'] = str(result.ErrorMessage) \
            if hasattr(result, 'ErrorMessage') else 'Success'
        return default
Ejemplo n.º 13
0
class SplitShipment(Wizard):
    "Split Shipment"
    __name__ = 'stock.shipment.split'
    start = StateView('stock.shipment.split.start',
                      'stock_split.shipment_split_start_view_form', [
                          Button("Cancel", 'end', 'tryton-cancel'),
                          Button("Split", 'split', 'tryton-ok', default=True),
                      ])
    split = StateTransition()

    def get_moves(self, shipment):
        if shipment.__name__ == 'stock.shipment.out':
            return shipment.outgoing_moves
        elif shipment.__name__ in {
                'stock.shipment.in.return',
                'stock.shipment.internal',
        }:
            return shipment.moves

    def default_start(self, fields):
        moves = self.get_moves(self.record)
        move_ids = [m.id for m in moves if m.state == 'draft']
        return {
            'domain_moves': move_ids,
        }

    def transition_split(self):
        pool = Pool()
        Move = pool.get('stock.move')
        shipment = self.record
        Shipment = self.model
        if shipment.state != 'draft':
            raise ValueError("Wrong shipment state")
        if not set(self.start.moves).issubset(self.start.domain_moves):
            raise ValueError("Invalid moves, %s != %s" %
                             (self.start.moves, self.start.domain_moves))

        if Shipment.__name__ == 'stock.shipment.out':
            Move.draft(shipment.inventory_moves)
            Move.delete(
                [m for m in shipment.inventory_moves if m.state == 'draft'])

        shipment, = Shipment.copy([shipment], default={'moves': None})
        Move.write(list(self.start.moves), {'shipment': str(shipment)})
        return 'end'
Ejemplo n.º 14
0
class CheckServiceStatus(Wizard):
    """
    Check Service Status Wizard

    Check service status for the current MWS account
    """
    __name__ = 'amazon.mws.check_service_status'

    start = StateView('amazon.mws.check_service_status.view',
                      'amazon_mws.check_service_status_view_form', [
                          Button('OK', 'end', 'tryton-ok'),
                      ])

    def default_start(self, data):
        """
        Check the service status of the MWS account

        :param data: Wizard data
        """
        MWSAccount = Pool().get('amazon.mws.account')

        account = MWSAccount(Transaction().context.get('active_id'))

        res = {}
        api = account.get_mws_api()
        response = api.get_service_status().parsed

        status = response['Status']['value']

        if status == 'GREEN':
            status_message = 'The service is operating normally. '

        elif status == 'GREEN_I':
            status_message = 'The service is operating normally. '

        elif status == 'YELLOW':
            status_message = 'The service is experiencing higher than ' + \
                'normal error rates or is operating with degraded performance. '
        else:
            status_message = 'The service is unavailable or experiencing ' + \
                'extremely high error rates. '

        res['status'] = status
        if not response.get('Messages'):
            res['message'] = status_message
            return res

        if isinstance(response['Messages']['Message'], dict):
            messages = [response['Messages']['Message']]
        else:
            messages = response['Messages']['Message']

        for message in messages:
            status_message = status_message + message['Text']['value'] + ' '
            res['message'] = status_message

        return res
class ValidatedInvoice(Wizard):
    'Validate Invoice'
    __name__ = 'account.invoice.validate_invoice'

    start = StateView('account.withholding',
        'nodux_account_withholding_ec.withholding_view_form', [
            Button('Cerrar', 'end', 'tryton-ok', default=True),
            ])

    def default_start(self, fields):

        Invoice = Pool().get('account.invoice')
        Journal = Pool().get('account.journal')

        default = {}
        journals = Journal.search([('type', '=', 'expense')])
        for j in journals:
            journal = j

        invoice = Invoice(Transaction().context.get('active_id'))

        invoice.set_number()
        #invoice.create_move()

        pool = Pool()
        Date = pool.get('ir.date')
        fecha_actual = Date.today()
        Taxes = pool.get('account.tax')
        taxes_1 = Taxes.search([('type', '=', 'percentage')])
        Configuration = pool.get('account.configuration')

        if Configuration(1).default_account_withholding:
            w = Configuration(1).default_account_withholding
        else:
            self.raise_user_error('No ha configurado la cuenta por defecto para la retencion. \nDirijase a Financiero-Configuracion-Configuracion Contable')

        if invoice.type == 'out':
            default['type'] = 'out_withholding'

        if invoice.description:
            default['number_w'] = invoice.description

        default['account'] = j.id
        default['withholding_address'] = invoice.invoice_address.id
        default['description'] = invoice.description
        default['reference'] = invoice.number
        default['comment']=invoice.comment
        default['company']=invoice.company.id
        default['party']=invoice.party.id
        default['currency']=invoice.currency.id
        default['journal']= journal.id
        default['taxes']=[]
        default['base_imponible'] = invoice.taxes[0].base
        default['iva']= invoice.taxes[0].amount
        default['withholding_date']= fecha_actual
        print "Default ** ", default
        return default
Ejemplo n.º 16
0
class GenerateFacturae(Wizard):
    'Generate Factura-e file'
    __name__ = 'account.invoice.generate_facturae'
    start = StateView(
        'account.invoice.generate_facturae.start',
        'account_invoice_facturae.generate_facturae_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Generate', 'generate', 'tryton-launch', default=True),
        ])
    generate = StateTransition()

    def transition_generate(self):
        Invoice = Pool().get('account.invoice')

        invoices = Invoice.browse(Transaction().context['active_ids'])
        service = 'generate_facturae_%s' % self.start.service
        getattr(Invoice, service)(invoices, self.start.certificate_password)
        return 'end'
Ejemplo n.º 17
0
class CreateShipmentInternal(Wizard):
    'Create Shipment Internal'
    __name__ = 'stock.shipment.internal.create'
    start = StateView(
        'stock.shipment.internal.create.start',
        'stock_supply.shipment_internal_create_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Create', 'create_', 'tryton-ok', default=True),
        ])
    create_ = StateAction('stock.act_shipment_internal_form')

    def do_create_(self, action):
        ShipmentInternal = Pool().get('stock.shipment.internal')
        ShipmentInternal.generate_internal_shipment()
        return action, {}

    def transition_create_(self):
        return 'end'
Ejemplo n.º 18
0
class GenerateShippingLabel(Wizard):
    'Generate Labels'
    __name__ = 'shipping.label'

    ups_config = StateView(
        'shipping.label.ups',
        'shipping_ups.shipping_ups_configuration_view_form', [
            Button('Back', 'start', 'tryton-go-previous'),
            Button('Continue', 'generate', 'tryton-go-next'),
        ])

    def default_ups_config(self, data):
        Config = Pool().get('sale.configuration')
        config = Config(1)
        shipment = self.start.shipment

        return {
            'ups_service_type':
            (shipment.ups_service_type and shipment.ups_service_type.id)
            or (config.ups_service_type and config.ups_service_type.id)
            or None,
            'ups_package_type': (shipment.ups_package_type
                                 or config.ups_package_type),
            'ups_saturday_delivery':
            shipment.ups_saturday_delivery
        }

    def transition_next(self):
        state = super(GenerateShippingLabel, self).transition_next()

        if self.start.carrier.carrier_cost_method == 'ups':
            return 'ups_config'
        return state

    def update_shipment(self):
        shipment = super(GenerateShippingLabel, self).update_shipment()

        if self.start.carrier.carrier_cost_method == 'ups':
            shipment.ups_service_type = self.ups_config.ups_service_type
            shipment.ups_package_type = self.ups_config.ups_package_type
            shipment.ups_saturday_delivery = \
                self.ups_config.ups_saturday_delivery

        return shipment
Ejemplo n.º 19
0
class ExportDataWizard:
    "Wizard to export data to external channel"
    __name__ = 'sale.channel.export_data'

    configure = StateView(
        'sale.channel.export_data.configure',
        'magento.export_data_configure_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Continue', 'next', 'tryton-go-next', default=True),
        ])

    def default_configure(self, data):
        Channel = Pool().get('sale.channel')

        channel = Channel(Transaction().context.get('active_id'))
        return {'channel_source': channel.source}

    def transition_next(self):
        Channel = Pool().get('sale.channel')

        channel = Channel(Transaction().context.get('active_id'))

        if channel.source == 'magento':
            return 'configure'

        return super(ExportDataWizard, self).transition_next()

    def transition_export_(self):
        """
        Export the products for the selected category on this channel
        """
        Channel = Pool().get('sale.channel')

        channel = Channel(Transaction().context['active_id'])

        if channel.source != 'magento':
            return super(ExportDataWizard, self).transition_export_()

        with Transaction().set_context({
                'current_channel': channel.id,
                'magento_attribute_set': self.start.attribute_set,
                'category': self.start.category,
        }):
            return super(ExportDataWizard, self).transition_export_()
class RecomputePrice(Wizard):
    'Recompute Product List Price'
    __name__ = 'contract.recompute_price'

    start = StateView(
        'contract.recompute_price.start',
        'contract_recompute_price.recompute_price_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Recompute', 'compute', 'tryton-ok', default=True),
        ])
    compute = StateTransition()

    def get_additional_args(self):
        method_name = 'get_additional_args_%s' % self.start.method
        if not hasattr(self, method_name):
            return {}
        return getattr(self, method_name)()

    def get_additional_args_fixed_amount(self):
        return {
            'unit_price': self.start.unit_price,
        }

    def get_additional_args_percentage(self):
        return {
            'percentage': self.start.percentage,
        }

    def transition_compute(self):
        pool = Pool()
        ContractLine = pool.get('contract.line')

        method_name = 'recompute_price_by_%s' % self.start.method
        method = getattr(ContractLine, method_name)
        if method:
            domain = [('contract_state', '=', 'confirmed')]
            if self.start.method == 'percentage' and self.start.categories:
                categories = [cat.id for cat in list(self.start.categories)]
                domain.append(('service.product.categories', 'in', categories))
            if self.start.method == 'fixed_amount' and self.start.services:
                services = [s.id for s in list(self.start.services)]
                domain.append(('service', 'in', services))
            method(ContractLine.search(domain), **self.get_additional_args())
        return 'end'
Ejemplo n.º 21
0
class Succeed(Wizard):
    "Succeed Payment"
    __name__ = 'account.payment.succeed'
    start = StateView(
        'account.payment.succeed.start',
        'account_payment_clearing.succeed_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Succeed', 'succeed', 'tryton-ok', default=True),
        ])
    succeed = StateTransition()

    def transition_succeed(self):
        pool = Pool()
        Payment = pool.get('account.payment')
        payments = Payment.browse(Transaction().context['active_ids'])

        with Transaction().set_context(clearing_date=self.start.date):
            Payment.succeed(payments)
        return 'end'
Ejemplo n.º 22
0
class TestConnection(Wizard):
    """
    Test Connection Wizard
    """
    __name__ = 'shipping_dhl_de.wizard_test_connection'

    start = StateView('shipping_dhl_de.wizard_test_connection.start',
                      'shipping_dhl_de.wizard_test_connection_view_form', [
                          Button('Ok', 'end', 'tryton-ok'),
                      ])
Ejemplo n.º 23
0
class OpenSaleOpportunityEmployee(Wizard):
    'Open Sale Opportunity per Employee'
    __name__ = 'sale.opportunity_employee.open'
    start = StateView(
        'sale.opportunity_employee.open.start',
        'sale_opportunity.opportunity_employee_open_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Open', 'open_', 'tryton-ok', default=True),
        ])
    open_ = StateAction('sale_opportunity.act_opportunity_employee_form')

    def do_open_(self, action):
        action['pyson_context'] = PYSONEncoder().encode({
            'start_date':
            self.start.start_date,
            'end_date':
            self.start.end_date,
        })
        return action, {}
Ejemplo n.º 24
0
class PrintGradeOverdueReport(Wizard):
    'Grade Overdue Report'
    __name__ = 'grade.overdue.report.print'

    start = StateView(
        'grade.overdue.report.print.start',
        'training.print_grade_overdue_report_start_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Print', 'print_', 'tryton-print', default=True),
        ])
    print_ = StateReport('grade.overdue.report')

    def do_print_(self, action):
        data = {
            'date': self.start.date,
            'user': self.start.user.name,
            'grade': self.start.grade.id,
        }
        return action, data
Ejemplo n.º 25
0
class PayLine(Wizard):
    'Pay Line'
    __name__ = 'account.move.line.pay'
    start = StateView('account.move.line.pay.start',
                      'account_payment.move_line_pay_start_view_form', [
                          Button('Cancel', 'end', 'tryton-cancel'),
                          Button('Pay', 'pay', 'tryton-ok', default=True),
                      ])
    pay = StateAction('account_payment.act_payment_form')

    def get_payment(self, line):
        pool = Pool()
        Payment = pool.get('account.payment')

        if (line.debit > 0) or (line.credit < 0):
            kind = 'receivable'
        else:
            kind = 'payable'

        return Payment(
            company=line.move.company,
            journal=self.start.journal,
            party=line.party,
            kind=kind,
            date=self.start.date,
            amount=line.payment_amount,
            line=line,
        )

    def do_pay(self, action):
        pool = Pool()
        Line = pool.get('account.move.line')
        Payment = pool.get('account.payment')

        lines = Line.browse(Transaction().context['active_ids'])

        payments = []
        for line in lines:
            payments.append(self.get_payment(line))
        Payment.save(payments)
        return action, {
            'res_id': [p.id for p in payments],
        }
Ejemplo n.º 26
0
class Debug(Wizard):
    'Debug'

    __name__ = 'debug'

    start_state = 'run'
    run = StateTransition()
    display = StateView('debug.visualize', 'debug.visualize_view_form', [
        Button('Quit', 'end', 'tryton-cancel'),
        Button('Re-Run', 'run', 'tryton-go-next')
    ])

    def run_code(self):
        # Run your code. return value will be wrote down in the display window
        if self.display.synch_model_data:
            return self.synch_model_data()
        elif self.display.pyson:
            return self.transform_pyson()

    def transform_pyson(self):
        from trytond.pyson import Eval, Bool, Or, PYSONEncoder, And, Not  # NOQA
        encoded = PYSONEncoder().encode(eval(self.display.pyson))
        return ''.join([x if x != '"' else '&quot;' for x in encoded])

    def synch_model_data(self):
        ModelData = Pool().get('ir.model.data')
        to_sync = ModelData.search([('out_of_sync', '=', True)])
        nb_to_sync = len(to_sync)
        if to_sync:
            ModelData.sync(to_sync)
        to_sync = ModelData.search([('out_of_sync', '=', True)])
        return 'Synchronised %s/%s model data' % (nb_to_sync - len(to_sync),
                                                  nb_to_sync)

    def transition_run(self):
        return 'display'

    def default_display(self, name):
        res = self.display._default_values
        if not res:
            return res
        res.update({'result': self.run_code()})
        return res
Ejemplo n.º 27
0
class PrintChartAccount(Wizard):
    'Print Chart Account'
    __name__ = 'account.print_chart_account'
    start = StateView(
        'account.print_chart_account.start',
        'account_ar.print_chart_account_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Print', 'print_', 'tryton-print', default=True),
        ])
    print_ = StateAction('account_ar.report_chart_account')

    def do_print_(self, action):
        data = {
            'company': self.start.company.id,
        }
        return action, data

    def transition_print_(self):
        return 'end'
Ejemplo n.º 28
0
class OpenHoursEmployee(Wizard):
    'Open Hours per Employee'
    __name__ = 'timesheet.hours_employee.open'
    start = StateView('timesheet.hours_employee.open.start',
        'timesheet.hours_employee_open_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Open', 'open_', 'tryton-ok', default=True),
            ])
    open_ = StateAction('timesheet.act_hours_employee_form')

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

    def transition_open_(self):
        return 'end'
Ejemplo n.º 29
0
class OpenChartAccount(Wizard):
    'Open Chart of Accounts'
    __name__ = 'analytic_account.open_chart'
    start = StateView('analytic_account.open_chart.start',
        'analytic_account.open_chart_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Open', 'open_', 'tryton-ok', default=True),
            ])
    open_ = StateAction('analytic_account.act_account_tree2')

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

    def transition_open_(self):
        return 'end'
Ejemplo n.º 30
0
class PrintResGroup(Wizard):
    'Print Groups'
    __name__ = 'nuntiare.print_res_group'

    start = StateView(
        'nuntiare.print.parameter', 'nuntiare.print_parameter_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Print', 'print_', 'tryton-print', default=True),
        ])
    print_ = StateAction('nuntiare.report_res_group')

    def do_print_(self, action):
        data = {
            'output_type': self.start.output_type,
        }
        return action, data

    def transition_print_(self):
        return 'end'