Example #1
0
class AddProductListing(Wizard):
    "Add product Channel Listing Wizard"
    __name__ = 'product.listing.add'

    start = StateView(
        'product.listing.add.start', 'sale_channel.listing_add_start_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Next', 'next', 'tryton-go-next', default=True),
        ])
    next = StateTransition()

    def default_start(self, fields):
        return {'product': Transaction().context['active_id']}

    def transition_next(self):
        return 'start_%s' % self.start.channel.source
class CreateSubscriptionInvoice(Wizard):
    "Create Subscription Invoice"
    __name__ = 'sale.subscription.create_invoice'
    start = StateView(
        'sale.subscription.create_invoice.start',
        'sale_subscription.create_invoice_start_view_form', [
            Button("Cancel", 'end', 'tryton-cancel'),
            Button("Create", 'create_', 'tryton-ok', default=True),
        ])
    create_ = StateTransition()

    def transition_create_(self):
        pool = Pool()
        Subscription = pool.get('sale.subscription')
        Subscription.generate_invoice(date=self.start.date)
        return 'end'
Example #3
0
class CreateDunning(Wizard):
    'Create Account Dunning'
    __name__ = 'account.dunning.create'
    start = StateView(
        'account.dunning.create.start',
        'account_dunning.dunning_create_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Create', 'create_', 'tryton-ok', default=True),
        ])
    create_ = StateAction('account_dunning.act_dunning_form')

    def do_create_(self, action):
        pool = Pool()
        Dunning = pool.get('account.dunning')
        Dunning.generate_dunnings(date=self.start.date)
        return action, {}
class SystemLogicsModulaImportEXPOrdiniFileProcess(Wizard):
    'SystemLogics Modula Import EXP Ordini File'
    __name__ = "systemlogics.modula.import.exp.ordini.file.process"
    start = StateView(
        'systemlogics.modula.import.exp.ordini.file.process.start',
        'systemlogics_modula.systemlogics_modula_import_exp_ordini_file_process_start',
        [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Process', 'process', 'tryton-ok', default=True),
        ])
    process = StateTransition()

    def transition_process(self):
        SystemLogicsModula = Pool().get('systemlogics.modula')
        SystemLogicsModula.export_ordini_file_process()
        return 'end'
Example #5
0
class APARGenerateRepRaiseWiz(Wizard):
    'APAR Representation Wizard'
    __name__ = 'apar.representation.raise'

    start_state = 'raises'
    raises = StateView('apar.representation.raise.show',
                       'apar.form_apar_representationshow_view', [
                           Button('Cancel', 'end', 'tryton-cancel'),
                           Button(
                               'Generate Representation',
                               'create_repr',
                               'tryton-go-next',
                               default=True,
                           )
                       ])
    create_repr = StateTransition()
    open_ = StateAction('apar.act_apar_representation')

    def create_representation(self):
        pool = Pool()
        context = Transaction().context
        repr_ = pool.get('apar.representation').create([{
            'raised_by':
            pool.get('res.user')(Transaction().user).employee,
            'subject':
            self.raises.subject,
            'text':
            self.raises.details,
            'raised_on':
            pool.get('ir.date').today()
        }])[0]
        self.raises.representation = repr_
        EmployeeForm = pool.get('apar.employee.form')
        active_rec = EmployeeForm(context.get('active_id'))
        pool.get('apar.employee.form').set_representation([active_rec])
        active_rec.representation = repr_
        active_rec.save()

    def transition_create_repr(self):
        self.create_representation()
        return 'open_'

    def do_open_(self, action):
        action['pyson_domain'] = PYSONEncoder().encode([
            ('id', '=', self.raises.representation.id)
        ])
        return action, {}
Example #6
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
Example #7
0
class UpdateMagentoCatalog(Wizard):
    '''
    Update Catalog

    This is a wizard to update already imported products
    '''
    __name__ = 'magento.update_catalog'

    start = StateView(
        'magento.update_catalog.start',
        'magento.magento_update_catalog_start_view_form', [
            Button('Cancel', 'end', 'tryton-cancel'),
            Button('Continue', 'update_', 'tryton-ok', default=True),
        ])
    update_ = StateAction('product.act_template_form')

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

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

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

        product_template_ids = self.update_products(channel)

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

    def transition_import_(self):
        return 'end'

    def update_products(self, channel):
        """
        Updates products for current magento_channel

        :param channel: Browse record of channel
        :return: List of product IDs
        """
        products = []
        with Transaction().set_context({'current_channel': channel.id}):
            for listing in channel.product_listings:
                products.append(listing.product.update_from_magento())

        return map(int, products)
Example #8
0
class CheckVIES(Wizard):
    'Check VIES'
    __name__ = 'party.check_vies'
    start_state = 'check'

    check = StateTransition()
    result = StateView('party.check_vies.result',
        'party.check_vies_result', [
            Button('OK', 'end', 'tryton-ok', True),
            ])

    def transition_check(self):
        parties_succeed = []
        parties_failed = []
        for party in self.records:
            for identifier in party.identifiers:
                if identifier.type != 'eu_vat':
                    continue
                eu_vat = get_cc_module('eu', 'vat')
                try:
                    if not eu_vat.check_vies(identifier.code)['valid']:
                        parties_failed.append(party.id)
                    else:
                        parties_succeed.append(party.id)
                except Exception as e:
                    if hasattr(e, 'faultstring') \
                            and hasattr(e.faultstring, 'find'):
                        if e.faultstring.find('INVALID_INPUT'):
                            parties_failed.append(party.id)
                            continue
                        if e.faultstring.find('SERVICE_UNAVAILABLE') \
                                or e.faultstring.find('MS_UNAVAILABLE') \
                                or e.faultstring.find('TIMEOUT') \
                                or e.faultstring.find('SERVER_BUSY'):
                            raise VIESUnavailable(
                                gettext('party.msg_vies_unavailable')) from e
                    raise
        self.result.parties_succeed = parties_succeed
        self.result.parties_failed = parties_failed
        return 'result'

    def default_result(self, fields):
        return {
            'parties_succeed': [p.id for p in self.result.parties_succeed],
            'parties_failed': [p.id for p in self.result.parties_failed],
            }
Example #9
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'
Example #10
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 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'
Example #12
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'
Example #13
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'
Example #14
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
Example #15
0
class DebugModel(Wizard):
    'Debug Model'

    __name__ = 'ir.model.debug'

    start_state = 'model_info'
    model_info = StateView('ir.model.debug.model_info',
                           'debug.model_info_view_form',
                           [Button('Quit', 'end', 'tryton-cancel')])

    def default_model_info(self, name):
        return {
            'model_name': Transaction().context.get('active_model', None),
            'id_to_calculate': Transaction().context.get('active_id', None),
            'hide_functions': False,
            'filter_value': 'name',
        }
Example #16
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'
Example #17
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,{}
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'
Example #19
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()
Example #20
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'
Example #21
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'
Example #22
0
class PrestashopConnectionWizard(Wizard):
    'Prestashop Connection Wizard'
    __name__ = 'prestashop.connection.wizard'

    start = StateView(
        'prestashop.connection.wizard.view',
        'prestashop.prestashop_connection_wizard_view_form',
        [
            Button('Ok', 'end', 'tryton-ok'),
        ]
    )

    def default_start(self, data):
        """Test the connection and show the user appropriate message

        :param data: Wizard data
        """
        return {}
Example #23
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'
Example #24
0
class ImportCarriers(Wizard):
    """
    Wizard to import carriers / shipping methods for instance
    """
    __name__ = 'magento.wizard_import_carriers'

    start = StateView('magento.wizard_import_carriers.start',
                      'magento.wizard_import_carriers_start_view_form', [
                          Button('Ok', 'end', 'tryton-ok'),
                      ])

    def default_start(self, data):
        """
        Import carriers and show the user appropriate message

        :param data: Wizard data
        """
        return {}
Example #25
0
class ImportOrderStates(Wizard):
    """
    Wizard to import order states for instance
    """
    __name__ = 'magento.wizard_import_order_states'

    start = StateView('magento.wizard_import_order_states.start',
                      'magento.wizard_import_order_states_start_view_form', [
                          Button('Ok', 'end', 'tryton-ok'),
                      ])

    def default_start(self, data):
        """
        Import order states and show the user appropriate message

        :param data: Wizard data
        """
        return {}
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'
Example #27
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_()
Example #28
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'
Example #29
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, {}
Example #30
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],
        }
Example #31
0
 def __init__(self, model_name, buttons):
     StateView.__init__(self, model_name, None, buttons)