trytond-stock_valued_discount /

#This file is part of Tryton.  The COPYRIGHT file at the top level
#of this repository contains the full copyright notices and license terms.

from trytond.model import ModelView, ModelSQL, fields
from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.pool import Pool
from decimal import Decimal

class ShipmentOut(ModelSQL, ModelView):
    _name = 'stock.shipment.out'

    def get_tax_amount(self, ids, name):
        Compute tax amount for each ShipmentOut
        pool = Pool()
        currency_obj = pool.get('currency.currency')
        tax_obj = pool.get('')
        invoice_obj = pool.get('account.invoice')

        amounts = {}
        for shipment in self.browse(ids):
            if (shipment.state in self._states_cached
                    and shipment.tax_amount_cache is not None):
                amounts[] = shipment.tax_amount_cache
            context = self.get_tax_context(shipment)
            taxes = {}
            for move in shipment.outgoing_moves:
                unit_price = move.unit_price
                    unit_price = (move.unit_price - move.unit_price * * Decimal('0.01'))
                with Transaction().set_context(context):
                    tax_list = tax_obj.compute(
                            [ for t in move.product.customer_taxes], 
                            unit_price, move.quantity)
                # Don't round on each line to handle rounding error
                for tax in tax_list:
                    key, val = invoice_obj._compute_tax(tax, 'out_invoice')
                    if not key in taxes:
                        taxes[key] = val['amount']
                        taxes[key] += val['amount']
            amount = sum((currency_obj.round(, taxes[key])
                    for key in taxes), Decimal(0))
            amounts[] = currency_obj.round(, amount)
        return amounts

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.