From To
This commit is contained in:
@@ -575,6 +575,7 @@ class Purchase(metaclass=PoolMeta):
|
|||||||
if not line_commands:
|
if not line_commands:
|
||||||
return
|
return
|
||||||
Line = Pool().get('purchase.line')
|
Line = Pool().get('purchase.line')
|
||||||
|
pending_values = {}
|
||||||
for command in line_commands:
|
for command in line_commands:
|
||||||
action = command[0]
|
action = command[0]
|
||||||
if action == 'create':
|
if action == 'create':
|
||||||
@@ -583,11 +584,15 @@ class Purchase(metaclass=PoolMeta):
|
|||||||
elif action == 'write':
|
elif action == 'write':
|
||||||
actions = iter(command[1:])
|
actions = iter(command[1:])
|
||||||
for line_ids, line_values in zip(actions, actions):
|
for line_ids, line_values in zip(actions, actions):
|
||||||
lines = Line.browse(line_ids)
|
for line_id in line_ids:
|
||||||
Line._check_delivery_period_values(lines, line_values)
|
pending_values.setdefault(line_id, {}).update(
|
||||||
|
line_values)
|
||||||
elif action == 'add':
|
elif action == 'add':
|
||||||
lines = Line.browse(command[1])
|
for line_id in command[1]:
|
||||||
Line._check_delivery_period_values(lines)
|
pending_values.setdefault(line_id, {})
|
||||||
|
for line_id, line_values in pending_values.items():
|
||||||
|
Line._check_delivery_period_values(
|
||||||
|
Line.browse([line_id]), line_values)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write(cls, *args):
|
def write(cls, *args):
|
||||||
|
|||||||
@@ -1003,6 +1003,7 @@ class Sale(metaclass=PoolMeta):
|
|||||||
if not line_commands:
|
if not line_commands:
|
||||||
return
|
return
|
||||||
Line = Pool().get('sale.line')
|
Line = Pool().get('sale.line')
|
||||||
|
pending_values = {}
|
||||||
for command in line_commands:
|
for command in line_commands:
|
||||||
action = command[0]
|
action = command[0]
|
||||||
if action == 'create':
|
if action == 'create':
|
||||||
@@ -1011,11 +1012,15 @@ class Sale(metaclass=PoolMeta):
|
|||||||
elif action == 'write':
|
elif action == 'write':
|
||||||
actions = iter(command[1:])
|
actions = iter(command[1:])
|
||||||
for line_ids, line_values in zip(actions, actions):
|
for line_ids, line_values in zip(actions, actions):
|
||||||
lines = Line.browse(line_ids)
|
for line_id in line_ids:
|
||||||
Line._check_delivery_period_values(lines, line_values)
|
pending_values.setdefault(line_id, {}).update(
|
||||||
|
line_values)
|
||||||
elif action == 'add':
|
elif action == 'add':
|
||||||
lines = Line.browse(command[1])
|
for line_id in command[1]:
|
||||||
Line._check_delivery_period_values(lines)
|
pending_values.setdefault(line_id, {})
|
||||||
|
for line_id, line_values in pending_values.items():
|
||||||
|
Line._check_delivery_period_values(
|
||||||
|
Line.browse([line_id]), line_values)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write(cls, *args):
|
def write(cls, *args):
|
||||||
|
|||||||
@@ -629,6 +629,26 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
'lines': [['add', [564]]],
|
'lines': [['add', [564]]],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def test_parent_write_checks_final_embedded_line_values(self):
|
||||||
|
'parent writes validate final line values after add and write commands'
|
||||||
|
Sale = Pool().get('sale.sale')
|
||||||
|
line = Mock(
|
||||||
|
from_del=datetime.date(2026, 4, 21),
|
||||||
|
to_del=datetime.date(2026, 4, 10),
|
||||||
|
)
|
||||||
|
|
||||||
|
with patch('trytond.modules.purchase_trade.sale.Pool') as SalePool:
|
||||||
|
SalePool.return_value.get.return_value = Mock(
|
||||||
|
browse=Mock(return_value=[line]))
|
||||||
|
Sale._check_lines_delivery_period_values({
|
||||||
|
'lines': [
|
||||||
|
['add', [564]],
|
||||||
|
['write', [564], {
|
||||||
|
'from_del': datetime.date(2026, 4, 6),
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
def test_pricing_eod_uses_weighted_average_for_manual_rows(self):
|
def test_pricing_eod_uses_weighted_average_for_manual_rows(self):
|
||||||
'manual pricing eod uses the weighted average of fixed and unfixed legs'
|
'manual pricing eod uses the weighted average of fixed and unfixed legs'
|
||||||
Pricing = Pool().get('pricing.pricing')
|
Pricing = Pool().get('pricing.pricing')
|
||||||
|
|||||||
Reference in New Issue
Block a user