From 26c0d5bef2a175764a6df6eac9a92d89f99d57d7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 10 Oct 2024 10:39:19 +0700 Subject: add clean description --- indoteknik_custom/models/product_template.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 031d1b5b..af7f98cd 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -5,6 +5,7 @@ import logging import requests import json import re +from bs4 import BeautifulSoup _logger = logging.getLogger(__name__) @@ -363,6 +364,7 @@ class ProductProduct(models.Model): specification = fields.Char(string='Specification') material = fields.Char(string='Material') qty_onhand_bandengan = fields.Float(string='Onhand BU', compute='_get_qty_onhand_bandengan') + clean_website_description = fields.Char(string='Clean Website Description', compute='_get_clean_website_description') qty_incoming_bandengan = fields.Float(string='Incoming BU', compute='_get_qty_incoming_bandengan') qty_outgoing_bandengan = fields.Float(string='Outgoing BU', compute='_get_qty_outgoing_bandengan') qty_available_bandengan = fields.Float(string='Available BU', compute='_get_qty_available_bandengan') @@ -373,6 +375,11 @@ class ProductProduct(models.Model): qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') short_spesification = fields.Char(string='Short Spesification') + def _get_clean_website_description(self): + for rec in self: + cleaned_desc = BeautifulSoup(self.website_description or '', "html.parser").get_text() + rec.clean_website_description = cleaned_desc + @api.constrains('name', 'internal_reference', 'x_manufacture') def required_public_categ_ids(self): for rec in self: -- cgit v1.2.3