add issue9274
This commit is contained in:
parent
812e8b8e47
commit
2f1636fb93
|
@ -0,0 +1,106 @@
|
|||
diff --git a/move.py b/move.py
|
||||
index c7c41ca..266df58 100644
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/move.py
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/move.py
|
||||
@@ -81,13 +81,15 @@ class Move(metaclass=PoolMeta):
|
||||
to_save = []
|
||||
for move, move_qty in fifo_moves:
|
||||
consumed_qty += move_qty
|
||||
-
|
||||
- with Transaction().set_context(date=move.effective_date):
|
||||
- move_unit_price = Currency.compute(
|
||||
- move.currency, move.unit_price,
|
||||
- self.company.currency, round=False)
|
||||
- move_unit_price = Uom.compute_price(move.uom, move_unit_price,
|
||||
- move.product.default_uom)
|
||||
+ if move.unit_price is not None:
|
||||
+ with Transaction().set_context(date=move.effective_date):
|
||||
+ move_unit_price = Currency.compute(
|
||||
+ move.currency, move.unit_price,
|
||||
+ self.company.currency, round=False)
|
||||
+ move_unit_price = Uom.compute_price(move.uom, move_unit_price,
|
||||
+ move.product.default_uom)
|
||||
+ else:
|
||||
+ move_unit_price = move.cost_price or 0
|
||||
cost_price += move_unit_price * Decimal(str(move_qty))
|
||||
|
||||
move_qty = Uom.compute_qty(self.product.default_uom, move_qty,
|
||||
diff --git a/product.py b/product.py
|
||||
index 9eaceac..cc6e982 100644
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/product.py
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/product.py
|
||||
@@ -31,7 +31,7 @@ class Product(metaclass=PoolMeta):
|
||||
domain = [
|
||||
('product', '=', self.id),
|
||||
self._domain_moves_cost(),
|
||||
- ('from_location.type', 'in', ['supplier', 'production']),
|
||||
+ ('from_location.type', '!=', 'storage'),
|
||||
('to_location.type', '=', 'storage'),
|
||||
]
|
||||
if not date:
|
||||
@@ -135,11 +135,10 @@ class Product(metaclass=PoolMeta):
|
||||
quantity = Decimal(str(quantity))
|
||||
|
||||
def in_move(move):
|
||||
- return (move.from_location.type in ['supplier', 'production']
|
||||
- or move.to_location.type == 'supplier')
|
||||
+ return move.to_location.type == 'storage'
|
||||
|
||||
def out_move(move):
|
||||
- return not in_move(move)
|
||||
+ return move.from_location.type == 'storage'
|
||||
|
||||
def compute_fifo_cost_price(quantity, date):
|
||||
fifo_moves = self.get_fifo_move(
|
||||
@@ -150,12 +149,15 @@ class Product(metaclass=PoolMeta):
|
||||
consumed_qty = 0
|
||||
for move, move_qty in fifo_moves:
|
||||
consumed_qty += move_qty
|
||||
- with Transaction().set_context(date=move.effective_date):
|
||||
- unit_price = Currency.compute(
|
||||
- move.currency, move.unit_price,
|
||||
- move.company.currency, round=False)
|
||||
- unit_price = Uom.compute_price(
|
||||
- move.uom, unit_price, move.product.default_uom)
|
||||
+ if move.unit_price is not None:
|
||||
+ with Transaction().set_context(date=move.effective_date):
|
||||
+ unit_price = Currency.compute(
|
||||
+ move.currency, move.unit_price,
|
||||
+ move.company.currency, round=False)
|
||||
+ unit_price = Uom.compute_price(
|
||||
+ move.uom, unit_price, move.product.default_uom)
|
||||
+ else:
|
||||
+ unit_price = move.cost_price or 0
|
||||
cost_price += unit_price * Decimal(str(move_qty))
|
||||
if consumed_qty:
|
||||
return (cost_price / Decimal(str(consumed_qty))).quantize(
|
||||
@@ -202,12 +204,15 @@ class Product(metaclass=PoolMeta):
|
||||
if move.from_location.type == 'storage':
|
||||
qty *= -1
|
||||
if in_move(move):
|
||||
- with Transaction().set_context(date=move.effective_date):
|
||||
- unit_price = Currency.compute(
|
||||
- move.currency, move.unit_price,
|
||||
- move.company.currency, round=False)
|
||||
- unit_price = Uom.compute_price(
|
||||
- move.uom, unit_price, self.default_uom)
|
||||
+ if move.unit_price is not None:
|
||||
+ with Transaction().set_context(date=move.effective_date):
|
||||
+ unit_price = Currency.compute(
|
||||
+ move.currency, move.unit_price,
|
||||
+ move.company.currency, round=False)
|
||||
+ unit_price = Uom.compute_price(
|
||||
+ move.uom, unit_price, self.default_uom)
|
||||
+ else:
|
||||
+ unit_price = cost_price
|
||||
if quantity + qty > 0 and quantity >= 0:
|
||||
cost_price = (
|
||||
(cost_price * quantity) + (unit_price * qty)
|
||||
@@ -216,7 +221,7 @@ class Product(metaclass=PoolMeta):
|
||||
cost_price = unit_price
|
||||
current_cost_price = cost_price.quantize(
|
||||
Decimal(str(10.0 ** -digits[1])))
|
||||
- else:
|
||||
+ elif out_move(move):
|
||||
current_out_qty += -qty
|
||||
quantity += qty
|
3
series
3
series
|
@ -75,4 +75,5 @@ stock_supply.diff # [stock_supply] Force rounding in the quantity of internal sh
|
|||
issue9103.diff # [trytond] User-defined reports for custom template extensions
|
||||
lazy_loading.diff # [trytond] lazy loading of id, create_date, write_date on many2one
|
||||
cost_price_in_productions_without_inputs.diff # [production]
|
||||
fifo_cost_price_formula.diff # [product_cost_fio] change formula to avoid minus zero cost_price
|
||||
#fifo_cost_price_formula.diff # [product_cost_fio] change formula to avoid minus zero cost_price
|
||||
#issue9274.diff # [product_cost_fifo] take care on inventory moves:
|
||||
|
|
Loading…
Reference in New Issue