6 changed files with 33 additions and 4 deletions
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import product_product |
@ -0,0 +1,20 @@ |
|||
from odoo import models, fields, api |
|||
from datetime import datetime |
|||
|
|||
class ProductProduct(models.Model): |
|||
"""This class extends the 'product.product' model to enhance its functionality.""" |
|||
_inherit = 'product.product' |
|||
|
|||
@api.depends('product_tmpl_id.write_date') |
|||
def _compute_write_date(self): |
|||
"""Compute the write date for the product record. |
|||
This method computes the write date for each product record by taking the maximum of the current |
|||
write date of the product and the write date of the related product template. If the product's write |
|||
date is not set, the current date and time are used. If the product template's write date is not set, |
|||
a minimum datetime value (datetime.min) is used. |
|||
This ensures that the write date reflects the most recent modification date between the product and |
|||
its template.""" |
|||
for record in self: |
|||
record_write_date = record.write_date or self.env.cr.now() |
|||
tmpl_write_date = record.product_tmpl_id.write_date or datetime.min |
|||
record.write_date = max(record_write_date, tmpl_write_date) |
Loading…
Reference in new issue