|
|
"""
First, the purpose of this computation is to update a product's
write_date whenever its template's write_date is updated. Indeed,
when a template's image is modified, updating its products'
write_date will invalidate the browser's cache for the products'
image, which may be the same as the template's. This guarantees UI
consistency.
Second, the field 'write_date' is automatically updated by the
framework when the product is modified. The recomputation of the
field supplements that behavior to keep the product's write_date
up-to-date with its template's write_date.
Third, the framework normally prevents us from updating write_date
because it is a "magic" field. However, the assignment inside the
compute method is not subject to this restriction. It therefore
works as intended :-)
"""
for record in self:
record.write_date = max(record.write_date or self.env.cr.now(), record.product_tmpl_id.write_date)
|
|