first commit
This commit is contained in:
2
modules/purchase_shipment_cost/tests/__init__.py
Normal file
2
modules/purchase_shipment_cost/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,135 @@
|
||||
===============================
|
||||
Purchase Shipment Cost Scenario
|
||||
===============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('purchase_shipment_cost', create_company)
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.save()
|
||||
|
||||
Create products::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> carrier_template = ProductTemplate()
|
||||
>>> carrier_template.name = 'Carrier Product'
|
||||
>>> carrier_template.default_uom = unit
|
||||
>>> carrier_template.type = 'service'
|
||||
>>> carrier_template.list_price = Decimal('5')
|
||||
>>> carrier_product, = carrier_template.products
|
||||
>>> carrier_product.cost_price = Decimal('3')
|
||||
>>> carrier_template.save()
|
||||
>>> carrier_product, = carrier_template.products
|
||||
|
||||
Create carrier::
|
||||
|
||||
>>> Carrier = Model.get('carrier')
|
||||
>>> carrier = Carrier()
|
||||
>>> party = Party(name='Carrier')
|
||||
>>> party.save()
|
||||
>>> carrier.party = party
|
||||
>>> carrier.carrier_product = carrier_product
|
||||
>>> carrier.save()
|
||||
|
||||
Receive a single product line::
|
||||
|
||||
>>> ShipmentIn = Model.get('stock.shipment.in')
|
||||
>>> Move = Model.get('stock.move')
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> supplier_location, = Location.find([
|
||||
... ('code', '=', 'SUP'),
|
||||
... ])
|
||||
>>> shipment = ShipmentIn()
|
||||
>>> shipment.supplier = supplier
|
||||
>>> move = Move()
|
||||
>>> shipment.incoming_moves.append(move)
|
||||
>>> move.from_location = supplier_location
|
||||
>>> move.to_location = shipment.warehouse.input_location
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 50
|
||||
>>> move.unit_price = Decimal('8')
|
||||
>>> move.currency = shipment.company.currency
|
||||
>>> shipment.carrier = carrier
|
||||
>>> shipment.cost_used
|
||||
Decimal('3.0000')
|
||||
>>> assertEqual(shipment.cost_currency_used, shipment.company.currency)
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.state
|
||||
'received'
|
||||
>>> move, = shipment.incoming_moves
|
||||
>>> move.unit_price
|
||||
Decimal('8.0600')
|
||||
|
||||
Receive many product lines::
|
||||
|
||||
>>> shipment = ShipmentIn()
|
||||
>>> shipment.supplier = supplier
|
||||
>>> for quantity in (1, 3, 5):
|
||||
... move = Move()
|
||||
... shipment.incoming_moves.append(move)
|
||||
... move.from_location = supplier_location
|
||||
... move.to_location = shipment.warehouse.input_location
|
||||
... move.product = product
|
||||
... move.quantity = quantity
|
||||
... move.unit_price = Decimal('8')
|
||||
... move.currency = shipment.company.currency
|
||||
>>> shipment.carrier = carrier
|
||||
>>> shipment.cost_used
|
||||
Decimal('3.0000')
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.state
|
||||
'received'
|
||||
>>> [move.unit_price for move in shipment.incoming_moves]
|
||||
[Decimal('8.3334'), Decimal('8.3333'), Decimal('8.3333')]
|
||||
|
||||
Receive a two lines with no cost::
|
||||
|
||||
>>> shipment = ShipmentIn()
|
||||
>>> shipment.supplier = supplier
|
||||
>>> move = shipment.incoming_moves.new()
|
||||
>>> move.from_location = supplier_location
|
||||
>>> move.to_location = shipment.warehouse.input_location
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 75
|
||||
>>> move.unit_price = Decimal('0.0')
|
||||
>>> move.currency = shipment.company.currency
|
||||
>>> move = shipment.incoming_moves.new()
|
||||
>>> move.from_location = supplier_location
|
||||
>>> move.to_location = shipment.warehouse.input_location
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 25
|
||||
>>> move.unit_price = Decimal('0.0')
|
||||
>>> move.currency = shipment.company.currency
|
||||
>>> shipment.carrier = carrier
|
||||
>>> shipment.cost_used
|
||||
Decimal('3.0000')
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.state
|
||||
'received'
|
||||
>>> tuple(m.unit_price for m in shipment.incoming_moves)
|
||||
(Decimal('0.0200'), Decimal('0.0600'))
|
||||
@@ -0,0 +1,136 @@
|
||||
==================================================
|
||||
Purchase Shipment Cost with Invoice Stock Scenario
|
||||
==================================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> 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
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules([
|
||||
... 'purchase_shipment_cost',
|
||||
... 'account_invoice_stock',
|
||||
... 'purchase',
|
||||
... ],
|
||||
... create_company, create_chart)
|
||||
|
||||
>>> Carrier = Model.get('carrier')
|
||||
>>> Move = Model.get('stock.move')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> Purchase = Model.get('purchase.purchase')
|
||||
>>> ShipmentIn = Model.get('stock.shipment.in')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=today))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Create account categories::
|
||||
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = accounts['expense']
|
||||
>>> account_category.save()
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.save()
|
||||
|
||||
Create products::
|
||||
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.purchasable = True
|
||||
>>> template.account_category = account_category
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> carrier_template = ProductTemplate()
|
||||
>>> carrier_template.name = 'Carrier Product'
|
||||
>>> carrier_template.default_uom = unit
|
||||
>>> carrier_template.type = 'service'
|
||||
>>> carrier_template.list_price = Decimal('5')
|
||||
>>> carrier_product, = carrier_template.products
|
||||
>>> carrier_product.cost_price = Decimal('3')
|
||||
>>> carrier_template.save()
|
||||
>>> carrier_product, = carrier_template.products
|
||||
|
||||
Create carrier::
|
||||
|
||||
>>> carrier = Carrier()
|
||||
>>> party = Party(name='Carrier')
|
||||
>>> party.save()
|
||||
>>> carrier.party = party
|
||||
>>> carrier.carrier_product = carrier_product
|
||||
>>> carrier.save()
|
||||
|
||||
Purchase a product::
|
||||
|
||||
>>> purchase = Purchase()
|
||||
>>> purchase.party = supplier
|
||||
>>> line = purchase.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal('10')
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.state
|
||||
'processing'
|
||||
|
||||
Receive the product::
|
||||
|
||||
>>> shipment = ShipmentIn()
|
||||
>>> shipment.supplier = supplier
|
||||
>>> move, = purchase.moves
|
||||
>>> shipment.incoming_moves.append(Move(id=move.id))
|
||||
>>> shipment.carrier = carrier
|
||||
>>> shipment.cost_used
|
||||
Decimal('3.0000')
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.state
|
||||
'received'
|
||||
>>> move, = shipment.incoming_moves
|
||||
>>> move.unit_price
|
||||
Decimal('13.0000')
|
||||
|
||||
Post the invoice with a different price::
|
||||
|
||||
>>> invoice, = purchase.invoices
|
||||
>>> line, = invoice.lines
|
||||
>>> line.unit_price = Decimal('9')
|
||||
>>> invoice.invoice_date = today
|
||||
>>> invoice.click('post')
|
||||
|
||||
Check unit price of move::
|
||||
|
||||
>>> move.reload()
|
||||
>>> move.unit_price
|
||||
Decimal('12.0000')
|
||||
@@ -0,0 +1,183 @@
|
||||
==================================================
|
||||
Purchase Shipment Cost with Account Stock 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_stock_continental.tests.tools import (
|
||||
... add_stock_accounts)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules([
|
||||
... 'purchase_shipment_cost',
|
||||
... 'account_stock_continental',
|
||||
... ],
|
||||
... create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = create_fiscalyear()
|
||||
>>> fiscalyear.account_stock_method = 'continental'
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_stock_accounts(get_accounts())
|
||||
>>> receivable = accounts['receivable']
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> expense = accounts['expense']
|
||||
>>> stock = accounts['stock']
|
||||
>>> stock_in = accounts['stock_expense']
|
||||
>>> stock_out, = stock_in.duplicate()
|
||||
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> stock_journal, = AccountJournal.find([('code', '=', 'STO')])
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.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.account_stock = stock
|
||||
>>> account_category.account_stock_in = stock_in
|
||||
>>> account_category.account_stock_out = stock_out
|
||||
>>> account_category.save()
|
||||
|
||||
Create products::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.account_category = account_category
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
>>> template_average, = template.duplicate({
|
||||
... 'cost_price_method': 'average',
|
||||
... })
|
||||
>>> template_average.account_category = account_category
|
||||
>>> template_average.save()
|
||||
>>> product_average, = template_average.products
|
||||
|
||||
>>> carrier_template = ProductTemplate()
|
||||
>>> carrier_template.name = 'Carrier Product'
|
||||
>>> carrier_template.default_uom = unit
|
||||
>>> carrier_template.type = 'service'
|
||||
>>> carrier_template.list_price = Decimal('5')
|
||||
>>> carrier_template.account_category = account_category
|
||||
>>> carrier_product, = carrier_template.products
|
||||
>>> carrier_product.cost_price = Decimal('3')
|
||||
>>> carrier_template.save()
|
||||
>>> carrier_product, = carrier_template.products
|
||||
|
||||
Create carrier::
|
||||
|
||||
>>> Carrier = Model.get('carrier')
|
||||
>>> carrier = Carrier()
|
||||
>>> party = Party(name='Carrier')
|
||||
>>> party.save()
|
||||
>>> carrier.party = party
|
||||
>>> carrier.carrier_product = carrier_product
|
||||
>>> carrier.save()
|
||||
|
||||
Receive a single product line::
|
||||
|
||||
>>> ShipmentIn = Model.get('stock.shipment.in')
|
||||
>>> Move = Model.get('stock.move')
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> supplier_location, = Location.find([
|
||||
... ('code', '=', 'SUP'),
|
||||
... ])
|
||||
>>> shipment = ShipmentIn()
|
||||
>>> shipment.supplier = supplier
|
||||
>>> move = Move()
|
||||
>>> shipment.incoming_moves.append(move)
|
||||
>>> move.from_location = supplier_location
|
||||
>>> move.to_location = shipment.warehouse.input_location
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 30
|
||||
>>> move.unit_price = Decimal('8')
|
||||
>>> move.currency = shipment.company.currency
|
||||
>>> move = Move()
|
||||
>>> shipment.incoming_moves.append(move)
|
||||
>>> move.from_location = supplier_location
|
||||
>>> move.to_location = shipment.warehouse.input_location
|
||||
>>> move.product = product_average
|
||||
>>> move.quantity = 20
|
||||
>>> move.unit_price = Decimal('8')
|
||||
>>> move.currency = shipment.company.currency
|
||||
>>> shipment.carrier = carrier
|
||||
>>> shipment.cost_used
|
||||
Decimal('3.0000')
|
||||
>>> assertEqual(shipment.cost_currency_used, shipment.company.currency)
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.state
|
||||
'received'
|
||||
>>> move, move_average = shipment.incoming_moves
|
||||
>>> move.unit_price
|
||||
Decimal('8.0600')
|
||||
>>> move_average.unit_price
|
||||
Decimal('8.0600')
|
||||
>>> stock_in.reload()
|
||||
>>> (stock_in.debit, stock_in.credit)
|
||||
(Decimal('0.00'), Decimal('398.20'))
|
||||
>>> expense.reload()
|
||||
>>> (expense.debit, expense.credit)
|
||||
(Decimal('0.00'), Decimal('3.00'))
|
||||
>>> stock.reload()
|
||||
>>> (stock.debit, stock.credit)
|
||||
(Decimal('401.20'), Decimal('0.00'))
|
||||
|
||||
Receive many product lines::
|
||||
|
||||
>>> shipment = ShipmentIn()
|
||||
>>> shipment.supplier = supplier
|
||||
>>> for quantity in (1, 3, 5):
|
||||
... move = Move()
|
||||
... shipment.incoming_moves.append(move)
|
||||
... move.from_location = supplier_location
|
||||
... move.to_location = shipment.warehouse.input_location
|
||||
... move.product = product
|
||||
... move.quantity = quantity
|
||||
... move.unit_price = Decimal('8')
|
||||
... move.currency = shipment.company.currency
|
||||
>>> shipment.carrier = carrier
|
||||
>>> shipment.cost_used
|
||||
Decimal('3.0000')
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.state
|
||||
'received'
|
||||
>>> [move.unit_price for move in shipment.incoming_moves]
|
||||
[Decimal('8.3334'), Decimal('8.3333'), Decimal('8.3333')]
|
||||
>>> stock_in.reload()
|
||||
>>> (stock_in.debit, stock_in.credit)
|
||||
(Decimal('0.00'), Decimal('467.20'))
|
||||
>>> expense.reload()
|
||||
>>> (expense.debit, expense.credit)
|
||||
(Decimal('0.00'), Decimal('6.00'))
|
||||
>>> stock.reload()
|
||||
>>> (stock.debit, stock.credit)
|
||||
(Decimal('473.20'), Decimal('0.00'))
|
||||
@@ -0,0 +1,198 @@
|
||||
==============================================================
|
||||
Purchase Shipment Cost with Account Stock Anglo-Saxon Scenario
|
||||
==============================================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> 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.account_stock_anglo_saxon.tests.tools import (
|
||||
... add_cogs_accounts)
|
||||
>>> from trytond.modules.account_stock_continental.tests.tools import (
|
||||
... add_stock_accounts)
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules([
|
||||
... 'purchase_shipment_cost',
|
||||
... 'account_stock_anglo_saxon',
|
||||
... 'purchase',
|
||||
... ],
|
||||
... create_company, create_chart)
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(today=today))
|
||||
>>> fiscalyear.account_stock_method = 'anglo_saxon'
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Get accounts::
|
||||
|
||||
>>> accounts = add_cogs_accounts(add_stock_accounts(get_accounts()))
|
||||
>>> receivable = accounts['receivable']
|
||||
>>> payable = accounts['payable']
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> expense = accounts['expense']
|
||||
>>> stock = accounts['stock']
|
||||
>>> stock_in = accounts['stock_expense']
|
||||
>>> stock_out, = stock_in.duplicate()
|
||||
>>> cogs = accounts['cogs']
|
||||
|
||||
>>> AccountJournal = Model.get('account.journal')
|
||||
>>> stock_journal, = AccountJournal.find([('code', '=', 'STO')])
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.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.account_stock = stock
|
||||
>>> account_category.account_cogs = cogs
|
||||
>>> account_category.account_stock_in = stock_in
|
||||
>>> account_category.account_stock_out = stock_out
|
||||
>>> 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.purchasable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.cost_price_method = 'average'
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> carrier_template = ProductTemplate()
|
||||
>>> carrier_template.name = 'Carrier Product'
|
||||
>>> carrier_template.default_uom = unit
|
||||
>>> carrier_template.type = 'service'
|
||||
>>> carrier_template.list_price = Decimal('5')
|
||||
>>> carrier_template.account_category = account_category
|
||||
>>> carrier_product, = carrier_template.products
|
||||
>>> carrier_product.cost_price = Decimal('3')
|
||||
>>> carrier_template.save()
|
||||
>>> carrier_product, = carrier_template.products
|
||||
|
||||
Create carrier::
|
||||
|
||||
>>> Carrier = Model.get('carrier')
|
||||
>>> carrier = Carrier()
|
||||
>>> party = Party(name='Carrier')
|
||||
>>> party.save()
|
||||
>>> carrier.party = party
|
||||
>>> carrier.carrier_product = carrier_product
|
||||
>>> carrier.save()
|
||||
|
||||
Create payment term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Purchase 5 products::
|
||||
|
||||
>>> Purchase = Model.get('purchase.purchase')
|
||||
>>> PurchaseLine = Model.get('purchase.line')
|
||||
>>> purchase = Purchase()
|
||||
>>> purchase.party = supplier
|
||||
>>> purchase.payment_term = payment_term
|
||||
>>> purchase.invoice_method = 'shipment'
|
||||
>>> purchase_line = PurchaseLine()
|
||||
>>> purchase.lines.append(purchase_line)
|
||||
>>> purchase_line.product = product
|
||||
>>> purchase_line.quantity = 5.0
|
||||
>>> purchase_line.unit_price = Decimal('5.0000')
|
||||
>>> purchase.click('quote')
|
||||
>>> purchase.click('confirm')
|
||||
>>> purchase.click('process')
|
||||
>>> purchase.state
|
||||
'processing'
|
||||
|
||||
Receive 4 products::
|
||||
|
||||
>>> ShipmentIn = Model.get('stock.shipment.in')
|
||||
>>> Move = Model.get('stock.move')
|
||||
>>> shipment = ShipmentIn(supplier=supplier)
|
||||
>>> move = Move(purchase.moves[0].id)
|
||||
>>> move.quantity = 4.0
|
||||
>>> shipment.incoming_moves.append(move)
|
||||
>>> shipment.carrier = carrier
|
||||
>>> shipment.cost_used
|
||||
Decimal('3.0000')
|
||||
>>> assertEqual(shipment.cost_currency_used, shipment.company.currency)
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.state
|
||||
'received'
|
||||
>>> move, = shipment.incoming_moves
|
||||
>>> move.unit_price
|
||||
Decimal('5.7500')
|
||||
>>> shipment.click('do')
|
||||
>>> shipment.state
|
||||
'done'
|
||||
>>> stock_in.reload()
|
||||
>>> stock.reload()
|
||||
>>> stock_in.debit
|
||||
Decimal('0.00')
|
||||
>>> stock_in.credit
|
||||
Decimal('20.00')
|
||||
>>> stock.reload()
|
||||
>>> stock.debit
|
||||
Decimal('23.00')
|
||||
>>> stock.credit
|
||||
Decimal('0.00')
|
||||
>>> expense.reload()
|
||||
>>> expense.debit
|
||||
Decimal('0.00')
|
||||
>>> expense.credit
|
||||
Decimal('3.00')
|
||||
|
||||
Open supplier invoice::
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> purchase.reload()
|
||||
>>> invoice, = purchase.invoices
|
||||
>>> invoice.invoice_date = today
|
||||
>>> invoice.save()
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
'posted'
|
||||
>>> payable.reload()
|
||||
>>> payable.debit
|
||||
Decimal('0.00')
|
||||
>>> payable.credit
|
||||
Decimal('20.00')
|
||||
>>> expense.reload()
|
||||
>>> expense.debit
|
||||
Decimal('20.00')
|
||||
>>> expense.credit
|
||||
Decimal('23.00')
|
||||
>>> stock_in.reload()
|
||||
>>> stock_in.debit
|
||||
Decimal('20.00')
|
||||
>>> stock_in.credit
|
||||
Decimal('20.00')
|
||||
13
modules/purchase_shipment_cost/tests/test_module.py
Normal file
13
modules/purchase_shipment_cost/tests/test_module.py
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
# 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 PurchaseShipmentCostTestCase(ModuleTestCase):
|
||||
'Test Purchase Shipment Cost module'
|
||||
module = 'purchase_shipment_cost'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/purchase_shipment_cost/tests/test_scenario.py
Normal file
8
modules/purchase_shipment_cost/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