当前位置: 首页>>代码示例>>Python>>正文


Python Pool.create方法代码示例

本文整理汇总了Python中trytond.pool.Pool.create方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.create方法的具体用法?Python Pool.create怎么用?Python Pool.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trytond.pool.Pool的用法示例。


在下文中一共展示了Pool.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cache_prestashop_id

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def cache_prestashop_id(cls, prestashop_id):
        """Cache the value of subdivision corresponding to the prestashop_id
        by creating a record in the cache model

        :param prestashop_id: Prestashop ID
        :returns: Active record of the subdivision cached
        """
        SubdivisionPrestashop = Pool().get("country.subdivision.prestashop")
        Country = Pool().get("country.country")
        SaleChannel = Pool().get("sale.channel")

        channel = SaleChannel(Transaction().context["current_channel"])
        channel.validate_prestashop_channel()

        client = channel.get_prestashop_client()

        state_data = client.states.get(prestashop_id)
        # The country should have been cached till now for sure
        country = Country.get_using_ps_id(state_data.id_country.pyval)
        subdivision = cls.search([("code", "=", country.code + "-" + state_data.iso_code.pyval)])

        if not subdivision:
            cls.raise_user_error("subdivision_not_found", (country.code + "-" + state_data.iso_code.pyval,))

        SubdivisionPrestashop.create(
            [{"subdivision": subdivision[0].id, "channel": channel.id, "prestashop_id": prestashop_id}]
        )

        return subdivision and subdivision[0] or None
开发者ID:priyankarani,项目名称:trytond-prestashop,代码行数:31,代码来源:country.py

示例2: createinvoice

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
 def createinvoice(cls, projects):
     invoice = Pool().get('account.invoice')
     products = Pool().get('product.product')
     #print products.search_rec_name(name='Openlabs').name
     for project in projects:
         details = {
             'payment_term': project.party.customer_payment_term.id,
             'party': project.party.id,
             'account': project.company.account_receivable.id,
             'invoice_address': cls._get_invoice_address(project.party),
         }
         details['description'] = project.name
         lines = [
                     ('create', {
                             'line': 'line',
                             'quantity': 3,
                             'unit': 30,
                             'divisor': 4,
                             'percentage': 25,
                             'days': 30,
                             })
                 ]
         details['lines'] = lines
         invoice.create(details)
     return True
开发者ID:simmianand,项目名称:project_billing,代码行数:27,代码来源:billing.py

示例3: change_constraint_dates

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def change_constraint_dates(cls, task_id):
        """
        Change the constraint dates
        """
        Activity = Pool().get("nereid.activity")

        task = cls.get_task(task_id)

        data = {"constraint_start_time": False, "constraint_finish_time": False}

        constraint_start = request.form.get("constraint_start_time", None)
        constraint_finish = request.form.get("constraint_finish_time", None)

        if constraint_start:
            data["constraint_start_time"] = datetime.strptime(constraint_start, "%m/%d/%Y")
        if constraint_finish:
            data["constraint_finish_time"] = datetime.strptime(constraint_finish, "%m/%d/%Y")

        cls.write([task], data)
        Activity.create(
            [
                {
                    "actor": request.nereid_user.id,
                    "object_": "project.work, %d" % task.id,
                    "verb": "changed_date",
                    "project": task.parent.id,
                }
            ]
        )

        if request.is_xhr:
            return jsonify({"success": True})

        flash("The constraint dates have been changed for this task.")
        return redirect(request.referrer)
开发者ID:GauravButola,项目名称:nereid-project,代码行数:37,代码来源:task.py

示例4: create_period

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
 def create_period(cls, fiscalyears, interval=1):
     '''
     Create periods for the fiscal years with month interval
     '''
     Period = Pool().get('account.period')
     to_create = []
     for fiscalyear in fiscalyears:
         period_start_date = fiscalyear.start_date
         while period_start_date < fiscalyear.end_date:
             period_end_date = period_start_date + \
                 relativedelta(months=interval - 1) + \
                 relativedelta(day=31)
             if period_end_date > fiscalyear.end_date:
                 period_end_date = fiscalyear.end_date
             name = datetime_strftime(period_start_date, '%Y-%m')
             if name != datetime_strftime(period_end_date, '%Y-%m'):
                 name += ' - ' + datetime_strftime(period_end_date, '%Y-%m')
             to_create.append({
                 'name': name,
                 'start_date': period_start_date,
                 'end_date': period_end_date,
                 'fiscalyear': fiscalyear.id,
                 'type': 'standard',
                 })
             period_start_date = period_end_date + relativedelta(days=1)
     if to_create:
         Period.create(to_create)
开发者ID:Sisouvan,项目名称:ogh,代码行数:29,代码来源:fiscalyear.py

示例5: remove_tag

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def remove_tag(cls, task_id, tag_id):
        """
        Assigns the provided to this task

        :param task_id: ID of task
        :param tag_id: ID of tag
        """
        Activity = Pool().get('nereid.activity')
        task = cls.get_task(task_id)

        cls.write(
            [task], {'tags': [('remove', [tag_id])]}
        )
        Activity.create([{
            'actor': request.nereid_user.id,
            'object_': 'project.work, %d' % task.id,
            'verb': 'removed_tag_from_task',
            'target': 'project.work, %d' % task.parent.id,
            'project': task.parent.id,
        }])

        if request.method == 'POST':
            flash('Tag removed from task %s' % task.rec_name)
            return redirect(request.referrer)

        flash("Tag cannot be removed")
        return redirect(request.referrer)
开发者ID:openlabs,项目名称:nereid-project,代码行数:29,代码来源:task.py

示例6: transition_create_

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def transition_create_(self):
        Appointment = Pool().get("gnuhealth.appointment")

        appointments = []
        # Iterate over days
        day_count = (self.start.date_end - self.start.date_start).days + 1
        for single_date in (self.start.date_start + timedelta(n) for n in range(day_count)):
            if (
                (single_date.weekday() == 0 and self.start.monday)
                or (single_date.weekday() == 1 and self.start.tuesday)
                or (single_date.weekday() == 2 and self.start.wednesday)
                or (single_date.weekday() == 3 and self.start.thursday)
                or (single_date.weekday() == 4 and self.start.friday)
                or (single_date.weekday() == 5 and self.start.saturday)
                or (single_date.weekday() == 6 and self.start.sunday)
            ):
                # Iterate over time
                dt = datetime.combine(single_date, self.start.time_start)
                dt_end = datetime.combine(single_date, self.start.time_end)
                while dt < dt_end:
                    appointment = {
                        "healthprof": self.start.healthprof.id,
                        "speciality": self.start.specialty.id,
                        "institution": self.start.institution.id,
                        "appointment_date": dt,
                        "appointment_date_end": dt + timedelta(minutes=self.start.appointment_minutes),
                        "state": "free",
                    }
                    appointments.append(appointment)
                    dt += timedelta(minutes=self.start.appointment_minutes)
        if appointments:
            Appointment.create(appointments)
        return "open_"
开发者ID:GabrielReusRodriguez,项目名称:gnuhealth,代码行数:35,代码来源:wizard_health_calendar.py

示例7: make_scanform

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def make_scanform(self):
        """
        Generate the SCAN Form for bag
        """
        Attachment = Pool().get('ir.attachment')

        if not self.shipments:
            self.raise_user_error('bag_empty')

        pic_numbers = [shipment.tracking_number for shipment in self.shipments]
        test = self.carrier.endicia_is_test and 'Y' or 'N'
        scan_request = SCANFormAPI(
            pic_numbers=pic_numbers,
            accountid=self.carrier.endicia_account_id,
            requesterid=self.carrier.endicia_requester_id,
            passphrase=self.carrier.endicia_passphrase,
            test=test,
        )
        response = scan_request.send_request()
        result = objectify_response(response)
        if not hasattr(result, 'SCANForm'):
            self.raise_user_error(
                'error_scanform', error_args=(result.ErrorMsg,)
            )
        else:
            self.submission_id = str(result.SubmissionID)
            self.save()
            Attachment.create([{
                'name': 'SCAN%s.png' % str(result.SubmissionID),
                'data': buffer(base64.decodestring(result.SCANForm.pyval)),
                'resource': '%s,%s' % (self.__name__, self.id)
            }])
开发者ID:bhavana94,项目名称:trytond-shipping-endicia,代码行数:34,代码来源:shipment_bag.py

示例8: _make_gls_label

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def _make_gls_label(self):
        """
        This method gets the prepared Shipment object and calls the GLS API
        for label generation.
        """
        Attachment = Pool().get('ir.attachment')

        for index, package in enumerate(self.packages, start=1):
            shipment = package._get_shipment_object()
            shipment.parcel = index
            label = shipment.create_label()
            response = Response.parse(label)

            # Get tracking number
            tracking_number = response.values.get('T8913')
            assert tracking_number

            package.tracking_number = tracking_number
            package.save()

            # Create attachment
            Attachment.create([{
                'name': "%s_%s_%s.zpl" % (
                    tracking_number, self.gls_parcel_number, package.code),
                'data': response.values.get('zpl_content'),
                'resource': '%s,%s' % (self.__name__, self.id),
            }])

        return tracking_number
开发者ID:kstenger,项目名称:trytond-shipping-gls,代码行数:31,代码来源:shipment.py

示例9: _create_address

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def _create_address(cls, data):
        "Create a new party.address"
        Address = Pool().get('party.address')
        NereidUser = Pool().get('nereid.user')
        ContactMechanism = Pool().get('party.contact_mechanism')

        email = data.pop('email')
        phone = data.pop('phone')

        if request.is_guest_user:
            existing = NereidUser.search([
                ('email', '=', email),
                ('company', '=', request.nereid_website.company.id),
            ])
            if existing:
                cls._handle_guest_checkout_with_regd_email(email)

        data['country'] = data.pop('country')
        data['subdivision'] = data.pop('subdivision')
        data['party'] = request.nereid_user.party.id
        ContactMechanism.create({
            'type': 'email',
            'party': request.nereid_user.party.id,
            'email': email,
        })
        ContactMechanism.create({
            'type': 'phone',
            'party': request.nereid_user.party.id,
            'value': phone,
        })
        address = Address.create(data)
        Address.write([address], {'email': email, 'phone': phone})

        return address
开发者ID:pokoli,项目名称:nereid-checkout,代码行数:36,代码来源:checkout.py

示例10: set_shares

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def set_shares(self, ids, name, value):
        share_obj = Pool().get('webdav.share')

        if not value:
            return

        attachments = self.browse(ids)
        for action in value:
            if action[0] == 'create':
                for attachment in attachments:
                    action[1]['path'] = attachment.path
                    share_obj.create(action[1])
            elif action[0] == 'write':
                share_obj.write(action[1], action[2])
            elif action[0] == 'delete':
                share_obj.delete(action[1])
            elif action[0] == 'delete_all':
                paths = [a.path for a in attachments]
                share_ids = share_obj.search([
                        ('path', 'in', paths),
                        ])
                share_obj.delete(share_ids)
            elif action[0] == 'unlink':
                pass
            elif action[0] == 'add':
                pass
            elif action[0] == 'unlink_all':
                pass
            elif action[0] == 'set':
                pass
            else:
                raise Exception('Bad arguments')
开发者ID:mediafactory,项目名称:tryton_core_daemon,代码行数:34,代码来源:webdav.py

示例11: transition_do_create

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def transition_do_create(self):
        """Create the entry for the newly created item sheet"""
        values = {}
        for key in self.start._fields.keys():
            if isinstance(self.start._fields[key], fields.Function):
                continue
            if key in ['trunks', 'total_volume_uom', 'mean_volume_uom', 'main_variety']:
                continue

            values[key] = getattr(self.start, key)

        MarkingSheet = Pool().get('marking_sheet.marking_sheet')
        active_id = Transaction().context['active_id']
        marking_sheet = MarkingSheet(active_id)

        # Set trunks
        trunks = [trunk.id for trunk in marking_sheet.trunks]
        values['trunks'] = [('add', trunks)]

        # Find the main variety (the top-level variety that has a higher
        # weight)
        volumes = {}
        for trunk in marking_sheet.trunks:
            variety = trunk.variety
            while not variety.parent is None:
                variety = variety.parent
            volumes[variety] = volumes.get(variety, 0) + trunk.total_cubing
        values['main_variety'] = max(volumes.iteritems(), key=operator.itemgetter(1))[0].id

        ItemsSheet = Pool().get('items_sheet.items_sheet')
        ItemsSheet.create([values])
        return 'end'
开发者ID:silpol,项目名称:tryton-bef,代码行数:34,代码来源:marking_to_items.py

示例12: create_using_amazon_data

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def create_using_amazon_data(cls, order_data, line_data):
        """
        Create a sale using amazon data

        :param order_data: Order data from amazon
        :return: Active record of record created
        """
        Party = Pool().get('party.party')
        Address = Pool().get('party.address')
        SaleChannel = Pool().get('sale.channel')
        ChannelException = Pool().get('channel.exception')

        amazon_channel = SaleChannel(
            Transaction().context['current_channel']
        )
        assert amazon_channel.source == 'amazon_mws'

        party_values = {
            'name': order_data['BuyerName']['value'],
            'email': order_data['BuyerEmail']['value'],
        }
        party = Party.find_or_create_using_amazon_data(party_values)
        if 'Phone' in order_data['ShippingAddress']:
            party.add_phone_using_amazon_data(
                order_data['ShippingAddress']['Phone']['value']
            )
        party_invoice_address = party_shipping_address = \
            Address.find_or_create_for_party_using_amazon_data(
                party, order_data['ShippingAddress']
            )

        sale = cls.get_sale_using_amazon_data(order_data, line_data)

        sale.party = party.id
        sale.invoice_address = party_invoice_address.id
        sale.shipment_address = party_shipping_address.id
        sale.channel = amazon_channel.id
        sale.save()

        # TODO: Handle Discounts
        # TODO: Handle Taxes

        if sale.total_amount != Decimal(
            order_data['OrderTotal']['Amount']['value']
        ):
            ChannelException.create([{
                'origin': '%s,%s' % (sale.__name__, sale.id),
                'log': 'Order total does not match.',
                'channel': sale.channel.id,
            }])

            return sale

        # We import only completed orders, so we can confirm them all
        cls.quote([sale])
        cls.confirm([sale])

        # TODO: Process the order for invoice as the payment info is received

        return sale
开发者ID:sharoonthomas,项目名称:trytond-amazon-mws,代码行数:62,代码来源:sale.py

示例13: round_down_total

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def round_down_total(cls, records):
        '''
        Round down total order price and add remaining amount as new sale line
        '''
        SaleLine = Pool().get('sale.line')

        sale_lines = []
        for record in records:
            # Check if there's already a roundoff line, remove and create new
            # if there is.
            round_off_line = SaleLine.search([
                ('sale', '=', record.id),
                ('is_round_off', '=', True),
            ])
            if round_off_line:
                SaleLine.delete(round_off_line)

            floored_total = floor(record.total_amount)
            amount_diff = record.total_amount - Decimal(floored_total)
            sale_lines.append({
                'sale': record,
                'is_round_off': True,
                'type': 'line',
                'quantity': -1,
                'unit_price': amount_diff,
                'description': 'Round Off'
            })

        SaleLine.create(
            [line for line in sale_lines if line['unit_price']]
        )
开发者ID:rajatguptarg,项目名称:trytond-pos,代码行数:33,代码来源:sale.py

示例14: cache_prestashop_id

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
    def cache_prestashop_id(cls, prestashop_id):
        """Cache the value of country corresponding to the prestashop_id
        by creating a record in the cache model

        :param prestashop_id: Prestashop ID
        :returns: Active record of the country cached
        """
        CountryPrestashop = Pool().get('country.country.prestashop')
        SaleChannel = Pool().get('sale.channel')

        channel = SaleChannel(Transaction().context['current_channel'])
        channel.validate_prestashop_channel()

        client = channel.get_prestashop_client()

        country_data = client.countries.get(prestashop_id)
        country = cls.search([('code', '=', country_data.iso_code.pyval)])

        if not country:
            cls.raise_user_error(
                'country_not_found', (country_data.iso_code.pyval,)
            )
        CountryPrestashop.create([{
            'country': country[0].id,
            'channel': channel.id,
            'prestashop_id': prestashop_id,
        }])

        return country and country[0] or None
开发者ID:riteshshrv,项目名称:trytond-prestashop,代码行数:31,代码来源:country.py

示例15: reservador

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import create [as 别名]
	def reservador(self,ids,name,value):
		obj_consulta = Pool().get('cefiro.consulta')

		for reser in self.browse(ids):
			for i in range(len(reser.dtini)):
				obj_consulta.create({'horaini':reser.dtini[i],'horaFin':reser.dtfin[i],'consultorio':reser.consultorio,'psicologos':[]})
		return res
开发者ID:guzmanico23,项目名称:cefiro,代码行数:9,代码来源:reserva.py


注:本文中的trytond.pool.Pool.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。