Update product_cost_fifo patch with new backport from master review 321611002
This commit is contained in:
parent
85485ca6bc
commit
7870c63ff7
|
@ -1,5 +1,5 @@
|
|||
diff --git a/move.py b/move.py
|
||||
index 1d4bd63..67dbd0c 100644
|
||||
index 1d4bd63..1b41353 100644
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/move.py
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/move.py
|
||||
@@ -10,6 +10,8 @@ from trytond.model.exceptions import AccessError
|
||||
|
@ -90,6 +90,15 @@ index 1d4bd63..67dbd0c 100644
|
|||
and self.to_location.type == 'storage'
|
||||
and self.product.cost_price_method == 'fifo'):
|
||||
cost_price = self._compute_product_cost_price('in')
|
||||
@@ -136,7 +141,7 @@ class Move(metaclass=PoolMeta):
|
||||
and self.product.cost_price_method == 'fifo'):
|
||||
fifo_cost_price, cost_price = (
|
||||
self._update_fifo_out_product_cost_price())
|
||||
- if self.cost_price is None:
|
||||
+ if self.cost_price_required and self.cost_price is None:
|
||||
self.cost_price = fifo_cost_price
|
||||
return cost_price
|
||||
|
||||
diff --git a/product.py b/product.py
|
||||
index 9eaceac..aa1b06c 100644
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/product.py
|
||||
|
@ -431,7 +440,7 @@ index c7b247f..34e7d47 100644
|
|||
def origin_name(self):
|
||||
pool = Pool()
|
||||
diff --git a/move.py b/move.py
|
||||
index aafa9e8..e45cb40 100644
|
||||
index aafa9e8..4ed02e7 100644
|
||||
--- a/trytond/trytond/modules/stock/move.py
|
||||
+++ b/trytond/trytond/modules/stock/move.py
|
||||
@@ -19,7 +19,7 @@ from trytond.tools import reduce_ids
|
||||
|
@ -443,7 +452,49 @@ index aafa9e8..e45cb40 100644
|
|||
|
||||
from .exceptions import MoveOriginWarning
|
||||
|
||||
@@ -471,15 +471,13 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
@@ -251,8 +251,15 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
'invisible': Eval('state') != 'done',
|
||||
},
|
||||
depends=['state'])
|
||||
- cost_price = fields.Numeric('Cost Price', digits=price_digits,
|
||||
- readonly=True)
|
||||
+ cost_price = fields.Numeric(
|
||||
+ "Cost Price", digits=price_digits, readonly=True,
|
||||
+ states={
|
||||
+ 'invisible': ~Eval('cost_price_required'),
|
||||
+ 'required': (
|
||||
+ (Eval('state') == 'done')
|
||||
+ & Eval('cost_price_required', False)),
|
||||
+ },
|
||||
+ depends=['cost_price_required'])
|
||||
currency = fields.Many2One('currency.currency', 'Currency',
|
||||
states={
|
||||
'invisible': ~Eval('unit_price_required'),
|
||||
@@ -264,6 +271,9 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
unit_price_required = fields.Function(
|
||||
fields.Boolean('Unit Price Required'),
|
||||
'on_change_with_unit_price_required')
|
||||
+ cost_price_required = fields.Function(
|
||||
+ fields.Boolean("Cost Price Required"),
|
||||
+ 'on_change_with_cost_price_required')
|
||||
assignation_required = fields.Function(
|
||||
fields.Boolean('Assignation Required'),
|
||||
'on_change_with_assignation_required')
|
||||
@@ -401,6 +411,13 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
return True
|
||||
return False
|
||||
|
||||
+ @fields.depends('from_location', 'to_location')
|
||||
+ def on_change_with_cost_price_required(self, name=None):
|
||||
+ from_type = self.from_location.type if self.from_location else None
|
||||
+ to_type = self.to_location.type if self.to_location else None
|
||||
+ return ((from_type != 'storage' and to_type == 'storage')
|
||||
+ or (from_type == 'storage' and to_type != 'storage'))
|
||||
+
|
||||
@fields.depends('from_location')
|
||||
def on_change_with_assignation_required(self, name=None):
|
||||
if self.from_location:
|
||||
@@ -471,15 +488,13 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
def search_rec_name(cls, name, clause):
|
||||
return [('product.rec_name',) + tuple(clause[1:])]
|
||||
|
||||
|
@ -460,7 +511,7 @@ index aafa9e8..e45cb40 100644
|
|||
|
||||
if direction == 'in':
|
||||
quantity = self.quantity
|
||||
@@ -489,13 +487,7 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
@@ -489,13 +504,7 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
|
||||
qty = Decimal(str(qty))
|
||||
product_qty = Decimal(str(self.product.quantity))
|
||||
|
@ -475,7 +526,7 @@ index aafa9e8..e45cb40 100644
|
|||
cost_price = self.product.get_multivalue(
|
||||
'cost_price', **self._cost_price_pattern)
|
||||
if product_qty + qty > 0 and product_qty >= 0:
|
||||
@@ -507,9 +499,7 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
@@ -507,9 +516,7 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
elif direction == 'out':
|
||||
new_cost_price = cost_price
|
||||
|
||||
|
@ -486,7 +537,16 @@ index aafa9e8..e45cb40 100644
|
|||
|
||||
@staticmethod
|
||||
def _get_internal_quantity(quantity, uom, product):
|
||||
@@ -609,6 +599,27 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
@@ -583,7 +590,7 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
cost_values.append(
|
||||
(move.product, cost_price,
|
||||
move._cost_price_pattern))
|
||||
- if move.cost_price is None:
|
||||
+ if move.cost_price_required and move.cost_price is None:
|
||||
if cost_price is None:
|
||||
cost_price = move.product.get_multivalue(
|
||||
'cost_price', **move._cost_price_pattern)
|
||||
@@ -609,6 +616,27 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
('company', self.company.id),
|
||||
)
|
||||
|
2
series
2
series
|
@ -77,5 +77,5 @@ lazy_loading.diff # [trytond] lazy loading of id, create_date, write_date on man
|
|||
cost_price_in_productions_without_inputs.diff # [production]
|
||||
#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:
|
||||
issues_321471002_317771007_327491003_325801002.diff # [product_cost_fifo, sale, stock] take care on inventory moves
|
||||
issues_321471002_317771007_327491003_325801002_321611002.diff # [product_cost_fifo, sale, stock] take care on inventory moves
|
||||
issue7280.diff # [account_invoice_stock] + [account_stock_landed_cost] Update unit price of stock moves based on posted invoice lines
|
||||
|
|
Loading…
Reference in New Issue