diff --git a/modules/account/move.py b/modules/account/move.py index c357c0e1bd..f817c30500 100644 --- a/modules/account/move.py +++ b/modules/account/move.py @@ -634,8 +634,8 @@ class Reconciliation(ModelSQL, ModelView): def check_lines(cls, reconciliations): Lang = Pool().get('ir.lang') for reconciliation in reconciliations: - debit = Decimal('0.0') - credit = Decimal('0.0') + debit = Decimal(0) + credit = Decimal(0) account = None if reconciliation.lines: party = reconciliation.lines[0].party @@ -1160,13 +1160,13 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView): @fields.depends('debit', 'credit', 'amount_second_currency') def on_change_debit(self): if self.debit: - self.credit = Decimal('0.0') + self.credit = Decimal(0) self._amount_second_currency_sign() @fields.depends('debit', 'credit', 'amount_second_currency') def on_change_credit(self): if self.credit: - self.debit = Decimal('0.0') + self.debit = Decimal(0) self._amount_second_currency_sign() @fields.depends('amount_second_currency', 'debit', 'credit') @@ -1547,8 +1547,8 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView): lines = list(lines) reconcile_account = None reconcile_party = None - amount = Decimal('0.0') - amount_second_currency = Decimal('0.0') + amount = Decimal(0) + amount_second_currency = Decimal(0) second_currencies = set() posted = True for line in lines: @@ -1990,8 +1990,8 @@ class ReconcileLines(Wizard): def get_writeoff(self): "Return writeoff amount and company" company = currency = None - amount = Decimal('0.0') - amount_second_currency = Decimal('0.0') + amount = Decimal(0) + amount_second_currency = Decimal(0) second_currencies = set() for line in self.records: amount += line.debit - line.credit diff --git a/modules/account/tax.py b/modules/account/tax.py index 3f31fa7086..8b0f695362 100644 --- a/modules/account/tax.py +++ b/modules/account/tax.py @@ -1094,7 +1094,7 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin): ''' taxes = cls.sort_taxes(taxes) res = cls._unit_compute(taxes, price_unit, date) - quantity = Decimal(str(quantity or 0.0)) + quantity = Decimal(str(quantity or 0)) for row in res: row['base'] *= quantity row['amount'] *= quantity diff --git a/modules/account/tests/scenario_account_reconciliation.rst b/modules/account/tests/scenario_account_reconciliation.rst index 514818b01e..0e0fc57ec7 100644 --- a/modules/account/tests/scenario_account_reconciliation.rst +++ b/modules/account/tests/scenario_account_reconciliation.rst @@ -195,4 +195,4 @@ Reconcile Lines with write-off:: >>> writeoff_line2.account == expense True >>> writeoff_line2.debit - Decimal('3.0') + Decimal('3') diff --git a/modules/account_es/reporting_tax.py b/modules/account_es/reporting_tax.py index 0cf1c91825..4276fba425 100644 --- a/modules/account_es/reporting_tax.py +++ b/modules/account_es/reporting_tax.py @@ -313,7 +313,7 @@ class AEAT303(AEATReport): "computed code %s already defined" % code) amounts['46'] = amounts['27'] - amounts['45'] amounts['64'] = amounts['46'] + amounts['58'] + amounts['76'] - amounts['66'] = amounts['64'] * Decimal(amounts['65']) / Decimal(100.0) + amounts['66'] = amounts['64'] * Decimal(amounts['65']) / Decimal(100) amounts['110'] = amounts['78'] = amount_to_compensate amounts['87'] = amounts['110'] - amounts['78'] amounts['69'] = (amounts['66'] + amounts['77'] - amounts['78'] diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 0ac9866c55..c7c3b0a60a 100644 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -618,9 +618,9 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): pool = Pool() InvoiceTax = pool.get('account.invoice.tax') - self.untaxed_amount = Decimal('0.0') - self.tax_amount = Decimal('0.0') - self.total_amount = Decimal('0.0') + self.untaxed_amount = Decimal(0) + self.tax_amount = Decimal(0) + self.total_amount = Decimal(0) computed_taxes = {} if self.lines: @@ -632,13 +632,13 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): if self.currency: return self.currency.is_zero(amount) else: - return amount == Decimal('0.0') + return amount == Decimal(0) tax_keys = [] taxes = list(self.taxes or []) for tax in (self.taxes or []): if tax.manual: - self.tax_amount += tax.amount or Decimal('0.0') + self.tax_amount += tax.amount or Decimal(0) continue key = tax._key if (key not in computed_taxes) or (key in tax_keys): @@ -646,12 +646,12 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): continue tax_keys.append(key) if not is_zero(computed_taxes[key]['base'] - - (tax.base or Decimal('0.0'))): + - (tax.base or Decimal(0))): self.tax_amount += computed_taxes[key]['amount'] tax.amount = computed_taxes[key]['amount'] tax.base = computed_taxes[key]['base'] else: - self.tax_amount += tax.amount or Decimal('0.0') + self.tax_amount += tax.amount or Decimal(0) for key in computed_taxes: if key not in tax_keys: self.tax_amount += computed_taxes[key]['amount'] @@ -2403,8 +2403,8 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): if self.type == 'line': currency = (self.invoice.currency if self.invoice else self.currency) - amount = (Decimal(str(self.quantity or '0.0')) - * (self.unit_price or Decimal('0.0'))) + amount = (Decimal(str(self.quantity or 0)) + * (self.unit_price or Decimal(0))) invoice_type = ( self.invoice.type if self.invoice else self.invoice_type) if (invoice_type == 'in' @@ -2419,7 +2419,7 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): if currency: return currency.round(amount) return amount - return Decimal('0.0') + return Decimal(0) def get_amount(self, name): if self.type == 'line': @@ -2898,11 +2898,11 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView): @staticmethod def default_base(): - return Decimal('0.0') + return Decimal(0) @staticmethod def default_amount(): - return Decimal('0.0') + return Decimal(0) @staticmethod def default_manual(): @@ -3359,7 +3359,7 @@ class PayInvoiceAsk(ModelView): @fields.depends( 'lines', 'amount', 'currency', 'invoice', 'payment_lines', 'company') def on_change_lines(self): - self.amount_writeoff = Decimal('0.0') + self.amount_writeoff = Decimal(0) if not self.invoice: return @@ -3436,7 +3436,7 @@ class PayInvoice(Wizard): currency = self.start.currency _, remainder = self.get_reconcile_lines_for_amount( invoice, amount, currency) - if remainder == Decimal('0.0') and amount <= invoice.amount_to_pay: + if remainder == Decimal(0) and amount <= invoice.amount_to_pay: return 'pay' return 'ask' diff --git a/modules/account_invoice/payment_term.py b/modules/account_invoice/payment_term.py index 359ff17a06..faefc7910b 100644 --- a/modules/account_invoice/payment_term.py +++ b/modules/account_invoice/payment_term.py @@ -54,7 +54,7 @@ class PaymentTerm(DeactivableMixin, ModelSQL, ModelView): """ # TODO implement business_days # http://pypi.python.org/pypi/BusinessHours/ - sign = 1 if amount >= Decimal('0.0') else -1 + sign = 1 if amount >= Decimal(0) else -1 res = [] remainder = amount for line in self.lines: @@ -62,7 +62,7 @@ class PaymentTerm(DeactivableMixin, ModelSQL, ModelView): value_date = line.get_date(date) if value is None or not value_date: continue - if ((remainder - value) * sign) < Decimal('0.0'): + if ((remainder - value) * sign) < Decimal(0): res.append((value_date, remainder)) break if value: @@ -133,16 +133,16 @@ class PaymentTermLine(sequence_ordered(), ModelSQL, ModelView): @fields.depends('type') def on_change_type(self): if self.type != 'fixed': - self.amount = Decimal('0.0') + self.amount = Decimal(0) self.currency = None if self.type not in ('percent', 'percent_on_total'): - self.ratio = Decimal('0.0') - self.divisor = Decimal('0.0') + self.ratio = Decimal(0) + self.divisor = Decimal(0) @fields.depends('ratio') def on_change_ratio(self): if not self.ratio: - self.divisor = Decimal('0.0') + self.divisor = Decimal(0) else: self.divisor = self.round(1 / self.ratio, self.__class__.divisor.digits[1]) @@ -150,7 +150,7 @@ class PaymentTermLine(sequence_ordered(), ModelSQL, ModelView): @fields.depends('divisor') def on_change_divisor(self): if not self.divisor: - self.ratio = Decimal('0.0') + self.ratio = Decimal(0) else: self.ratio = self.round(1 / self.divisor, self.__class__.ratio.digits[1]) diff --git a/modules/account_statement/statement.py b/modules/account_statement/statement.py index a117cea061..8a9f382990 100644 --- a/modules/account_statement/statement.py +++ b/modules/account_statement/statement.py @@ -830,7 +830,7 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView): if self.party: if self.amount: with Transaction().set_context(date=self.date): - if self.amount > Decimal("0.0"): + if self.amount > Decimal(0): self.account = self.party.account_receivable_used else: self.account = self.party.account_payable_used @@ -856,7 +856,7 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView): # The user has entered a non-default value, we keep it. pass elif self.amount: - if self.amount > Decimal("0.0"): + if self.amount > Decimal(0): self.account = self.party.account_receivable_used else: self.account = self.party.account_payable_used diff --git a/modules/account_statement_rule/account.py b/modules/account_statement_rule/account.py index b8ba0da384..25ed887165 100644 --- a/modules/account_statement_rule/account.py +++ b/modules/account_statement_rule/account.py @@ -344,7 +344,7 @@ class StatementRuleLine(sequence_ordered(), ModelSQL, ModelView): account = related_to_account elif party: with Transaction().set_context(date=origin.date): - if amount > Decimal('0.0'): + if amount > Decimal(0): account = party.account_receivable_used else: account = party.account_payable_used diff --git a/modules/account_stock_anglo_saxon/invoice.py b/modules/account_stock_anglo_saxon/invoice.py index ee6e2d23cf..ceacb32943 100644 --- a/modules/account_stock_anglo_saxon/invoice.py +++ b/modules/account_stock_anglo_saxon/invoice.py @@ -31,10 +31,10 @@ class InvoiceLine(metaclass=PoolMeta): if type_.startswith('in_'): move_line.debit = amount - move_line.credit = Decimal('0.0') + move_line.credit = Decimal(0) move_line.account = self.product.account_stock_in_used else: - move_line.debit = Decimal('0.0') + move_line.debit = Decimal(0) move_line.credit = amount move_line.account = self.product.account_stock_out_used diff --git a/modules/account_stock_anglo_saxon/stock.py b/modules/account_stock_anglo_saxon/stock.py index 2dccd2087d..f3d26b9c8a 100644 --- a/modules/account_stock_anglo_saxon/stock.py +++ b/modules/account_stock_anglo_saxon/stock.py @@ -143,7 +143,7 @@ class Move(metaclass=PoolMeta): unit, quantity, product.default_uom, round=False) as_qty_field = _get_field(type_) - cost = Decimal('0.0') + cost = Decimal(0) consumed_qty = 0.0 for move, move_qty, move_cost_price in cls._get_anglo_saxon_move( moves, total_qty, type_): diff --git a/modules/account_stock_continental/stock.py b/modules/account_stock_continental/stock.py index 45af021712..d80dc1752e 100644 --- a/modules/account_stock_continental/stock.py +++ b/modules/account_stock_continental/stock.py @@ -37,12 +37,12 @@ class Move(metaclass=PoolMeta): Decimal(str(self.quantity)) * unit_price) if type_.startswith('in_'): - move_line.debit = Decimal('0.0') + move_line.debit = Decimal(0) move_line.credit = amount move_line.account = self.product.account_stock_in_used else: move_line.debit = amount - move_line.credit = Decimal('0.0') + move_line.credit = Decimal(0) move_line.account = self.product.account_stock_out_used return [move_line] @@ -58,12 +58,12 @@ class Move(metaclass=PoolMeta): ) if not amount: return - if amount >= Decimal('0.0'): - move_line.debit = Decimal('0.0') + if amount >= Decimal(0): + move_line.debit = Decimal(0) move_line.credit = amount else: move_line.debit = - amount - move_line.credit = Decimal('0.0') + move_line.credit = Decimal(0) return move_line def _get_account_stock_move_type(self): @@ -141,7 +141,7 @@ class Move(metaclass=PoolMeta): else: account_move_lines = self._get_account_stock_move_lines(type_) - amount = Decimal('0.0') + amount = Decimal(0) for line in account_move_lines: amount += line.debit - line.credit diff --git a/modules/analytic_account/account.py b/modules/analytic_account/account.py index b2fa817eb7..d004b5b874 100644 --- a/modules/analytic_account/account.py +++ b/modules/analytic_account/account.py @@ -232,7 +232,7 @@ class Account( for name in names: if name not in ('credit', 'debit'): raise Exception('Bad argument') - result[name] = {}.fromkeys(ids, Decimal('0.0')) + result[name] = {}.fromkeys(ids, Decimal(0)) id2account = {} for account in accounts: diff --git a/modules/currency/currency.py b/modules/currency/currency.py index b66680bb04..1332cc13a6 100644 --- a/modules/currency/currency.py +++ b/modules/currency/currency.py @@ -120,7 +120,7 @@ class Currency( def on_change_with_rate(self): now = datetime.date.today() closer = datetime.date.min - res = Decimal('0.0') + res = Decimal(0) for rate in self.rates or []: date = getattr(rate, 'date', None) or now if date <= now and date > closer: diff --git a/modules/product_cost_fifo/move.py b/modules/product_cost_fifo/move.py index 77c8295b29..e4169ad1bf 100644 --- a/modules/product_cost_fifo/move.py +++ b/modules/product_cost_fifo/move.py @@ -83,7 +83,7 @@ class Move(metaclass=PoolMeta): with Transaction().set_context(company=self.company.id): fifo_moves = self.product.get_fifo_move(total_qty) - cost_price = Decimal("0.0") + cost_price = Decimal(0) consumed_qty = 0.0 to_save = [] for move, move_qty in fifo_moves: diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index ad24810af9..272baa4d08 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -468,9 +468,9 @@ class Purchase( @fields.depends('lines', 'currency', methods=['get_tax_amount']) def on_change_lines(self): - self.untaxed_amount = Decimal('0.0') - self.tax_amount = Decimal('0.0') - self.total_amount = Decimal('0.0') + self.untaxed_amount = Decimal(0) + self.tax_amount = Decimal(0) + self.total_amount = Decimal(0) if self.lines: for line in self.lines: self.untaxed_amount += getattr(line, 'amount', None) or 0 @@ -1533,7 +1533,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView): if self.type == 'line': return self.on_change_with_amount() elif self.type == 'subtotal': - amount = Decimal('0.0') + amount = Decimal(0) for line2 in self.purchase.lines: if line2.type == 'line': amount += line2.purchase.currency.round( @@ -1541,7 +1541,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView): elif line2.type == 'subtotal': if self == line2: break - amount = Decimal('0.0') + amount = Decimal(0) return amount @fields.depends('purchase', '_parent_purchase.warehouse') diff --git a/modules/purchase_blanket_agreement/purchase.py b/modules/purchase_blanket_agreement/purchase.py index c494b3b0de..287f9afd73 100644 --- a/modules/purchase_blanket_agreement/purchase.py +++ b/modules/purchase_blanket_agreement/purchase.py @@ -568,8 +568,8 @@ class BlanketAgreementLine(ModelSQL, ModelView): '_parent_blanket_agreement.currency') def on_change_with_amount(self, name=None): amount = ( - Decimal(str(self.quantity or '0.0')) - * (self.unit_price or Decimal('0.0'))) + Decimal(str(self.quantity or 0)) + * (self.unit_price or Decimal(0))) if self.blanket_agreement and self.blanket_agreement.currency: return self.blanket_agreement.currency.round(amount) diff --git a/modules/purchase_requisition/purchase.py b/modules/purchase_requisition/purchase.py index b80e9e9f47..d74e148812 100644 --- a/modules/purchase_requisition/purchase.py +++ b/modules/purchase_requisition/purchase.py @@ -234,7 +234,7 @@ class PurchaseRequisition(Workflow, ModelSQL, ModelView): @fields.depends('lines', 'currency') def on_change_with_total_amount(self): - self.total_amount = Decimal('0.0') + self.total_amount = Decimal(0) if self.lines: for line in self.lines: self.total_amount += getattr(line, 'amount', None) or 0 diff --git a/modules/sale/sale.py b/modules/sale/sale.py index 7b27bbc105..41c099a173 100644 --- a/modules/sale/sale.py +++ b/modules/sale/sale.py @@ -528,9 +528,9 @@ class Sale( @fields.depends('lines', 'currency', methods=['get_tax_amount']) def on_change_lines(self): - self.untaxed_amount = Decimal('0.0') - self.tax_amount = Decimal('0.0') - self.total_amount = Decimal('0.0') + self.untaxed_amount = Decimal(0) + self.tax_amount = Decimal(0) + self.total_amount = Decimal(0) if self.lines: for line in self.lines: @@ -1583,18 +1583,18 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView): def on_change_with_amount(self): if self.type == 'line': currency = self.sale.currency if self.sale else None - amount = Decimal(str(self.quantity or '0.0')) * \ - (self.unit_price or Decimal('0.0')) + amount = Decimal(str(self.quantity or 0)) * \ + (self.unit_price or Decimal(0)) if currency: return currency.round(amount) return amount - return Decimal('0.0') + return Decimal(0) def get_amount(self, name): if self.type == 'line': return self.on_change_with_amount() elif self.type == 'subtotal': - amount = Decimal('0.0') + amount = Decimal(0) for line2 in self.sale.lines: if line2.type == 'line': amount += line2.sale.currency.round( @@ -1602,9 +1602,9 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView): elif line2.type == 'subtotal': if self == line2: break - amount = Decimal('0.0') + amount = Decimal(0) return amount - return Decimal('0.0') + return Decimal(0) @fields.depends('sale', '_parent_sale.warehouse') def on_change_with_warehouse(self, name=None): diff --git a/modules/sale_blanket_agreement/sale.py b/modules/sale_blanket_agreement/sale.py index 0292056a9e..2e2cd54885 100644 --- a/modules/sale_blanket_agreement/sale.py +++ b/modules/sale_blanket_agreement/sale.py @@ -521,8 +521,8 @@ class BlanketAgreementLine(ModelSQL, ModelView): '_parent_blanket_agreement.currency') def on_change_with_amount(self, name=None): amount = ( - Decimal(str(self.quantity or '0.0')) - * (self.unit_price or Decimal('0.0'))) + Decimal(str(self.quantity or 0)) + * (self.unit_price or Decimal(0))) if self.blanket_agreement and self.blanket_agreement.currency: return self.blanket_agreement.currency.round(amount)