first commit
This commit is contained in:
2
modules/sale_invoice_date/tests/__init__.py
Normal file
2
modules/sale_invoice_date/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,94 @@
|
||||
==========================
|
||||
Sale Invoice Date Scenario
|
||||
==========================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from dateutil.relativedelta import relativedelta
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
>>> end_month = today + relativedelta(day=31)
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('sale_invoice_date', create_company, create_chart)
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> InvoiceTerm = Model.get('sale.invoice.term')
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=(today, end_month)))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create invoice term::
|
||||
|
||||
>>> invoice_term = InvoiceTerm(name="End of Month")
|
||||
>>> relative_delta = invoice_term.relative_deltas.new()
|
||||
>>> relative_delta.day = 31
|
||||
>>> invoice_term.save()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.sale_invoice_term = invoice_term
|
||||
>>> customer.save()
|
||||
|
||||
Create account categories::
|
||||
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = accounts['expense']
|
||||
>>> account_category.account_revenue = accounts['revenue']
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Make a sale::
|
||||
|
||||
>>> sale = Sale(party=customer)
|
||||
>>> assertEqual(sale.invoice_term, invoice_term)
|
||||
>>> line = sale.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 1
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
|
||||
Check invoice date::
|
||||
|
||||
>>> invoice, = sale.invoices
|
||||
>>> assertEqual(invoice.invoice_date, end_month)
|
||||
31
modules/sale_invoice_date/tests/test_module.py
Normal file
31
modules/sale_invoice_date/tests/test_module.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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 unittest.mock import MagicMock
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class SaleInvoiceDateTestCase(ModuleTestCase):
|
||||
'Test Sale Invoice Date module'
|
||||
module = 'sale_invoice_date'
|
||||
extras = ['sale_invoice_grouping']
|
||||
|
||||
@with_transaction()
|
||||
def test_invoice_grouping(self):
|
||||
"Test fields to group invoice"
|
||||
pool = Pool()
|
||||
Sale = pool.get('sale.sale')
|
||||
Invoice = pool.get('account.invoice')
|
||||
|
||||
sale = Sale()
|
||||
invoice = MagicMock(spec=Invoice)
|
||||
|
||||
fields = sale._get_invoice_grouping_fields(invoice)
|
||||
|
||||
self.assertIn('invoice_date', fields)
|
||||
self.assertLessEqual(fields, Invoice._fields.keys())
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/sale_invoice_date/tests/test_scenario.py
Normal file
8
modules/sale_invoice_date/tests/test_scenario.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# 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.tests.test_tryton import load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
Reference in New Issue
Block a user