first commit
This commit is contained in:
2
modules/sale_invoice_grouping/tests/__init__.py
Normal file
2
modules/sale_invoice_grouping/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,183 @@
|
||||
==============================
|
||||
Sale Invoice Grouping Scenario
|
||||
==============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> 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 (
|
||||
... create_payment_term, set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'sale_invoice_grouping', create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> expense = accounts['expense']
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
>>> customer_grouped = Party(name='Customer Grouped',
|
||||
... sale_invoice_grouping_method='standard')
|
||||
>>> customer_grouped.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
|
||||
>>> 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
|
||||
|
||||
Create payment term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Sale some products::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale.invoice_method = 'order'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
|
||||
Make another sale::
|
||||
|
||||
>>> sale, = Sale.duplicate([sale])
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
|
||||
Check the invoices::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoices = Invoice.find([('party', '=', customer.id)])
|
||||
>>> len(invoices)
|
||||
2
|
||||
>>> invoice = invoices[0]
|
||||
>>> invoice.type
|
||||
'out'
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
|
||||
Now we'll use the same scenario with the grouped customer::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer_grouped
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale.invoice_method = 'order'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 1.0
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
|
||||
Make another sale::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer_grouped
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale.invoice_method = 'order'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
|
||||
Check the invoices::
|
||||
|
||||
>>> invoices = Invoice.find([
|
||||
... ('party', '=', customer_grouped.id),
|
||||
... ('state', '=', 'draft'),
|
||||
... ])
|
||||
>>> len(invoices)
|
||||
1
|
||||
>>> invoice, = invoices
|
||||
>>> len(invoice.lines)
|
||||
2
|
||||
>>> invoice.lines[0].quantity
|
||||
1.0
|
||||
>>> invoice.lines[1].quantity
|
||||
2.0
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
|
||||
Create a manual invoice::
|
||||
|
||||
>>> manual_invoice = Invoice()
|
||||
>>> manual_invoice.party = customer_grouped
|
||||
>>> manual_invoice.payment_term = payment_term
|
||||
>>> manual_invoice.save()
|
||||
|
||||
Check that a new sale won't be grouped with the manual invoice::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer_grouped
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale.invoice_method = 'order'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 3.0
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
|
||||
Check the invoices::
|
||||
|
||||
>>> invoices = Invoice.find([
|
||||
... ('party', '=', customer_grouped.id),
|
||||
... ('state', '=', 'draft'),
|
||||
... ])
|
||||
>>> len(invoices)
|
||||
2
|
||||
@@ -0,0 +1,96 @@
|
||||
=======================================
|
||||
Sale Invoice Grouping Multiple Scenario
|
||||
=======================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> 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
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... 'sale_invoice_grouping', create_company, create_chart)
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear())
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> customer = Party(
|
||||
... name="Customer",
|
||||
... sale_invoice_grouping_method='standard')
|
||||
>>> customer.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> 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
|
||||
|
||||
Sale some products::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.invoice_method = 'order'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> sale.click('quote')
|
||||
>>> sales = [sale]
|
||||
|
||||
Make another sale::
|
||||
|
||||
>>> sale, = Sale.duplicate([sale])
|
||||
>>> sale.click('quote')
|
||||
>>> sales.append(sale)
|
||||
|
||||
Confirm both sales::
|
||||
|
||||
>>> Sale.click(sales, 'confirm')
|
||||
>>> state, = set(s.state for s in sales)
|
||||
>>> state
|
||||
'processing'
|
||||
|
||||
Check the invoices::
|
||||
|
||||
>>> invoice, = Invoice.find([('party', '=', customer.id)])
|
||||
|
||||
Deleting the invoice keeps same grouping::
|
||||
|
||||
>>> invoice.delete()
|
||||
>>> invoice, = Invoice.find([('party', '=', customer.id)])
|
||||
12
modules/sale_invoice_grouping/tests/test_module.py
Normal file
12
modules/sale_invoice_grouping/tests/test_module.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# 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 ModuleTestCase
|
||||
|
||||
|
||||
class SaleInvoiceGroupingTestCase(ModuleTestCase):
|
||||
'Test Sale Invoice Grouping module'
|
||||
module = 'sale_invoice_grouping'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/sale_invoice_grouping/tests/test_scenario.py
Normal file
8
modules/sale_invoice_grouping/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