Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions html_description_field/__init__.py
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions html_description_field/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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 <paloschi.eca@gmail.com>',
],
'depends': ['br_sale'],
'data': [
'views/sale_order.xml',
],
}
5 changes: 5 additions & 0 deletions html_description_field/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions html_description_field/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -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('</p>', '\r\n'))
return doc.text_content()
24 changes: 24 additions & 0 deletions html_description_field/views/sale_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_order_form_inherit_html_description" model="ir.ui.view">
<field name="name">view.order.form.inherit.html.description</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/form/field[@name='name']" position="after">
<label for="quotation_description" />
<field name="quotation_description" />
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
<field name="quotation_description" />
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='order_line']/tree" position="attributes">
<attribute name="editable"></attribute>
</xpath>
</field>
</record>
</odoo>