Files
odoo_source/addons/analytic/views/analytic_plan_views.xml
T
williamandh4818 dc696c8ed4 [IMP] analytic: allow cross analytics
Purpose
=======

Make it possible to compare analytic values between plans by inputting
up to one account per plan on each line.
For instance, if we have 2 plans: "Country" and "Product Type", with the
following accounts

| Country | Product Type |
| ------- | ------------ |
| BE      | Drinks       |
| LU      | Food         |

And the following invoices:
* 1000€ of drinks in Belgium
* 2000€ of food in Belgium
* 3000€ of food in Luxemburg

We want to be able to display the following pivot tables:

|     | Drinks | Food | Total |
| --- | ------ | ---- | ----- |
| BE  |   1000 | 2000 |  3000 |
| LU  |      0 | 3000 |  3000 |
| Tot |   1000 | 5000 |  6000 |

|        | Total |
| ------ | ----- |
| Food   |  5000 |
| * BE   |  2000 |
| * LU   |  3000 |
| Drinks |  1000 |
| * BE   |  1000 |
| Total  |  6000 |

Implementation
==============

* `ir.fields` are added/removed dynamically on `account.analytic.line`
* Each analytic plan corresponds to one field on `account.analytic.line`
* The fields are added dynamically in the views.
* `account.analytic.plan` doesn't have a `company_id` field anymore,
  meaning that all the companies have access to all the plans. This
  means that the applicability fields and lines are now company
  dependent, and those can be used to know which fields/plans to display
  for which company.
* There can no longer be one "Project" plan per company, even if the
  accounts of that project can still be owned by only one company.
* There is now only one method to get the default (or "Project" plan),
  which is `_get_plan_columns`

task-3497653

closes odoo/odoo#139225

Related: odoo/upgrade#5306
Related: odoo/enterprise#49226
Signed-off-by: William André (wan) <wan@odoo.com>
Co-authored-by: william <wan@odoo.com>
Co-authored-by: h4818 <ayh@odoo.com>
2023-10-25 18:10:57 +00:00

81 lines
3.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_analytic_plan_form_view" model="ir.ui.view">
<field name="name">account.analytic.plan.form</field>
<field name="model">account.analytic.plan</field>
<field name="arch" type="xml">
<form string="Analytic Plans">
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_view_children_plans" type="object" class="oe_stat_button" icon="fa-bars">
<field string="Subplans" name="children_count" widget="statinfo"/>
</button>
<button name="action_view_analytical_accounts" type="object" class="oe_stat_button" icon="fa-bars">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="all_account_count"/></span>
<span class="o_stat_text">Analytic Accounts</span>
</div>
</button>
</div>
<div class="oe_title">
<h1>
<field name="name"/>
</h1>
</div>
<group>
<group>
<field name="parent_id"/>
<field name="default_applicability"
invisible="parent_id"/>
<field name="color" widget="color_picker"/>
</group>
<group>
</group>
</group>
<notebook>
<page string="Applicability" name="applicability"
invisible="parent_id">
<field name="applicability_ids">
<tree editable="bottom">
<field name="business_domain"/>
<field name="applicability"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="account_analytic_plan_tree_view" model="ir.ui.view">
<field name="name">account.analytic.plan.tree</field>
<field name="model">account.analytic.plan</field>
<field name="arch" type="xml">
<tree string="Analytic Plans" multi_edit="1">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="default_applicability"/>
<field name="color" widget="color_picker"/>
</tree>
</field>
</record>
<record id="account_analytic_plan_action" model="ir.actions.act_window">
<field name="name">Analytic Plans</field>
<field name="res_model">account.analytic.plan</field>
<field name="view_mode">tree,form</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree'}),
(0, 0, {'view_mode': 'form', 'view_id': ref('account_analytic_plan_form_view')})]"/>
<field name="domain">[('parent_id', '=', False)]</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Click to add a new analytic account plan.
</p>
</field>
</record>
</odoo>