Se corrieron las pruebas de estilo y de tryton
This commit is contained in:
parent
80c13f3c98
commit
b6250456f5
83
invoice.py
83
invoice.py
@ -1,29 +1,40 @@
|
||||
# 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 Pool, PoolMeta
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.model import fields
|
||||
from trytond.modules.currency.fields import Monetary
|
||||
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
from decimal import Decimal
|
||||
from trytond.model.exceptions import ValidationError
|
||||
|
||||
|
||||
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'),
|
||||
'get_unit_taxes')
|
||||
total_with_taxes = fields.Function(Monetary("Total With Taxes", 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'),
|
||||
'get_total_with_taxes')
|
||||
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')
|
||||
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')
|
||||
|
||||
total_tax_extra = fields.Function(Monetary("Total Tax Extra", currency='currency', digits='currency'),
|
||||
'get_total_tax_extra')
|
||||
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',
|
||||
'_parent_invoice.currency', 'taxes', 'amount')
|
||||
@ -39,7 +50,6 @@ 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):
|
||||
@ -58,42 +68,47 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
'_parent_invoice.currency', 'taxes', 'amount')
|
||||
def on_change_with_total_with_taxes(self):
|
||||
try:
|
||||
total_with_taxes = self.amount + self.tax_amount
|
||||
total_with_taxes = self.amount + self.tax_amount
|
||||
return total_with_taxes
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
raise ValidationError(f"Se produjo un error {e}.")
|
||||
|
||||
|
||||
@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
|
||||
unit_with_tax = self.unit_price + self.tax_unit
|
||||
return unit_with_tax
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
raise ValidationError(f"Se produjo un error {e}.")
|
||||
|
||||
@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
|
||||
total_tax_extra = Decimal(str(self.quantity or '0.0')) * \
|
||||
(self.tax_extra_unit or Decimal('0.0'))
|
||||
(self.tax_extra_unit or Decimal('0.0'))
|
||||
if currency:
|
||||
return currency.round(total_tax_extra)
|
||||
return total_tax_extra
|
||||
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',
|
||||
'company', methods=['_get_tax_rule_pattern'])
|
||||
@fields.depends('product', 'unit', '_parent_invoice.type',
|
||||
'_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(Line, self).on_change_product()
|
||||
|
||||
super(InvoiceLine, self).on_change_product()
|
||||
|
||||
def get_amount_taxes(self, name):
|
||||
if self.type == 'line':
|
||||
return self.on_change_with_tax_amount()
|
||||
@ -105,7 +120,7 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
def get_total_with_taxes(self, name):
|
||||
if self.type == 'line':
|
||||
return self.on_change_with_total_with_taxes()
|
||||
|
||||
|
||||
def get_unit_with_tax(self, name):
|
||||
if self.type == 'line':
|
||||
return self.on_change_with_unit_with_tax()
|
||||
|
3
setup.py
3
setup.py
@ -85,7 +85,8 @@ 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',
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user