Fix account stock with fixed cost price
issue2423 review231004
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Use cost price instead of unit price when cost method is "fixed"
|
||||
|
||||
Version 2.2.0 - 2011-10-24
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
|
||||
|
||||
+4
-3
@@ -23,9 +23,10 @@ An Account Move is created for each Stock Move for which one Stock Location has
|
||||
the type "Storage" and an the other has the type "Supplier", "Customer" or
|
||||
"Lost and Found".
|
||||
|
||||
If the Stock Move has a "Supplier" Location as origin, then the Account
|
||||
Stock of the Product is debited and the Account Stock Supplier of the Product is
|
||||
credited. The amount is the Unit Price of the move.
|
||||
If the Stock Move has a "Supplier" Location as origin, then the Account Stock
|
||||
of the Product is debited and the Account Stock Supplier of the Product is
|
||||
credited. The amount is the Unit Price of the move or the Cost Price of the
|
||||
Product if it uses the "fixed" method.
|
||||
The account move is inverted if it is the destination.
|
||||
|
||||
If the Stock Move has a "Customer" Location as destination, then the Account
|
||||
|
||||
@@ -22,7 +22,8 @@ class Move(ModelSQL, ModelView):
|
||||
move_line = {
|
||||
'name': move.rec_name,
|
||||
}
|
||||
if type_.endswith('supplier'):
|
||||
if (type_.endswith('supplier')
|
||||
and move.product.cost_price_method != 'fixed'):
|
||||
unit_price = move.unit_price
|
||||
else:
|
||||
unit_price = uom_obj.compute_price(move.product.default_uom,
|
||||
|
||||
@@ -148,6 +148,7 @@ Create product::
|
||||
>>> product.salable = True
|
||||
>>> product.list_price = Decimal('10')
|
||||
>>> product.cost_price = Decimal('5')
|
||||
>>> product.cost_price_method = 'fixed'
|
||||
>>> product.account_expense = expense
|
||||
>>> product.account_revenue = revenue
|
||||
>>> product.account_stock = stock
|
||||
@@ -158,6 +159,9 @@ Create product::
|
||||
>>> product.account_journal_stock_customer = stock_journal
|
||||
>>> product.account_journal_stock_lost_found = stock_journal
|
||||
>>> product.save()
|
||||
>>> product_average = Product(Product.copy(product.id, config.context))
|
||||
>>> product_average.cost_price_method = 'average'
|
||||
>>> product_average.save()
|
||||
|
||||
Create payment term::
|
||||
|
||||
@@ -168,7 +172,7 @@ Create payment term::
|
||||
>>> payment_term.lines.append(payment_term_line)
|
||||
>>> payment_term.save()
|
||||
|
||||
Purchase 5 products::
|
||||
Purchase 12 products::
|
||||
|
||||
>>> Purchase = Model.get('purchase.purchase')
|
||||
>>> PurchaseLine = Model.get('purchase.line')
|
||||
@@ -180,6 +184,12 @@ Purchase 5 products::
|
||||
>>> purchase.lines.append(purchase_line)
|
||||
>>> purchase_line.product = product
|
||||
>>> purchase_line.quantity = 5.0
|
||||
>>> purchase_line.unit_price = Decimal(4)
|
||||
>>> purchase_line = PurchaseLine()
|
||||
>>> purchase.lines.append(purchase_line)
|
||||
>>> purchase_line.product = product_average
|
||||
>>> purchase_line.quantity = 7.0
|
||||
>>> purchase_line.unit_price = Decimal(6)
|
||||
>>> purchase.save()
|
||||
>>> Purchase.workflow_trigger_validate(purchase.id, 'quotation',
|
||||
... config.context)
|
||||
@@ -188,7 +198,7 @@ Purchase 5 products::
|
||||
>>> purchase.state
|
||||
u'confirmed'
|
||||
|
||||
Receive 4 products::
|
||||
Receive 9 products::
|
||||
|
||||
>>> ShipmentIn = Model.get('stock.shipment.in')
|
||||
>>> Move = Model.get('stock.move')
|
||||
@@ -196,6 +206,9 @@ Receive 4 products::
|
||||
>>> move = Move(purchase.moves[0].id)
|
||||
>>> shipment.incoming_moves.append(move)
|
||||
>>> move.quantity = 4.0
|
||||
>>> move = Move(purchase.moves[1].id)
|
||||
>>> shipment.incoming_moves.append(move)
|
||||
>>> move.quantity = 5.0
|
||||
>>> shipment.save()
|
||||
>>> ShipmentIn.workflow_trigger_validate(shipment.id, 'received',
|
||||
... config.context)
|
||||
@@ -205,11 +218,11 @@ Receive 4 products::
|
||||
u'done'
|
||||
>>> stock_supplier.reload()
|
||||
>>> (stock_supplier.debit, stock_supplier.credit) == \
|
||||
... (Decimal('0.00'), Decimal('20.00'))
|
||||
... (Decimal('0.00'), Decimal('50.00'))
|
||||
True
|
||||
>>> stock.reload()
|
||||
>>> (stock.debit, stock.credit) == \
|
||||
... (Decimal('20.00'), Decimal('0.00'))
|
||||
... (Decimal('50.00'), Decimal('0.00'))
|
||||
True
|
||||
|
||||
Open supplier invoice::
|
||||
@@ -217,27 +230,24 @@ Open supplier invoice::
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> purchase.reload()
|
||||
>>> invoice, = purchase.invoices
|
||||
>>> invoice_line, = invoice.lines
|
||||
>>> invoice_line = invoice.lines[0]
|
||||
>>> invoice_line.unit_price = Decimal('6')
|
||||
>>> invoice_line = invoice.lines[1]
|
||||
>>> invoice_line.unit_price = Decimal('4')
|
||||
>>> invoice.save()
|
||||
>>> Invoice.workflow_trigger_validate(invoice.id, 'open', config.context)
|
||||
>>> invoice.state
|
||||
u'open'
|
||||
>>> payable.reload()
|
||||
>>> (payable.debit, payable.credit) == \
|
||||
... (Decimal('0.00'), Decimal('24.00'))
|
||||
... (Decimal('0.00'), Decimal('44.00'))
|
||||
True
|
||||
>>> expense.reload()
|
||||
>>> (expense.debit, expense.credit) == \
|
||||
... (Decimal('24.00'), Decimal('0.00'))
|
||||
... (Decimal('44.00'), Decimal('0.00'))
|
||||
True
|
||||
|
||||
Update cost price of product::
|
||||
|
||||
>>> product.cost_price = Decimal('6')
|
||||
>>> product.save()
|
||||
|
||||
Sale 2 products::
|
||||
Sale 5 products::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> SaleLine = Model.get('sale.line')
|
||||
@@ -249,6 +259,10 @@ Sale 2 products::
|
||||
>>> sale.lines.append(sale_line)
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> sale_line = SaleLine()
|
||||
>>> sale.lines.append(sale_line)
|
||||
>>> sale_line.product = product_average
|
||||
>>> sale_line.quantity = 3.0
|
||||
>>> sale.save()
|
||||
>>> Sale.workflow_trigger_validate(sale.id, 'quotation', config.context)
|
||||
>>> Sale.workflow_trigger_validate(sale.id, 'confirm', config.context)
|
||||
@@ -256,7 +270,7 @@ Sale 2 products::
|
||||
>>> sale.state
|
||||
u'processing'
|
||||
|
||||
Send 2 products::
|
||||
Send 5 products::
|
||||
|
||||
>>> ShipmentOut = Model.get('stock.shipment.out')
|
||||
>>> shipment, = sale.shipments
|
||||
@@ -276,11 +290,11 @@ Send 2 products::
|
||||
u'done'
|
||||
>>> stock_customer.reload()
|
||||
>>> (stock_customer.debit, stock_customer.credit) == \
|
||||
... (Decimal('12.00'), Decimal('0.00'))
|
||||
... (Decimal('28.00'), Decimal('0.00'))
|
||||
True
|
||||
>>> stock.reload()
|
||||
>>> (stock.debit, stock.credit) == \
|
||||
... (Decimal('20.00'), Decimal('12.00'))
|
||||
... (Decimal('50.00'), Decimal('28.00'))
|
||||
True
|
||||
|
||||
Open customer invoice::
|
||||
@@ -292,11 +306,11 @@ Open customer invoice::
|
||||
u'open'
|
||||
>>> receivable.reload()
|
||||
>>> (receivable.debit, receivable.credit) == \
|
||||
... (Decimal('20.00'), Decimal('0.00'))
|
||||
... (Decimal('50.00'), Decimal('0.00'))
|
||||
True
|
||||
>>> revenue.reload()
|
||||
>>> (revenue.debit, revenue.credit) == \
|
||||
... (Decimal('0.00'), Decimal('20.00'))
|
||||
... (Decimal('0.00'), Decimal('50.00'))
|
||||
True
|
||||
|
||||
Create an Inventory::
|
||||
@@ -310,7 +324,9 @@ Create an Inventory::
|
||||
>>> inventory.location = storage
|
||||
>>> inventory.save()
|
||||
>>> Inventory.complete_lines(inventory.id, config.context)
|
||||
>>> inventory_line, = inventory.lines
|
||||
>>> inventory_line = inventory.lines[0]
|
||||
>>> inventory_line.quantity = 1.0
|
||||
>>> inventory_line = inventory.lines[1]
|
||||
>>> inventory_line.quantity = 1.0
|
||||
>>> inventory.save()
|
||||
>>> Inventory.workflow_trigger_validate(inventory.id, 'done', config.context)
|
||||
@@ -318,9 +334,9 @@ Create an Inventory::
|
||||
u'done'
|
||||
>>> stock_lost_found.reload()
|
||||
>>> (stock_lost_found.debit, stock_lost_found.credit) == \
|
||||
... (Decimal('6.00'), Decimal('0.00'))
|
||||
... (Decimal('11.00'), Decimal('0.00'))
|
||||
True
|
||||
>>> stock.reload()
|
||||
>>> (stock.debit, stock.credit) == \
|
||||
... (Decimal('20.00'), Decimal('18.00'))
|
||||
... (Decimal('50.00'), Decimal('39.00'))
|
||||
True
|
||||
|
||||
Reference in New Issue
Block a user