Remove default invoice type using the context
Since 6693e138391b the context keyword is no more used.
This commit is contained in:
@@ -77,8 +77,24 @@ class Invoice(metaclass=PoolMeta):
|
||||
'readonly': Eval('state') != 'draft',
|
||||
})
|
||||
|
||||
@fields.depends('company', 'type')
|
||||
@fields.depends(methods=['set_cash_rounding'])
|
||||
def on_change_company(self):
|
||||
try:
|
||||
super().on_change_company()
|
||||
except AttributeError:
|
||||
pass
|
||||
self.set_cash_rounding()
|
||||
|
||||
@fields.depends(methods=['set_cash_rounding'])
|
||||
def on_change_type(self):
|
||||
try:
|
||||
super().on_change_type()
|
||||
except AttributeError:
|
||||
pass
|
||||
self.set_cash_rounding()
|
||||
|
||||
@fields.depends('company', 'type')
|
||||
def set_cash_rounding(self):
|
||||
pool = Pool()
|
||||
Config = pool.get('account.configuration')
|
||||
config = Config(1)
|
||||
@@ -91,15 +107,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
'cash_rounding',
|
||||
company=self.company.id if self.company else None)
|
||||
|
||||
@classmethod
|
||||
def default_cash_rounding(cls, **pattern):
|
||||
pool = Pool()
|
||||
Config = pool.get('account.configuration')
|
||||
config = Config(1)
|
||||
if cls.default_type() == 'out':
|
||||
return config.get_multivalue(
|
||||
'cash_rounding', **pattern)
|
||||
|
||||
@fields.depends(methods=['_on_change_lines_taxes'])
|
||||
def on_change_cash_rounding(self):
|
||||
self._on_change_lines_taxes()
|
||||
|
||||
@@ -73,7 +73,7 @@ Create payment term::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> bool(invoice.cash_rounding)
|
||||
True
|
||||
>>> invoice.party = party
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ Create party::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.cash_rounding = True
|
||||
>>> invoice.currency = eur
|
||||
>>> bool(invoice.cash_rounding)
|
||||
|
||||
@@ -48,7 +48,7 @@ Create chart of accounts::
|
||||
|
||||
Create invoice::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = saber.party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
|
||||
@@ -43,7 +43,7 @@ Create payment_term::
|
||||
Create deposit invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice(party=party, payment_term=payment_term)
|
||||
>>> invoice = Invoice(type='out', party=party, payment_term=payment_term)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['deposit']
|
||||
>>> line.description = 'Deposit'
|
||||
@@ -61,7 +61,7 @@ Check party deposit::
|
||||
|
||||
Create final invoice::
|
||||
|
||||
>>> invoice = Invoice(party=party, payment_term=payment_term)
|
||||
>>> invoice = Invoice(type='out', party=party, payment_term=payment_term)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.description = 'Revenue'
|
||||
|
||||
@@ -60,7 +60,8 @@ Create party::
|
||||
|
||||
Create deposit invoice::
|
||||
|
||||
>>> invoice = Invoice(party=party, currency=eur, invoice_date=yesterday)
|
||||
>>> invoice = Invoice(
|
||||
... type='out', party=party, currency=eur, invoice_date=yesterday)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['deposit']
|
||||
>>> line.description = "Deposit"
|
||||
@@ -78,7 +79,7 @@ Check party deposit::
|
||||
|
||||
Create final invoice::
|
||||
|
||||
>>> invoice = Invoice(party=party, currency=eur, invoice_date=today)
|
||||
>>> invoice = Invoice(type='out', party=party, currency=eur, invoice_date=today)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.description = "Revenue"
|
||||
|
||||
@@ -134,7 +134,7 @@ Create product::
|
||||
Create invoices::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.invoice_date = period.start_date
|
||||
>>> line = invoice.lines.new()
|
||||
@@ -144,8 +144,8 @@ Create invoices::
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.total_amount
|
||||
Decimal('242.00')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.type = 'in'
|
||||
|
||||
>>> invoice = Invoice(type='in')
|
||||
>>> invoice.party = supplier
|
||||
>>> invoice.invoice_date = period.start_date
|
||||
>>> line = invoice.lines.new()
|
||||
@@ -155,8 +155,8 @@ Create invoices::
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.total_amount
|
||||
Decimal('106.00')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.type = 'in'
|
||||
|
||||
>>> invoice = Invoice(type='in')
|
||||
>>> invoice.party = ec_supplier
|
||||
>>> invoice.invoice_date = period.start_date
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -70,7 +70,7 @@ Create invoices::
|
||||
... ('name', '=', 'IVA Intracomunitario 21% (bienes)'),
|
||||
... ])
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.invoice_date = today
|
||||
>>> invoice.currency = eur
|
||||
@@ -82,8 +82,8 @@ Create invoices::
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.total_amount
|
||||
Decimal('242.00')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.type = 'in'
|
||||
|
||||
>>> invoice = Invoice(type='in')
|
||||
>>> invoice.party = supplier
|
||||
>>> invoice.currency = eur
|
||||
>>> invoice.invoice_date = today
|
||||
|
||||
@@ -85,7 +85,7 @@ Create product::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.invoice_date = period.start_date
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -72,7 +72,7 @@ Create invoices::
|
||||
... ('es_reported_with', '=', tax.id),
|
||||
... ])
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.invoice_date = fiscalyear.start_date
|
||||
>>> line = invoice.lines.new()
|
||||
@@ -84,7 +84,8 @@ Create invoices::
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.total_amount
|
||||
Decimal('121.00')
|
||||
>>> invoice = Invoice()
|
||||
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = surcharge_party
|
||||
>>> invoice.invoice_date = fiscalyear.start_date
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Remove default invoice type
|
||||
|
||||
Version 7.8.0 - 2025-12-15
|
||||
--------------------------
|
||||
|
||||
@@ -535,10 +535,6 @@ class Invoice(
|
||||
~((table.state == 'cancelled') & (table.number == Null)),
|
||||
CharLength(table.number), table.number]
|
||||
|
||||
@staticmethod
|
||||
def default_type():
|
||||
return Transaction().context.get('type', 'out')
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
return 'draft'
|
||||
|
||||
@@ -63,7 +63,7 @@ Create product::
|
||||
|
||||
Create invoice::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.product = product
|
||||
|
||||
@@ -84,7 +84,7 @@ Create product::
|
||||
Create credit note::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.product = product
|
||||
|
||||
@@ -146,7 +146,7 @@ Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> InvoiceLine = Model.get('account.invoice.line')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = InvoiceLine()
|
||||
@@ -352,7 +352,7 @@ Pay invoice::
|
||||
|
||||
Create empty invoice::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> invoice.click('post')
|
||||
@@ -361,7 +361,7 @@ Create empty invoice::
|
||||
|
||||
Create some complex invoice and test its taxes base rounding::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> invoice.invoice_date = today
|
||||
@@ -392,7 +392,7 @@ Clear company tax_identifier::
|
||||
|
||||
Create a paid invoice::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
@@ -419,7 +419,7 @@ The invoice is posted when the reconciliation is deleted::
|
||||
|
||||
Credit invoice with non line lines::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -117,7 +117,7 @@ Create product::
|
||||
Create invoice with alternate currency::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.currency = eur
|
||||
>>> line = invoice.lines.new()
|
||||
@@ -157,7 +157,7 @@ Create negative tax::
|
||||
|
||||
Create invoice with alternate currency and negative taxes::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.currency = eur
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -71,7 +71,7 @@ Create party::
|
||||
|
||||
Create invoice::
|
||||
|
||||
>>> invoice = Invoice(party=party)
|
||||
>>> invoice = Invoice(type='out', party=party)
|
||||
>>> invoice.currency = eur
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -66,7 +66,7 @@ Create party::
|
||||
Create invoice with alternate currency::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.currency = eur
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -81,7 +81,7 @@ Create party::
|
||||
|
||||
Create invoice with alternate currency::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.currency = eur
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -56,7 +56,7 @@ Create parties::
|
||||
|
||||
Post customer invoice::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party1
|
||||
>>> invoice.alternative_payees.append(Party(party2.id))
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -48,7 +48,7 @@ Create party::
|
||||
Post customer invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = revenue
|
||||
|
||||
@@ -42,7 +42,7 @@ Create party::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = revenue
|
||||
|
||||
@@ -61,7 +61,7 @@ Create party::
|
||||
Create an invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice(party=party)
|
||||
>>> invoice = Invoice(type='out', party=party)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
>>> line.quantity = 1
|
||||
|
||||
@@ -52,7 +52,7 @@ Create party::
|
||||
|
||||
Post customer invoice::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
|
||||
@@ -53,7 +53,7 @@ Create party::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
|
||||
@@ -39,7 +39,7 @@ Create party::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = revenue
|
||||
|
||||
@@ -61,7 +61,7 @@ Create party::
|
||||
|
||||
Create invoice::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = accounts['revenue']
|
||||
|
||||
@@ -50,7 +50,7 @@ Create party::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.description = 'Description'
|
||||
@@ -138,7 +138,7 @@ Set party as direct debit::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> bool(invoice.payment_direct_debit)
|
||||
True
|
||||
|
||||
+3
-3
@@ -70,7 +70,7 @@ Create parties::
|
||||
Create and pay an invoice without clearing::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = customer
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.account = revenue
|
||||
@@ -104,7 +104,7 @@ Create and pay an invoice without clearing::
|
||||
|
||||
Create an invoice and pay it::
|
||||
|
||||
>>> invoice1 = Invoice()
|
||||
>>> invoice1 = Invoice(type='out')
|
||||
>>> invoice1.party = customer
|
||||
>>> line = invoice1.lines.new()
|
||||
>>> line.account = revenue
|
||||
@@ -148,7 +148,7 @@ Unreconcile the payment line and check the amount to pay::
|
||||
|
||||
Create a second invoice and reconcile its line to pay with the payment::
|
||||
|
||||
>>> invoice2 = Invoice()
|
||||
>>> invoice2 = Invoice(type='out')
|
||||
>>> invoice2.party = customer
|
||||
>>> line = invoice2.lines.new()
|
||||
>>> line.account = revenue
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ Create a party::
|
||||
|
||||
Create an invoice::
|
||||
|
||||
>>> invoice = Invoice(party=customer)
|
||||
>>> invoice = Invoice(type='out', party=customer)
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('40.0000')
|
||||
|
||||
@@ -278,7 +278,7 @@ Now create a supplier invoice with an accountant::
|
||||
|
||||
Create customer invoice with negative quantity::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = customer
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> invoice_line = invoice.lines.new()
|
||||
|
||||
@@ -84,7 +84,7 @@ Create party::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.invoice_date = period.start_date
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -70,7 +70,7 @@ Create party::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -76,7 +76,7 @@ Create payment term::
|
||||
Create invoice with analytic accounts::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
@@ -98,7 +98,7 @@ Create invoice with analytic accounts::
|
||||
|
||||
Create invoice with an empty analytic account::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -135,7 +135,7 @@ Create product sold::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = customer
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> invoice.agent = agent
|
||||
|
||||
@@ -98,7 +98,7 @@ Create product sold::
|
||||
|
||||
Create invoice and credit it before paying::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = customer
|
||||
>>> invoice.agent = agent
|
||||
>>> line = invoice.lines.new()
|
||||
|
||||
@@ -105,7 +105,7 @@ Create agent::
|
||||
Create invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice = Invoice(type='out')
|
||||
>>> invoice.party = customer
|
||||
>>> invoice.payment_term = payment_term
|
||||
>>> invoice.agent = agent
|
||||
|
||||
@@ -154,7 +154,7 @@ Check the invoices::
|
||||
|
||||
Create a manual invoice::
|
||||
|
||||
>>> manual_invoice = Invoice()
|
||||
>>> manual_invoice = Invoice(type='out')
|
||||
>>> manual_invoice.party = customer_grouped
|
||||
>>> manual_invoice.payment_term = payment_term
|
||||
>>> manual_invoice.save()
|
||||
|
||||
Reference in New Issue
Block a user