Skip to content

Commit

Permalink
Port account_analytic_required to v10
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-via committed Oct 10, 2016
1 parent 79fee42 commit 2902973
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion account_analytic_required/README.rst
Expand Up @@ -22,7 +22,7 @@ Usage

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/87/9.0
:target: https://runbot.odoo-community.org/runbot/87/10.0

Bug Tracker
===========
Expand Down
7 changes: 3 additions & 4 deletions account_analytic_required/__manifest__.py
@@ -1,16 +1,15 @@
# -*- coding: utf-8 -*-
# © 2011 Akretion
# © 2011-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
'name': 'Account Analytic Required',
'version': '9.0.1.0.0',
'version': '10.0.1.0.0',
'category': 'Analytic Accounting',
'license': 'AGPL-3',
'author': "Akretion,Odoo Community Association (OCA)",
'website': 'http://www.akretion.com/',
'depends': ['account'],
'data': ['views/account.xml'],
'installable': False,
'auto_install': False,
'installable': True,
}
11 changes: 5 additions & 6 deletions account_analytic_required/models/account.py
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
# © 2011 Akretion
# © 2011-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from openerp import _, api, exceptions, fields, models
from openerp.tools import float_is_zero
from odoo import _, api, exceptions, fields, models
from odoo.tools import float_is_zero


class AccountAccountType(models.Model):
Expand Down Expand Up @@ -59,12 +59,11 @@ def _check_analytic_required_msg(self):
move_line.analytic_account_id):
return _("Analytic policy is set to 'Never' with account %s "
"'%s' but the account move line with label '%s' "
"has an analytic account %s '%s'."
"has an analytic account '%s'."
) % (move_line.account_id.code,
move_line.account_id.name,
move_line.name,
move_line.analytic_account_id.code,
move_line.analytic_account_id.name)
move_line.analytic_account_id.name_get()[0][1])

@api.constrains('analytic_account_id', 'account_id', 'debit', 'credit')
def _check_analytic_required(self):
Expand Down
Expand Up @@ -3,8 +3,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from datetime import datetime

from openerp.tests import common
from openerp import exceptions
from odoo.tests import common
from odoo import exceptions


class TestAccountAnalyticRequired(common.TransactionCase):
Expand All @@ -17,7 +17,7 @@ def setUp(self):
self.move_line_obj = self.env['account.move.line']
self.analytic_account_obj = self.env['account.analytic.account']
self.analytic_account = self.analytic_account_obj.create(
{'name': 'test aa', 'account_type': 'normal'})
{'name': 'test aa'})
self.account_sales = self.env['account.account'].create({
'code': "X1020",
'name': "Product Sales - (test)",
Expand Down Expand Up @@ -75,6 +75,7 @@ def _set_analytic_policy(self, policy, account=None):
account.user_type_id.analytic_policy = policy

def test_optional(self):
self._set_analytic_policy('optional')
self._create_move(with_analytic=False)
self._create_move(with_analytic=True)

Expand Down Expand Up @@ -107,7 +108,7 @@ def test_never_with_analytic_0(self):
self._create_move(with_analytic=True, amount=0)

def test_always_remove_analytic(self):
# remove partner when policy is always
# remove analytic when policy is always
self._set_analytic_policy('always')
line = self._create_move(with_analytic=True)
with self.assertRaises(exceptions.ValidationError):
Expand Down
20 changes: 16 additions & 4 deletions account_analytic_required/views/account.xml
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Account analytic required module for OpenERP
Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
© 2011-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

<odoo>
Expand All @@ -30,6 +28,20 @@
</field>
</record>

<record id="view_account_type_search" model="ir.ui.view">
<field name="name">account_analytic_required.account_type_search</field>
<field name="model">account.account.type</field>
<field name="inherit_id" ref="account.view_account_type_search" />
<field name="arch" type="xml">
<field name="name" position="after">
<group string="Group By" name="groupby">
<filter name="analytic_policy_groupby" string="Analytic Policy"
context="{'group_by': 'analytic_policy'}"/>
</group>
</field>
</field>
</record>

<menuitem action="account.action_account_type_form" sequence="20" id="menu_action_account_type_form" parent="account.account_account_menu" groups="base.group_no_one"/>

</odoo>

0 comments on commit 2902973

Please sign in to comment.