addons14/sale_last_price_info/models/product.py
def _compute_last_sale(self):
        """ Get last sale price, last sale date and last customer """
        so_line_obj = self.env["sale.order.line"]
        for product in self:
            line = so_line_obj.search(
                [("product_id", "=", product.id), ("state", "in", ["sale", "done"])],
                limit=1,
                order="date_order_sale_last_price_info desc",
            )
            product.last_sale_date = fields.Datetime.to_string(
                line.date_order_sale_last_price_info
            )
            product.last_sale_price = line.price_unit
            product.last_customer_id = line.order_id.partner_id
 Get last sale price, last sale date and last customer 
Get last sale price, last sale date and last customer
Get last sale price last sale date and last customer
def _compute_last_sale(self):
        so_line_obj = self.env["sale.order.line"]
        for product in self:
            line = so_line_obj.search(
                [("product_id", "=", product.id), ("state", "in", ["sale", "done"])],
                limit=1,
                order="date_order_sale_last_price_info desc",
            )
            product.last_sale_date = fields.Datetime.to_string(
                line.date_order_sale_last_price_info
            )
            product.last_sale_price = line.price_unit
            product.last_customer_id = line.order_id.partner_id
def _compute_last_sale ( self ) : so_line_obj = self . env [ "sale.order.line" ] for product in self : line = so_line_obj . search ( [ ( "product_id" , "=" , product . id ) , ( "state" , "in" , [ "sale" , "done" ] ) ] , limit = 1 , order = "date_order_sale_last_price_info desc" , ) product . last_sale_date = fields . Datetime . to_string ( line . date_order_sale_last_price_info ) product . last_sale_price = line . price_unit product . last_customer_id = line . order_id . partner_id
Get last sale price, last sale date and last customer
Get last sale price last sale date and last customer
""" Get last sale price, last sale date and last customer """
self