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


Python Pool.get_sale_price方法代码示例

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


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

示例1: get_pricelist_shipping_cost

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_sale_price [as 别名]
    def get_pricelist_shipping_cost(self):
        """
        Return pricelist shipping cost
        """
        Product = Pool().get('product.product')
        Carrier = Pool().get('carrier')
        Company = Pool().get('company.company')

        carrier, = Carrier.search([('carrier_cost_method', '=', 'pricelist')])

        total = Decimal('0')

        company = Transaction().context.get('company')
        if not company:
            raise UserError("Company not in context.")

        default_currency = Company(company).currency

        with Transaction().set_context(
                customer=self.customer.id,
                price_list=carrier.price_list.id,
                currency=default_currency.id):
            for move in self.outgoing_moves:
                total += \
                    Product.get_sale_price([move.product])[move.product.id] * \
                    Decimal(move.quantity)

        return total, default_currency.id
开发者ID:openlabs,项目名称:trytond-carrier-pricelist,代码行数:30,代码来源:shipment.py

示例2: on_change_session

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_sale_price [as 别名]
    def on_change_session(self):
        Product = Pool().get('product.product')
        res = {}
        if self.session:
            res = {'uom': self.session.offer.name.default_uom.id}
            with Transaction().set_context(self._get_context_subscription_price(self.subscription)):
                for session_product in self.session.offer.name.products: 
                    product = session_product

                res['unit_price'] = Product.get_sale_price([product],
                        self.quantity or 0)[product.id]
                if res['unit_price']:
                    res['unit_price'] = res['unit_price'].quantize(
                        Decimal(1) / 10 ** self.__class__.unit_price.digits[1])
            self.unit_price = res['unit_price']
            res['number_calls'] = self.session.offer.number_calls
            if self.quantity and self.unit_price:
                total = self.quantity * self.unit_price
                res['total_amount'] = total
        return res
开发者ID:iehoshia,项目名称:trytond-training_subscription,代码行数:22,代码来源:training.py

示例3: get_pricelist_shipping_cost

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_sale_price [as 别名]
    def get_pricelist_shipping_cost(self):
        """
        Return pricelist shipping cost
        """
        Product = Pool().get('product.product')
        Carrier = Pool().get('carrier')
        Company = Pool().get('company.company')

        carrier, = Carrier.search([('carrier_cost_method', '=', 'pricelist')])

        total = Decimal('0')

        company = Transaction().context.get('company')
        if not company:
            raise UserError("Company not in context.")

        default_currency = Company(company).currency

        try:
            context = {
                'customer': self.party.id,
                'price_list': carrier.price_list.id,
                'currency': self.currency.id,
            }
        except:
            if Transaction().context.get('ignore_carrier_computation'):
                # If carrier computation is ignored just return the
                # default values
                return Decimal('0'), default_currency.id

        with Transaction().set_context(**context):
            for line in self.lines:
                if not line.product:
                    continue
                total += \
                    Product.get_sale_price([line.product])[line.product.id] * \
                    Decimal(line.quantity)

        return total, self.currency.id
开发者ID:fulfilio,项目名称:trytond-carrier-pricelist,代码行数:41,代码来源:sale.py


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