From dd225145b18af8002842adc8339d1b0d32e5334f Mon Sep 17 00:00:00 2001 From: Felipe Date: Wed, 13 Jun 2018 14:22:38 -0300 Subject: [PATCH] Add Html description field to sale order line --- html_description_field/__init__.py | 5 +++++ html_description_field/__manifest__.py | 24 +++++++++++++++++++++ html_description_field/models/__init__.py | 5 +++++ html_description_field/models/sale_order.py | 20 +++++++++++++++++ html_description_field/views/sale_order.xml | 24 +++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 html_description_field/__init__.py create mode 100644 html_description_field/__manifest__.py create mode 100644 html_description_field/models/__init__.py create mode 100644 html_description_field/models/sale_order.py create mode 100644 html_description_field/views/sale_order.xml diff --git a/html_description_field/__init__.py b/html_description_field/__init__.py new file mode 100644 index 00000000..333a6b3d --- /dev/null +++ b/html_description_field/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2018 Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/html_description_field/__manifest__.py b/html_description_field/__manifest__.py new file mode 100644 index 00000000..2f217866 --- /dev/null +++ b/html_description_field/__manifest__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# © 2018 Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +{ # pylint: disable=C8101,C8103 + 'name': "Descrição Cotação Html", + + 'summary': """""", + + 'description': """""", + 'author': "Trustcode", + 'website': "http://www.trustcode.com.br", + 'category': 'Uncategorized', + 'version': '11.0.1.0.0', + 'license': 'AGPL-3', + 'contributors': [ + 'Felipe Paloschi ', + ], + 'depends': ['br_sale'], + 'data': [ + 'views/sale_order.xml', + ], +} diff --git a/html_description_field/models/__init__.py b/html_description_field/models/__init__.py new file mode 100644 index 00000000..f3a82095 --- /dev/null +++ b/html_description_field/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2018 Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import sale_order diff --git a/html_description_field/models/sale_order.py b/html_description_field/models/sale_order.py new file mode 100644 index 00000000..fdd3bb1e --- /dev/null +++ b/html_description_field/models/sale_order.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 2018 Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields, api +from lxml.html import document_fromstring + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + quotation_description = fields.Html(string="Descrição (html)") + + @api.onchange('quotation_description') + def onchange_description(self): + self.name = self.clean_html_text(self.quotation_description) + + def clean_html_text(self, string): + doc = document_fromstring(string.replace('

', '\r\n')) + return doc.text_content() diff --git a/html_description_field/views/sale_order.xml b/html_description_field/views/sale_order.xml new file mode 100644 index 00000000..27465c9c --- /dev/null +++ b/html_description_field/views/sale_order.xml @@ -0,0 +1,24 @@ + + + + + view.order.form.inherit.html.description + sale.order + + + + + + + + + 1 + + + + + + +