-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[11.0][ADD]account_invoice_line_default
- Loading branch information
1 parent
b92355b
commit def2ad5
Showing
11 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
:target: https://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
===================== | ||
Invoice Line defaults | ||
===================== | ||
|
||
This module facilitates the encoding of Invoices lines: | ||
|
||
- The 'Account' field is initialised from the default invoice account fields on the partner records. | ||
- The 'Reference/Description' field is moved to the main page of the Supplier Invoice form | ||
and the Invoice Line descriptions are initialised from the Invoice Description field. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2009-2019 Noviat. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Account Invoice Line Defaults', | ||
'version': '11.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'Noviat', | ||
'website': 'http://www.noviat.com', | ||
'category': 'Accounting & Finance', | ||
'complexity': 'normal', | ||
'summary': 'Account Invoice Line Defaults', | ||
'data': [ | ||
'views/account_invoice.xml', | ||
'views/res_partner.xml', | ||
], | ||
'depends': [ | ||
'account', | ||
], | ||
'installable': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_line_default | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: [email protected]\n" | ||
"POT-Creation-Date: 2011-09-01 16:38:44.068000\n" | ||
"PO-Revision-Date: 2018-01-05 10:00:00.068000\n" | ||
"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Language: fr\n" | ||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
||
#. module: account_invoice_line_default | ||
#: model:ir.model.fields,field_description:account_invoice_line_default.field_res_partner_property_in_inv_account_id | ||
msgid "Incoming Invoice Account" | ||
msgstr "Compte factures fournisseurs" | ||
|
||
#. module: account_invoice_line_default | ||
#: model:ir.model.fields,field_description:account_invoice_line_default.field_res_partner_property_out_inv_account_id | ||
msgid "Outgoing Invoice Account" | ||
msgstr "Compte factures clients" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_line_default | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: [email protected]\n" | ||
"POT-Creation-Date: 2011-09-01 16:38:44.039000\n" | ||
"PO-Revision-Date: 2018-01-05 10:00:00.039000\n" | ||
"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Language: nl\n" | ||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
||
#. module: account_invoice_line_default | ||
#: model:ir.model.fields,field_description:account_invoice_line_default.field_res_partner_property_in_inv_account_id | ||
msgid "Incoming Invoice Account" | ||
msgstr "Rekening Inkoopfacturen" | ||
|
||
#. module: account_invoice_line_default | ||
#: model:ir.model.fields,field_description:account_invoice_line_default.field_res_partner_property_out_inv_account_id | ||
msgid "Outgoing Invoice Account" | ||
msgstr "Rekening Verkoopfacturen" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_invoice | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright 2009-2019 Noviat. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from lxml import etree | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = 'account.invoice' | ||
|
||
@api.model | ||
def fields_view_get(self, view_id=None, view_type=False, | ||
toolbar=False, submenu=False): | ||
res = super(AccountInvoice, self).fields_view_get( | ||
view_id=view_id, view_type=view_type, | ||
toolbar=toolbar, submenu=submenu) | ||
context = self._context | ||
if not context.get('account_invoice_line_default'): | ||
if view_type == 'form': | ||
view = etree.XML(res['arch']) | ||
inv_line_ids = view.xpath("//field[@name='invoice_line_ids']") | ||
extra_ctx = ( | ||
"'account_invoice_line_default': 1, " | ||
"'inv_name': name, " | ||
"'inv_partner_id': partner_id") | ||
for el in inv_line_ids: | ||
ctx = el.get('context') | ||
if ctx: | ||
ctx_strip = ctx.rstrip("}").strip().rstrip(",") | ||
ctx = ctx_strip + ", " + extra_ctx + "}" | ||
else: | ||
ctx = "{" + extra_ctx + "}" | ||
el.set('context', str(ctx)) | ||
res['arch'] = etree.tostring(view) | ||
return res | ||
|
||
|
||
class AccountInvoiceLine(models.Model): | ||
_inherit = 'account.invoice.line' | ||
|
||
name = fields.Text( | ||
default=lambda self: self._default_name()) | ||
account_id = fields.Many2one( | ||
default=lambda self: self._default_account()) | ||
|
||
@api.model | ||
def _default_name(self): | ||
return self._context.get('account_invoice_line_default') \ | ||
and self._context.get('inv_name') | ||
|
||
@api.model | ||
def _default_account(self): | ||
ctx = self._context | ||
account = None | ||
if ctx.get('account_invoice_line_default'): | ||
if ctx.get('inv_partner_id'): | ||
partner = self.env['res.partner'].browse( | ||
ctx['inv_partner_id']) | ||
partner = partner.commercial_partner_id | ||
if ctx.get('type') in ['in_invoice', 'in_refund']: | ||
account = partner.property_in_inv_account_id | ||
else: | ||
account = partner.property_out_inv_account_id | ||
return account or super(AccountInvoiceLine, self)._default_account() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2009-2019 Noviat. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = 'res.partner' | ||
|
||
property_in_inv_account_id = fields.Many2one( | ||
comodel_name='account.account', | ||
string='Incoming Invoice Account', | ||
company_dependent=True, | ||
domain=[('deprecated', '=', False)], | ||
oldname="property_in_inv_acc", | ||
help="Default Account on incoming Invoices.") | ||
property_out_inv_account_id = fields.Many2one( | ||
comodel_name='account.account', | ||
string='Outgoing Invoice Account', | ||
company_dependent=True, | ||
domain=[('deprecated', '=', False)], | ||
oldname="property_out_inv_acc", | ||
help="Default Account on outgoing Invoices.") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="invoice_supplier_form" model="ir.ui.view"> | ||
<field name="name">account.invoice.supplier.form.inherit</field> | ||
<field name="model">account.invoice</field> | ||
<field name="inherit_id" ref="account.invoice_supplier_form"/> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<field name="date_due" position="after"> | ||
<field name="name" string="Description"/> | ||
</field> | ||
<xpath expr="//notebook/page[@name='other_info']//field[@name='name']" position="replace"/> | ||
</data> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="view_partner_property_form" model="ir.ui.view"> | ||
<field name="name">res.partner.property.form.inherit</field> | ||
<field name="model">res.partner</field> | ||
<field name="inherit_id" ref="account.view_partner_property_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="property_account_receivable_id" position="after"> | ||
<field name="property_out_inv_account_id"/> | ||
</field> | ||
<field name="property_account_payable_id" position="after"> | ||
<field name="property_in_inv_account_id"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |