[FIX] stock: virtual_available and to_date

When updating the schedule date of a picking, the schedule dates of its
stock moves are updated. However, their date field isn't. According to
the help of the date field, its value should be equal to the
expected_date field until the move is done. That's probably why the
virtal_available computed field only take care of the date field its
`to_date` domain.

As this is a long standing issue, it seems safer to adapt the computed
field's domain instead of fixing the date should be equal to expected
date until done thingy.

task-2003485
This commit is contained in:
Simon Lejeune
2019-08-13 07:54:38 +00:00
committed by William Henrotin
parent d32f21cbc8
commit c2c9d6d143
+22 -4
View File
@@ -125,11 +125,29 @@ class Product(models.Model):
domain_move_in_done = list(domain_move_in)
domain_move_out_done = list(domain_move_out)
if from_date:
domain_move_in += [('date', '>=', from_date)]
domain_move_out += [('date', '>=', from_date)]
date_date_expected_domain_from = [
'|',
'&',
('state', '=', 'done'),
('date', '<=', from_date),
'&',
('state', '!=', 'done'),
('date_expected', '<=', from_date),
]
domain_move_in += date_date_expected_domain_from
domain_move_out += date_date_expected_domain_from
if to_date:
domain_move_in += [('date', '<=', to_date)]
domain_move_out += [('date', '<=', to_date)]
date_date_expected_domain_to = [
'|',
'&',
('state', '=', 'done'),
('date', '<=', to_date),
'&',
('state', '!=', 'done'),
('date_expected', '<=', to_date),
]
domain_move_in += date_date_expected_domain_to
domain_move_out += date_date_expected_domain_to
Move = self.env['stock.move']
Quant = self.env['stock.quant']