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


Python Pool.write方法代码示例

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


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

示例1: edit_task

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def edit_task(self):
        """
        Edit the task
        """
        Activity = Pool().get('nereid.activity')
        Work = Pool().get('timesheet.work')

        task = self.get_task(self.id)

        Work.write([task.work], {
            'name': request.form.get('name'),
        })
        self.write([task], {
            'comment': request.form.get('comment')
        })
        Activity.create([{
            'actor': request.nereid_user.id,
            'object_': 'project.work, %d' % task.id,
            'verb': 'edited_task',
            'target': 'project.work, %d' % task.parent.id,
            'project': task.parent.id,
        }])
        if request.is_xhr:
            return jsonify({
                'success': True,
                'name': self.rec_name,
                'comment': self.comment,
            })
        return redirect(request.referrer)
开发者ID:openlabs,项目名称:nereid-project,代码行数:31,代码来源:task.py

示例2: element

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
def element(model, record_id):
    """
    GET: Retrieve a representation of the member
    PUT: Write to the record
    DELETE: Delete the record

    :param model: name of the model
    :param record_id: ID of the record
    """
    model = Pool().get(model, type='model')
    record = model(record_id)

    if request.method == 'GET':
        # Return a dictionary of the read record
        fields_names = request.args.getlist('fields_names')
        return jsonify(
            model.read([record.id], fields_names)[0]
        )

    elif request.method == 'PUT':
        # Write to the record and return the updated record
        model.write([record], request.json)
        fields_names = request.args.getlist('fields_names')
        return jsonify(
            model.read([record.id], fields_names)[0]
        )

    elif request.method == 'DELETE':
        model.delete([record])
        return jsonify({}), 205
开发者ID:GauravButola,项目名称:tryton-restful,代码行数:32,代码来源:application.py

示例3: create

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def create(cls, vlist):
        Attendee = Pool().get('calendar.event.attendee')
        events = super(Event, cls).create(vlist)

        if Transaction().user == 0:
            # user is 0 means create is triggered by another one
            return events

        for event in events:
            to_notify, owner = event.attendees_to_notify()
            if not to_notify:
                continue

            with Transaction().set_context(skip_schedule_agent=True):
                ical = event.event2ical()
            ical.add('method')
            ical.method.value = 'REQUEST'

            attendee_emails = [a.email for a in to_notify]

            subject, body = event.subject_body('new', owner)
            msg = cls.create_msg(owner.email, attendee_emails, subject, body,
                ical)
            sent = event.send_msg(owner.email, attendee_emails, msg, 'new')

            vals = {'status': 'needs-action'}
            if sent:
                vals['schedule_status'] = '1.1'  # successfully sent
            else:
                vals['schedule_status'] = '5.1'  # could not complete delivery
            Attendee.write(to_notify, vals)

        return events
开发者ID:silpol,项目名称:tryton-bef,代码行数:35,代码来源:calendar_.py

示例4: do_return_

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def do_return_(self, action):
        Sale = Pool().get('sale.sale')
        action, data = super(ReturnSale, self).do_return_(action)

        Sale.write(Sale.browse(data['res_id']), {'carrier': None})

        return action, data
开发者ID:bhavana94,项目名称:trytond-shipping,代码行数:9,代码来源:sale.py

示例5: _submit_registered

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def _submit_registered(self):
        """Submission when registered user"""
        cart_obj = Pool().get("nereid.cart")
        sale_obj = Pool().get("sale.sale")
        from trytond.modules.nereid_checkout.forms import OneStepCheckoutRegd

        form = OneStepCheckoutRegd(request.form)
        addresses = cart_obj._get_addresses()
        form.billing_address.choices.extend(addresses)
        form.shipping_address.choices.extend(addresses)
        form.payment_method.choices = [(m.id, m.name) for m in request.nereid_website.allowed_gateways]
        form.shipment_method.validators = []

        cart = cart_obj.open_cart()
        if form.validate():
            # Get billing address
            if form.billing_address.data == 0:
                # New address
                billing_address = self._create_address(form.new_billing_address.data)
            else:
                billing_address = form.billing_address.data

            # Get shipping address
            shipping_address = billing_address
            if not form.shipping_same_as_billing:
                if form.shipping_address.data == 0:
                    shipping_address = self._create_address(form.new_shipping_address.data)
                else:
                    shipping_address = form.shipping_address.data

            # Write the information to the order
            sale_obj.write(cart.sale.id, {"invoice_address": billing_address, "shipment_address": shipping_address})

        return form, form.validate()
开发者ID:openlabs,项目名称:nereid-demo-store,代码行数:36,代码来源:checkout.py

示例6: save

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
 def save(self):
     "Save the session in database"
     session_obj = Pool().get('ir.session.wizard')
     if self.dirty:
         session_obj.write(self._session.id, {
                 'data': json.dumps(self.data, cls=JSONEncoder),
                 })
开发者ID:mediafactory,项目名称:tryton_core_daemon,代码行数:9,代码来源:wizard.py

示例7: write

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def write(cls, lines, vals):
        Purchase = Pool().get('purchase.purchase')

        if 'invoice' in vals:
            with Transaction().set_user(0, set_context=True):
                purchases = Purchase.search([
                        ('invoice_lines', 'in', [l.id for l in lines]),
                        ])
                if vals['invoice']:
                    Purchase.write(purchases, {
                        'invoices': [('add', [vals['invoice']])],
                        })
                else:
                    for purchase in purchases:
                        invoice_ids = list(set([x.invoice.id for x
                                    in purchase.invoice_lines
                                    if x.invoice and x.id in lines])
                            - set([x.invoice.id for x
                                    in purchase.invoice_lines
                                    if x.invoice and x.id not in lines]))
                        Purchase.write([purchase], {
                            'invoices': [('unlink', invoice_ids)],
                            })

        return super(InvoiceLine, cls).write(lines, vals)
开发者ID:silpol,项目名称:tryton-bef,代码行数:27,代码来源:invoice.py

示例8: set_shares

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [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

示例9: write

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
 def write(cls, lines, vals):
     Selection = Pool().get("analytic_account.account.selection")
     vals = vals.copy()
     selection_vals = {}
     for field in vals.keys():
         if field.startswith("analytic_account_"):
             root_id = int(field[len("analytic_account_") :])
             selection_vals[root_id] = vals[field]
             del vals[field]
     if selection_vals:
         for line in lines:
             if line.type != "line":
                 continue
             accounts = []
             if not line.analytic_accounts:
                 # Create missing selection
                 with Transaction().set_user(0):
                     selection, = Selection.create([{}])
                 cls.write([line], {"analytic_accounts": selection.id})
             for account in line.analytic_accounts.accounts:
                 if account.root.id in selection_vals:
                     value = selection_vals[account.root.id]
                     if value:
                         accounts.append(value)
                 else:
                     accounts.append(account.id)
             for account_id in selection_vals.values():
                 if account_id and account_id not in accounts:
                     accounts.append(account_id)
             Selection.write([line.analytic_accounts], {"accounts": [("set", accounts)]})
     return super(PurchaseLine, cls).write(lines, vals)
开发者ID:silpol,项目名称:tryton-bef,代码行数:33,代码来源:purchase.py

示例10: create_invoice

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def create_invoice(self):
        '''
        Create a invoice for the travaux and return the invoice
        '''
        Line = Pool().get('invoice.travaux.line')
        Invoice = Pool().get('account.invoice')

        if self.invoice:
            return

        invoice = self._get_invoice_travaux()
        invoice_lines = self._get_invoice_line_travaux_line(invoice)
        invoice.save()

        for line_id, invoice_line in invoice_lines.iteritems():
            invoice_line.invoice = invoice
            invoice_line.save()
            Line.write([Line(line_id)], {
                    'invoice_line': invoice_line.id,
                    })

        with Transaction().set_user(0, set_context=True):
            Invoice.update_taxes([invoice])

        self.write([self], {
                'invoice': invoice.id,
                })
        return invoice
开发者ID:silpol,项目名称:tryton-bef,代码行数:30,代码来源:forest_work.py

示例11: edit_task

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def edit_task(self):
        """
        Edit the task
        """
        Activity = Pool().get("nereid.activity")
        Work = Pool().get("timesheet.work")

        task = self.get_task(self.id)

        Work.write([task.work], {"name": request.form.get("name")})
        self.write([task], {"comment": request.form.get("comment")})
        Activity.create(
            [
                {
                    "actor": request.nereid_user.id,
                    "object_": "project.work, %d" % task.id,
                    "verb": "edited_task",
                    "target": "project.work, %d" % task.parent.id,
                    "project": task.parent.id,
                }
            ]
        )
        if request.is_xhr:
            return jsonify({"success": True, "name": self.rec_name, "comment": self.comment})
        return redirect(request.referrer)
开发者ID:GauravButola,项目名称:nereid-project,代码行数:27,代码来源:task.py

示例12: _submit_guest

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def _submit_guest(cls):
        '''Submission when guest user'''
        Cart = Pool().get('nereid.cart')
        Sale = Pool().get('sale.sale')

        form = OneStepCheckout(request.form)
        cart = Cart.open_cart()
        if form.validate():
            # Get billing address
            billing_address = cls._create_address(
                form.new_billing_address.data
            )

            # Get shipping address
            shipping_address = billing_address
            if not form.shipping_same_as_billing:
                shipping_address = cls._create_address(
                    form.new_shipping_address.data
                )

            # Write the information to the order
            Sale.write(
                [cart.sale], {
                    'invoice_address': billing_address,
                    'shipment_address': shipping_address,
                }
            )
        return form, form.validate()
开发者ID:pokoli,项目名称:nereid-checkout,代码行数:30,代码来源:checkout.py

示例13: update_pricelist_shipment_cost

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def update_pricelist_shipment_cost(self):
        "Add a shipping line to sale for pricelist costmethod"
        Sale = Pool().get('sale.sale')
        Currency = Pool().get('currency.currency')

        if not self.carrier or self.carrier.carrier_cost_method != 'pricelist':
            return

        with Transaction().set_context(self._get_carrier_context()):
            shipment_cost = self.carrier.get_sale_price()
        if not shipment_cost[0]:
            return

        shipment_cost = Currency.compute(
            Currency(shipment_cost[1]), shipment_cost[0], self.currency
        )
        Sale.write([self], {
            'lines': [
                ('create', [{
                    'type': 'line',
                    'product': self.carrier.carrier_product.id,
                    'description': self.carrier.carrier_product.name,
                    'quantity': 1,  # XXX
                    'unit': self.carrier.carrier_product.sale_uom.id,
                    'unit_price': Decimal(shipment_cost),
                    'shipment_cost': Decimal(shipment_cost),
                    'amount': Decimal(shipment_cost),
                    'taxes': [],
                    'sequence': 9999,  # XXX
                }]),
                ('delete', [
                    line for line in self.lines if line.shipment_cost
                ]),
            ]
        })
开发者ID:fulfilio,项目名称:trytond-carrier-pricelist,代码行数:37,代码来源:sale.py

示例14: update_from_magento_using_data

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def update_from_magento_using_data(self, product_data):
        """
        Update product using magento data

        :param product_data: Product Data from magento
        :returns: Active record of product updated
        """
        Template = Pool().get("product.template")

        product_template_values = self.extract_product_values_from_data(product_data)
        product_template_values.update(
            {
                "products": [
                    (
                        "write",
                        [self],
                        {
                            "description": product_data.get("description"),
                            "code": product_data["sku"],
                            "list_price": Decimal(
                                product_data.get("special_price") or product_data.get("price") or 0.00
                            ),
                            "cost_price": Decimal(product_data.get("cost") or 0.00),
                        },
                    )
                ]
            }
        )
        Template.write([self.template], product_template_values)

        return self
开发者ID:usudaysingh,项目名称:trytond-magento,代码行数:33,代码来源:product.py

示例15: apply_ups_shipping

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import write [as 别名]
    def apply_ups_shipping(self):
        "Add a shipping line to sale for ups"
        Sale = Pool().get('sale.sale')
        Currency = Pool().get('currency.currency')

        if self.is_ups_shipping:
            with Transaction().set_context(self._get_carrier_context()):
                shipment_cost, currency_id = self.carrier.get_sale_price()
                if not shipment_cost:
                    return
            # Convert the shipping cost to sale currency from USD
            shipment_cost = Currency.compute(
                Currency(currency_id), shipment_cost, self.currency
            )
            Sale.write([self], {
                'lines': [
                    ('create', [{
                        'type': 'line',
                        'product': self.carrier.carrier_product.id,
                        'description': self.ups_service_type.name,
                        'quantity': 1,  # XXX
                        'unit': self.carrier.carrier_product.sale_uom.id,
                        'unit_price': shipment_cost,
                        'shipment_cost': shipment_cost,
                        'amount': shipment_cost,
                        'taxes': [],
                        'sequence': 9999,  # XXX
                    }]),
                    ('delete', [
                        line for line in self.lines if line.shipment_cost
                    ]),
                ]
            })
开发者ID:mbehrle,项目名称:trytond-shipping-ups,代码行数:35,代码来源:sale.py


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