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 file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import PoolMeta
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import fields
|
||||||
from trytond.modules.currency.fields import Monetary
|
from trytond.modules.currency.fields import Monetary
|
||||||
|
|
||||||
from trytond.exceptions import UserError
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from trytond.model.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class InvoiceLine(metaclass=PoolMeta):
|
class InvoiceLine(metaclass=PoolMeta):
|
||||||
'Invoice Line Extras'
|
'Invoice Line Extras'
|
||||||
__name__ = 'account.invoice.line'
|
__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')
|
'get_amount_taxes')
|
||||||
tax_unit = fields.Function(Monetary("Unit Tax", currency='currency', digits='currency'),
|
tax_unit = fields.Function(Monetary("Unit Tax",
|
||||||
'get_unit_taxes')
|
currency='currency',
|
||||||
total_with_taxes = fields.Function(Monetary("Total With Taxes", currency='currency', digits='currency'),
|
digits='currency'),
|
||||||
|
'get_unit_taxes')
|
||||||
|
total_with_taxes = fields.Function(Monetary("Total With Taxes",
|
||||||
|
currency='currency',
|
||||||
|
digits='currency'),
|
||||||
'get_total_with_taxes')
|
'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",
|
||||||
'get_unit_with_tax')
|
currency='currency',
|
||||||
tax_extra_unit = Monetary("Tax Extra Unit", currency='currency', digits='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'),
|
total_tax_extra = fields.Function(Monetary(
|
||||||
'get_total_tax_extra')
|
"Total Tax Extra",
|
||||||
|
currency='currency',
|
||||||
|
digits='currency'),
|
||||||
|
'get_total_tax_extra')
|
||||||
|
|
||||||
@fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
|
@fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
|
||||||
'_parent_invoice.currency', 'taxes', 'amount')
|
'_parent_invoice.currency', 'taxes', 'amount')
|
||||||
@ -39,7 +50,6 @@ class InvoiceLine(metaclass=PoolMeta):
|
|||||||
return tax_amount
|
return tax_amount
|
||||||
return Decimal('0.0')
|
return Decimal('0.0')
|
||||||
|
|
||||||
|
|
||||||
@fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
|
@fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
|
||||||
'_parent_invoice.currency', 'taxes', 'amount')
|
'_parent_invoice.currency', 'taxes', 'amount')
|
||||||
def on_change_with_tax_unit(self):
|
def on_change_with_tax_unit(self):
|
||||||
@ -58,42 +68,47 @@ class InvoiceLine(metaclass=PoolMeta):
|
|||||||
'_parent_invoice.currency', 'taxes', 'amount')
|
'_parent_invoice.currency', 'taxes', 'amount')
|
||||||
def on_change_with_total_with_taxes(self):
|
def on_change_with_total_with_taxes(self):
|
||||||
try:
|
try:
|
||||||
total_with_taxes = self.amount + self.tax_amount
|
total_with_taxes = self.amount + self.tax_amount
|
||||||
return total_with_taxes
|
return total_with_taxes
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
raise ValidationError(f"Se produjo un error {e}.")
|
||||||
|
|
||||||
|
@fields.depends('type', 'quantity',
|
||||||
@fields.depends('type', 'quantity', 'unit_price', 'unit', 'invoice',
|
'unit_price', 'unit',
|
||||||
'_parent_invoice.currency', 'taxes', 'amount')
|
'invoice', '_parent_invoice.currency',
|
||||||
|
'taxes', 'amount')
|
||||||
def on_change_with_unit_with_tax(self):
|
def on_change_with_unit_with_tax(self):
|
||||||
try:
|
try:
|
||||||
unit_with_tax = self.unit_price + self.tax_unit
|
unit_with_tax = self.unit_price + self.tax_unit
|
||||||
return unit_with_tax
|
return unit_with_tax
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
raise ValidationError(f"Se produjo un error {e}.")
|
||||||
|
|
||||||
@fields.depends('type', 'quantity', 'tax_extra_unit', 'unit_price', 'unit', 'invoice',
|
@fields.depends('type', 'quantity', 'tax_extra_unit',
|
||||||
'_parent_invoice.currency', 'taxes', 'amount')
|
'unit_price', 'unit', 'invoice',
|
||||||
|
'_parent_invoice.currency',
|
||||||
|
'taxes', 'amount')
|
||||||
def on_change_with_total_tax_extra(self):
|
def on_change_with_total_tax_extra(self):
|
||||||
if self.type == 'line':
|
if self.type == 'line':
|
||||||
currency = self.invoice.currency if self.invoice else None
|
currency = self.invoice.currency if self.invoice else None
|
||||||
total_tax_extra = Decimal(str(self.quantity or '0.0')) * \
|
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:
|
if currency:
|
||||||
return currency.round(total_tax_extra)
|
return currency.round(total_tax_extra)
|
||||||
return total_tax_extra
|
return total_tax_extra
|
||||||
return Decimal('0.0')
|
return Decimal('0.0')
|
||||||
|
|
||||||
@fields.depends('product', 'unit', '_parent_invoice.type',
|
@fields.depends('product', 'unit', '_parent_invoice.type',
|
||||||
'_parent_invoice.party', 'party', 'invoice', 'invoice_type',
|
'_parent_invoice.party',
|
||||||
'_parent_invoice.invoice_date', '_parent_invoice.accounting_date',
|
'party', 'invoice', 'invoice_type',
|
||||||
'company', methods=['_get_tax_rule_pattern'])
|
'_parent_invoice.invoice_date',
|
||||||
|
'_parent_invoice.accounting_date',
|
||||||
|
'company', methods=['_get_tax_rule_pattern'])
|
||||||
def on_change_product(self):
|
def on_change_product(self):
|
||||||
self.tax_amount = self.on_change_with_tax_amount()
|
self.tax_amount = self.on_change_with_tax_amount()
|
||||||
self.total_with_taxes = self.on_change_with_total_with_taxes()
|
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):
|
def get_amount_taxes(self, name):
|
||||||
if self.type == 'line':
|
if self.type == 'line':
|
||||||
return self.on_change_with_tax_amount()
|
return self.on_change_with_tax_amount()
|
||||||
@ -105,7 +120,7 @@ class InvoiceLine(metaclass=PoolMeta):
|
|||||||
def get_total_with_taxes(self, name):
|
def get_total_with_taxes(self, name):
|
||||||
if self.type == 'line':
|
if self.type == 'line':
|
||||||
return self.on_change_with_total_with_taxes()
|
return self.on_change_with_total_with_taxes()
|
||||||
|
|
||||||
def get_unit_with_tax(self, name):
|
def get_unit_with_tax(self, name):
|
||||||
if self.type == 'line':
|
if self.type == 'line':
|
||||||
return self.on_change_with_unit_with_tax()
|
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,
|
download_url=download_url,
|
||||||
project_urls={
|
project_urls={
|
||||||
"Bug Tracker": 'https://bugs.tryton.org/',
|
"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',
|
"Forum": 'https://www.tryton.org/forum',
|
||||||
"Source Code": 'https://hg.tryton.org/modules/purchase_line_extras',
|
"Source Code": 'https://hg.tryton.org/modules/purchase_line_extras',
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user