add contexual field to invoice form and copy value from sales if available
This commit is contained in:
@@ -2,11 +2,12 @@
|
|||||||
'name': 'Sale Order Contextual Note',
|
'name': 'Sale Order Contextual Note',
|
||||||
'version': '16.0.1.0.0',
|
'version': '16.0.1.0.0',
|
||||||
'category': 'Sales',
|
'category': 'Sales',
|
||||||
'summary': 'Adds a contextual note field to sale orders',
|
'summary': 'Adds a contextual note field to sale orders and invoices',
|
||||||
'author': 'DomusLavila',
|
'author': 'DomusLavila',
|
||||||
'depends': ['sale_management'],
|
'depends': ['sale_management', 'account'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/sale_order_contextual_view.xml',
|
'views/sale_order_contextual_view.xml',
|
||||||
|
'views/account_move_form.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
from . import sale_order_contextual
|
from . import sale_order_contextual
|
||||||
|
from . import account_move
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class AccountMoveContextual(models.Model):
|
||||||
|
_inherit = 'account.move'
|
||||||
|
|
||||||
|
contextual_note = fields.Text(
|
||||||
|
string='Contextuele opmerking',
|
||||||
|
)
|
||||||
@@ -7,3 +7,9 @@ class SaleOrderContextual(models.Model):
|
|||||||
contextual_note = fields.Text(
|
contextual_note = fields.Text(
|
||||||
string='Contextuele opmerking',
|
string='Contextuele opmerking',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _prepare_invoice(self):
|
||||||
|
vals = super()._prepare_invoice()
|
||||||
|
if self.contextual_note:
|
||||||
|
vals['contextual_note'] = self.contextual_note
|
||||||
|
return vals
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="account_move_contextual_note_form" model="ir.ui.view">
|
||||||
|
<field name="name">account.move.contextual.note.form</field>
|
||||||
|
<field name="model">account.move</field>
|
||||||
|
<field name="inherit_id" ref="account.view_move_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//notebook" position="before">
|
||||||
|
<separator string="Contextual"/>
|
||||||
|
<group>
|
||||||
|
<field name="contextual_note" string="Note" colspan="2"/>
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -5,10 +5,11 @@
|
|||||||
<field name="model">sale.order</field>
|
<field name="model">sale.order</field>
|
||||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//notebook" position="inside">
|
<xpath expr="//group[@name='sale_header']" position="after">
|
||||||
<page string="Contextual" name="contextual_note_page">
|
<separator string="Contextual"/>
|
||||||
<field name="contextual_note" nolabel="1"/>
|
<group>
|
||||||
</page>
|
<field name="contextual_note" string="Note" colspan="2"/>
|
||||||
|
</group>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user