Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					33bfb6ce1c | 
							
								
								
									
										63
									
								
								invoice.py
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								invoice.py
									
									
									
									
									
								
							@@ -1,39 +1,28 @@
 | 
			
		||||
# 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.pool import PoolMeta
 | 
			
		||||
from trytond.model import fields
 | 
			
		||||
from trytond.pool import Pool, PoolMeta
 | 
			
		||||
from trytond.model import ModelView, ModelSQL, fields
 | 
			
		||||
from trytond.modules.currency.fields import Monetary
 | 
			
		||||
from decimal import Decimal
 | 
			
		||||
from trytond.model.exceptions import ValidationError
 | 
			
		||||
 | 
			
		||||
from trytond.exceptions import UserError
 | 
			
		||||
 | 
			
		||||
from decimal import Decimal
 | 
			
		||||
 | 
			
		||||
class InvoiceLine(metaclass=PoolMeta):
 | 
			
		||||
    'Invoice Line Extras'
 | 
			
		||||
    __name__ = 'account.invoice.line'
 | 
			
		||||
 | 
			
		||||
    tax_amount = fields.Function(Monetary("Tax",
 | 
			
		||||
                                          currency='currency',
 | 
			
		||||
                                          digits='currency'),
 | 
			
		||||
    tax_amount = fields.Function(Monetary("Tax", currency='currency', digits='currency'),
 | 
			
		||||
                                 'get_amount_taxes')
 | 
			
		||||
    tax_unit = fields.Function(Monetary("Unit Tax",
 | 
			
		||||
                                        currency='currency',
 | 
			
		||||
                                        digits='currency'),
 | 
			
		||||
    tax_unit = fields.Function(Monetary("Unit Tax", currency='currency', digits='currency'),
 | 
			
		||||
                                 'get_unit_taxes')
 | 
			
		||||
    total_with_taxes = fields.Function(Monetary("Total With Taxes",
 | 
			
		||||
                                                currency='currency',
 | 
			
		||||
                                                digits='currency'),
 | 
			
		||||
    total_with_taxes = fields.Function(Monetary("Total With Taxes", currency='currency', digits='currency'),
 | 
			
		||||
                                       'get_total_with_taxes')
 | 
			
		||||
    unit_with_tax = fields.Function(Monetary("Unit With Tax",
 | 
			
		||||
                                             currency='currency',
 | 
			
		||||
                                             digits='currency'),
 | 
			
		||||
    unit_with_tax = fields.Function(Monetary("Unit With Tax", currency='currency', digits='currency'),
 | 
			
		||||
                                       'get_unit_with_tax')
 | 
			
		||||
    tax_extra_unit = Monetary(
 | 
			
		||||
        "Tax Extra Unit", currency='currency', digits='currency')
 | 
			
		||||
    tax_extra_unit = Monetary("Tax Extra Unit", currency='currency', digits='currency')
 | 
			
		||||
 | 
			
		||||
    total_tax_extra = fields.Function(Monetary(
 | 
			
		||||
        "Total Tax Extra",
 | 
			
		||||
        currency='currency',
 | 
			
		||||
        digits='currency'),
 | 
			
		||||
    total_tax_extra = fields.Function(Monetary("Total Tax Extra", currency='currency', digits='currency'),
 | 
			
		||||
                                         'get_total_tax_extra')
 | 
			
		||||
 | 
			
		||||
    @fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
 | 
			
		||||
@@ -50,6 +39,7 @@ class InvoiceLine(metaclass=PoolMeta):
 | 
			
		||||
            return tax_amount
 | 
			
		||||
        return Decimal('0.0')
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    @fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
 | 
			
		||||
                    '_parent_invoice.currency', 'taxes', 'amount')
 | 
			
		||||
    def on_change_with_tax_unit(self):
 | 
			
		||||
@@ -70,24 +60,21 @@ class InvoiceLine(metaclass=PoolMeta):
 | 
			
		||||
        try:
 | 
			
		||||
            total_with_taxes = self.amount + self.tax_amount    
 | 
			
		||||
            return total_with_taxes
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            raise ValidationError(f"Se produjo un error {e}.")
 | 
			
		||||
        except:
 | 
			
		||||
            pass
 | 
			
		||||
 | 
			
		||||
    @fields.depends('type', 'quantity',
 | 
			
		||||
                    'unit_price', 'unit',
 | 
			
		||||
                    'invoice', '_parent_invoice.currency',
 | 
			
		||||
                    'taxes', 'amount')
 | 
			
		||||
 | 
			
		||||
    @fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
 | 
			
		||||
                    '_parent_invoice.currency', 'taxes', 'amount')
 | 
			
		||||
    def on_change_with_unit_with_tax(self):
 | 
			
		||||
        try:
 | 
			
		||||
            unit_with_tax = self.unit_price + self.tax_unit    
 | 
			
		||||
            return unit_with_tax
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            raise ValidationError(f"Se produjo un error {e}.")
 | 
			
		||||
        except:
 | 
			
		||||
            pass
 | 
			
		||||
 | 
			
		||||
    @fields.depends('type', 'quantity', 'tax_extra_unit',
 | 
			
		||||
                    'unit_price', 'unit', 'invoice',
 | 
			
		||||
                    '_parent_invoice.currency',
 | 
			
		||||
                    'taxes', 'amount')
 | 
			
		||||
    @fields.depends('type', 'quantity', 'tax_extra_unit', 'unit_price', 'unit', 'invoice',
 | 
			
		||||
                    '_parent_invoice.currency', 'taxes', 'amount')
 | 
			
		||||
    def on_change_with_total_tax_extra(self):
 | 
			
		||||
        if self.type == 'line':
 | 
			
		||||
            currency = self.invoice.currency if self.invoice else None
 | 
			
		||||
@@ -99,15 +86,13 @@ class InvoiceLine(metaclass=PoolMeta):
 | 
			
		||||
        return Decimal('0.0')
 | 
			
		||||
 | 
			
		||||
    @fields.depends('product', 'unit', '_parent_invoice.type',   
 | 
			
		||||
                    '_parent_invoice.party',
 | 
			
		||||
                    'party', 'invoice', 'invoice_type',
 | 
			
		||||
                    '_parent_invoice.invoice_date',
 | 
			
		||||
                    '_parent_invoice.accounting_date',
 | 
			
		||||
        '_parent_invoice.party', 'party', 'invoice', 'invoice_type',
 | 
			
		||||
        '_parent_invoice.invoice_date', '_parent_invoice.accounting_date',
 | 
			
		||||
        'company', methods=['_get_tax_rule_pattern'])
 | 
			
		||||
    def on_change_product(self):
 | 
			
		||||
        self.tax_amount = self.on_change_with_tax_amount()
 | 
			
		||||
        self.total_with_taxes = self.on_change_with_total_with_taxes()
 | 
			
		||||
        super(InvoiceLine, self).on_change_product()
 | 
			
		||||
        super(Line, self).on_change_product()
 | 
			
		||||
        
 | 
			
		||||
    def get_amount_taxes(self, name):
 | 
			
		||||
        if self.type == 'line':
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								setup.py
									
									
									
									
									
								
							@@ -85,8 +85,7 @@ setup(name=name,
 | 
			
		||||
    download_url=download_url,
 | 
			
		||||
    project_urls={
 | 
			
		||||
        "Bug Tracker": 'https://bugs.tryton.org/',
 | 
			
		||||
        "Documentation":
 | 
			
		||||
            'https://docs.tryton.org/projects/modules-purchase-line-extras',
 | 
			
		||||
        "Documentation": 'https://docs.tryton.org/projects/modules-purchase-line-extras',
 | 
			
		||||
        "Forum": 'https://www.tryton.org/forum',
 | 
			
		||||
        "Source Code": 'https://hg.tryton.org/modules/purchase_line_extras',
 | 
			
		||||
        },
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,7 @@
 | 
			
		||||
[tryton]
 | 
			
		||||
version=6.8.0
 | 
			
		||||
version=7.0.0
 | 
			
		||||
depends:
 | 
			
		||||
	ir
 | 
			
		||||
	account_invoice
 | 
			
		||||
xml:
 | 
			
		||||
    invoice.xml
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user