Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
•
Invoicing (account)
• Discuss (mail) |
Lines of code | 758 |
Technical Name |
account_analytic_dimension_policy |
License | AGPL-3 |
Versions | 8.0 13.0 |
Analytic Dimension Policy
This module adds the Analytic Dimension Policy option on Accounts, Account Groups and Account Types.
You have the choice between 4 policies : Always, Never, Posted Moves and Optional.
If no policy has been defined on an Account the policy will be retrieved from the Account Group or Account Type.
The policy setting is optional on General Accounts and Account Groups and required on Account Types.
You can also define on Account, Account Group or Account Type for which dimensions the policy will be enforced. By default all Analytic Dimensions will be enforced.
Policies will be enforced on all account.move.line fields that have been defined as an analytic_dimension via Accounting | Invoicing -> Configuration -> Analytic Dimensions.
This is a base module for setting policies on analytical dimensions created by other modules.
Sample code to do this:
class AccountMoveLine(models.Model): _inherit = "account.move.line" department_id = fields.Many2one( comodel_name="hr.department", string="Department")
<record id="view_move_form" model="ir.ui.view"> <field name="name">account.move.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//field[@name='invoice_line_ids']/tree/field[@name='analytic_account_id']" position="after"> <field name="department_id"/> </xpath> <xpath expr="//notebook//field[@name='line_ids']/tree/field[@name='analytic_account_id']" position="after"> <field name="department_id"/> </xpath> </field> </record>
Dimensions that are not available in the standard bank reconciliation widget must also be added to the widget Qweb template.
<t t-extend="reconciliation.line.create"> <t t-jquery="tr[class='create_tax_id']" t-operation="append"> <tr class="create_department_id"> <td class="o_td_label"> <label class="o_form_label">Department</label> </td> <td class="o_td_field"></td> </tr> </t> </t>
This module is inspired by https://github.com/OCA/account-analytic/blob/13.0/account_analytic_required.
Known Issues
The current version of this module requires a restart of the Odoo server after adding Analytic Dimensions in order to enable the UI enforcement.
The current version of this module assumes that 'account.move.line' objects are created/updated via an embedded editable tree view in a 'account.move' form view.
Policy enforcement will still work if a custom module allows to update an Analytic Dimension field via e.g. a Journal Item form view, but the enforcement will be performed in this case via a pop-up window in stead of front end UI enforcement.
Please log in to comment on this module