mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of account_payment_analytic for 11.0
This commit is contained in:
16
account_payment_analytic/README.rst
Normal file
16
account_payment_analytic/README.rst
Normal 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
|
||||||
1
account_payment_analytic/__init__.py
Normal file
1
account_payment_analytic/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
19
account_payment_analytic/__manifest__.py
Normal file
19
account_payment_analytic/__manifest__.py
Normal 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,
|
||||||
|
}
|
||||||
1
account_payment_analytic/models/__init__.py
Normal file
1
account_payment_analytic/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import account_payment
|
||||||
29
account_payment_analytic/models/account_payment.py
Normal file
29
account_payment_analytic/models/account_payment.py
Normal 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
|
||||||
49
account_payment_analytic/views/account_payment_views.xml
Normal file
49
account_payment_analytic/views/account_payment_views.xml
Normal 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>
|
||||||
Reference in New Issue
Block a user