Initial commit of account_payment_analytic for 11.0

This commit is contained in:
Jared Kipe
2019-06-25 12:41:57 -07:00
parent 605e79b606
commit a7ba9ff148
6 changed files with 115 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
********************************
Hibou - Account Payment Analytic
********************************
Need to track Analytic Accounts on payments? Look no further!
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
=======
License
=======
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/11.0/LICENSE>`_.
Copyright Hibou Corp. 2019

View File

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

View File

@@ -0,0 +1,19 @@
{
'name': 'Payment Analytic',
'version': '11.0.1.0.0',
'author': 'Hibou Corp. <hello@hibou.io>',
'category': 'Accounting',
'summary': 'Record Analytic Account on Payment',
'description': """
Record Analytic Account on Payment
""",
'website': 'https://hibou.io/',
'depends': [
'account',
],
'data': [
'views/account_payment_views.xml',
],
'installable': True,
'auto_install': False,
}

View File

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

View File

@@ -0,0 +1,29 @@
from odoo import api, fields, models
class AccountAbstractPayment(models.AbstractModel):
_inherit = 'account.abstract.payment'
account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account')
class AccountRegisterPayment(models.TransientModel):
_inherit = 'account.register.payments'
@api.multi
def _prepare_payment_vals(self, invoices):
res = super(AccountRegisterPayment, self)._prepare_payment_vals(invoices)
if self.account_analytic_id:
res['account_analytic_id'] = self.account_analytic_id.id
return res
class AccountPayment(models.Model):
_inherit = 'account.payment'
def _get_shared_move_line_vals(self, debit, credit, amount_currency, move_id, invoice_id=False):
res = super(AccountPayment, self)._get_shared_move_line_vals(debit, credit, amount_currency, move_id, invoice_id=invoice_id)
if self.account_analytic_id:
# Note the field name is not an accident! res is `account.move.line`
res['analytic_account_id'] = self.account_analytic_id.id
return res

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Register Payment Wizard -->
<record id="view_account_payment_from_invoices_inherit" model="ir.ui.view">
<field name="name">account.register.payments.wizard.inherit</field>
<field name="model">account.register.payments</field>
<field name="inherit_id" ref="account.view_account_payment_from_invoices"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount']" position="after">
<field name="account_analytic_id"/>
</xpath>
</field>
</record>
<!-- Account Payments -->
<record id="view_account_payment_form_inherit" model="ir.ui.view">
<field name="name">account.payment.form.inherit</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='amount_div']" position="after">
<field name="account_analytic_id"/>
</xpath>
</field>
</record>
<record id="view_account_payment_tree_inherit" model="ir.ui.view">
<field name="name">account.payment.tree.inherit</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount']" position="after">
<field name="account_analytic_id"/>
</xpath>
</field>
</record>
<record id="view_account_supplier_payment_tree_inherit" model="ir.ui.view">
<field name="name">account.supplier.payment.tree.inherit</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_supplier_payment_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount']" position="after">
<field name="account_analytic_id"/>
</xpath>
</field>
</record>
</odoo>