How To generate manual invoice.
If You want to create manul invoice then folllow below step.
1) Create Py file for account invoice as below.
from openerp import models, fields, api, _
class account_invoice(models.Model):
_inherit = "account.invoice"
@api.multi
def write(self, vals):
if vals.get('number'):
vals['number'] = vals['number']
elif self.number:
vals['number'] = self.number
return super(account_invoice, self).write(vals)
_defaults = {
'number': False
}
2) Change in invoice form view as below.
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="inherit_view_account_invoice_for_number">
<field name="name">inherit.view.account.invoice.for.number</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='number']" position="replace">
<field name="number" attrs="{'readonly':[('state','!=','draft')]}" required="1"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="inherit_invoice_supplier_form">
<field name="name">inherit.view.account.invoice.for.supplier.number</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='number']" position="replace">
<field name="number" attrs="{'readonly':[('state','!=','draft')]}" required="1"/>
</xpath>
</field>
</record>
</data>
</openerp>
Version - 9 :
class AccountInvoice(models.Model):
_inherit = "account.invoice"
temp_number = fields.Char('Temp Number', copy=False)
@api.multi
def write(self, vals):
if vals.get('temp_number'):
vals['number'] = vals.get('temp_number')
if self.temp_number:
vals['number'] = self.temp_number
return super(AccountInvoice, self).write(vals)
<record id="manual_invoice_form_inherit" model="ir.ui.view">
<field name="name">manual.invoice.form.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//form/sheet/h1/field[@name='number']" position="replace">
<field name="number"/>
</xpath>
<xpath expr="//form/sheet/h1/field[@name='number']" position="after">
<field name="temp_number"/>
</xpath>
</data>
</field>
</record>
If You want to create manul invoice then folllow below step.
1) Create Py file for account invoice as below.
from openerp import models, fields, api, _
class account_invoice(models.Model):
_inherit = "account.invoice"
@api.multi
def write(self, vals):
if vals.get('number'):
vals['number'] = vals['number']
elif self.number:
vals['number'] = self.number
return super(account_invoice, self).write(vals)
_defaults = {
'number': False
}
2) Change in invoice form view as below.
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="inherit_view_account_invoice_for_number">
<field name="name">inherit.view.account.invoice.for.number</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='number']" position="replace">
<field name="number" attrs="{'readonly':[('state','!=','draft')]}" required="1"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="inherit_invoice_supplier_form">
<field name="name">inherit.view.account.invoice.for.supplier.number</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='number']" position="replace">
<field name="number" attrs="{'readonly':[('state','!=','draft')]}" required="1"/>
</xpath>
</field>
</record>
</data>
</openerp>
Version - 9 :
class AccountInvoice(models.Model):
_inherit = "account.invoice"
temp_number = fields.Char('Temp Number', copy=False)
@api.multi
def write(self, vals):
if vals.get('temp_number'):
vals['number'] = vals.get('temp_number')
if self.temp_number:
vals['number'] = self.temp_number
return super(AccountInvoice, self).write(vals)
<record id="manual_invoice_form_inherit" model="ir.ui.view">
<field name="name">manual.invoice.form.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//form/sheet/h1/field[@name='number']" position="replace">
<field name="number"/>
</xpath>
<xpath expr="//form/sheet/h1/field[@name='number']" position="after">
<field name="temp_number"/>
</xpath>
</data>
</field>
</record>
No comments:
Post a Comment