Fall 5559: Textbausteine - AN / AB / RE

develop
Ahmed Aly 2018-06-27 16:13:31 +02:00
parent 58a89396ad
commit 70d7238d57
9 changed files with 94 additions and 0 deletions

View File

@ -1 +1,2 @@
from . import models
from . import wizards

View File

@ -17,6 +17,7 @@
'data': [
'views/account_invoice_view.xml',
'views/sale_order_view.xml',
'wizards/wizard_add_line_comment.xml',
],
'installable': True,
'auto_install': False,

View File

@ -15,3 +15,14 @@ class AccountInvoice(models.Model):
comment = self.comment_line_template_id
if comment:
self.note_line = comment.get_value(self.partner_id.id)
class AccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"
@api.multi
def add_line_comment(self):
self.ensure_one()
action = self.env.ref('dp_line_comment_template.action_wizard_line_comment').read()[0]
action['context'] = str({"model_name": 'account.invoice.line', "model_id": self.id})
return action

View File

@ -24,3 +24,14 @@ class SaleOrder(models.Model):
'note_line': self.note_line,
})
return values
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
@api.multi
def add_line_comment(self):
self.ensure_one()
action = self.env.ref('dp_line_comment_template.action_wizard_line_comment').read()[0]
action['context'] = str({"model_name": 'sale.order.line', "model_id": self.id})
return action

View File

@ -16,6 +16,10 @@
<field name="note_line" nolabel="1" colspan="2"/>
</group>
</xpath>
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='name']" position="after">
<!--<label for="add_line_comment">TB</label>-->
<button name="add_line_comment" string="Textbaustein" icon="fa-plus-square" type="object"/>
</xpath>
</field>
</record>

View File

@ -16,6 +16,10 @@
<field name="note_line" nolabel="1" colspan="2"/>
</group>
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
<!--<label for="add_line_comment">TB</label>-->
<button name="add_line_comment" string="Textbaustein" icon="fa-plus-square" type="object"/>
</xpath>
</field>
</record>

View File

@ -0,0 +1 @@
from . import wizard_add_line_comment

View File

@ -0,0 +1,28 @@
# Copyright 2018-Today datenpol gmbh (<http://www.datenpol.at>)
# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses).
import re
from odoo import fields, models, api
class AddLineComment(models.TransientModel):
_name = 'wizard.add_line_comment'
_description = 'Zeilentextbaustein hinzufügen'
comment_line_template_id = fields.Many2one('base.comment.template', string='Line Comment Template')
note_line = fields.Html('Line Comment')
@api.onchange('comment_line_template_id')
def _onchange_note_line(self):
comment = self.comment_line_template_id
if comment:
self.note_line = comment.get_value(self.env[self.env.context.get('model_name')].browse([self.env.context.get('model_id')]).partner_id.id)
def add_line_comment(self):
self.ensure_one()
regex = re.compile(r"(?i)<[^>]*>", re.IGNORECASE)
name = regex.sub('', self.note_line)
self.env[self.env.context.get('model_name')].browse([self.env.context.get('model_id')]).name += "\n" + name
return {'type': 'ir.actions.act_window_close'}

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>)
License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). -->
<odoo>
<record id="wizard_add_line_comment_form_view" model="ir.ui.view">
<field name="name">wizard_add_line_comment_form_view</field>
<field name="model">wizard.add_line_comment</field>
<field name="arch" type="xml">
<form string="Zeilentextbaustein hinzufügen">
<group>
<field name="comment_line_template_id"/>
<field name="note_line"/>
</group>
<footer>
<button name="add_line_comment" string="Zeilentextbaustein hinzufügen" class="btn-primary" type="object"/>
<button string="Abbrechen" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_wizard_line_comment" model="ir.actions.act_window">
<field name="name">Zeilentextbaustein hinzufügen</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.add_line_comment</field>
<field name="target">new</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
</odoo>