Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.0] extract analytic_base_department #170

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
09bb612
[ADD] Commit of the modules used by C2C to move in our new public branch
jgrandguillaume Aug 12, 2011
3047957
[MRG] from 6.1
yvaucher Jul 24, 2012
668d0b9
[FIX] crm_department - headers
yvaucher Mar 19, 2012
332e0f2
[FIX] view xpath in analytic_department
guewen Jul 23, 2012
9c2bb8e
[MIGR] set installable to False on all the modules, the flag has to b…
guewen Jan 4, 2013
4f69d01
[CHG] Migration to v7. Features depending on the deprecated user depa…
dreispt Feb 27, 2013
4e83c43
[FIX] file 'x' attributes; license now stated in a single place.
dreispt Feb 27, 2013
096f3c8
[FIX] License and author
dreispt Feb 28, 2013
21c42e7
[FIX] removing useless <field name=type>; fixing DOS linebreaks and +…
dreispt Mar 4, 2013
598354f
[IMP] Add the project/account department on analytic line. You can no…
jgrandguillaume May 8, 2014
0a9dca7
[IMP] Add department_id in analytic form view + add default value for…
jgrandguillaume May 8, 2014
3410f44
[FIX] Missed a coma
jgrandguillaume May 8, 2014
125c4a0
[IMP] Add triggers on needed field (as suggested by review)
jgrandguillaume May 12, 2014
d8c0176
Set modules as not installable
dreispt Jul 1, 2014
736967c
Port analytic_department to v8
dreispt Jul 2, 2014
bc02cc6
Remove x file flag from LICENSE
dreispt Jul 10, 2014
82a2ecd
Fix context named argument
dreispt Jul 10, 2014
22614c3
Split analytic_department into analytic_base_department to isolate de…
dreispt Jul 22, 2014
6cea7f7
Add tests to analytic_base_department
dreispt Aug 13, 2014
986d0e4
Fix python import, version number and i18n
dreispt Sep 17, 2014
aded2bd
ADD Department's related user
angelmoya Jan 17, 2015
02bc922
FIX format and new api
angelmoya Jan 17, 2015
2994439
FIX computed field
angelmoya Jan 17, 2015
3bb818c
IMP user.department_ids auto_join
angelmoya Jan 19, 2015
44372a5
Revert "ADD Department's related user"
dreispt Jan 30, 2015
2915ef6
Add OCA as author of OCA addons
gurneyalex Mar 2, 2015
161aaaf
[UPD] prefix versions with 8.0
sbidoul Oct 9, 2015
428ba49
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
f230d84
[PORT][9.0] analytic_base_department
yvaucher Jan 28, 2016
d3882df
Replace yml test by a python unit test
yvaucher Apr 28, 2016
a811713
Move description in README.rst
yvaucher Apr 28, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions analytic_base_department/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
OpenERP, Open Source Management Solution

Original author: Joël Grand-Guillaume
Copyright © 2011 Camptocamp SA (http://www.camptocamp.com)
Copyright © 2013 Daniel Reis (SECURITAS)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public Lice
along with this program. If not, see <http://www.gnu.org/licenses/>.
70 changes: 70 additions & 0 deletions analytic_base_department/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=======================================
Base Analytic Department Categorization
=======================================

This module add Department to Analytic Account lines.
It will set current user by default on the lines.

Installation
============

No required dependency on Accounting modules.

You might want to install as well other modules to set department:

- Analytic Department Categorization (`analytic_departement`)
- Project Department Categorization (`project_departement`)
- Project Task specific Department (`project_task_departement`)


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/140/9.0


Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/project/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Joël Grand-Guillaume <joël.grandguillaume@camptocamp.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Daniel Reis <dgreis@sapo.pt>
* Angel Moya <angel.moya@domatix.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
5 changes: 5 additions & 0 deletions analytic_base_department/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2011 Joël Grand-Guillaume (Camptocamp)
# © 2013 Daniel Reis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
15 changes: 15 additions & 0 deletions analytic_base_department/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# © 2011 Joël Grand-Guillaume (Camptocamp)
# © 2013 Daniel Reis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Base Analytic Department Categorization",
"version": "9.0.1.0.0",
"author": "Camptocamp, Daniel Reis,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Generic Modules/Projects & Services",
"website": "http://camptocamp.com",
"depends": ["analytic", "hr"],
"data": ["views/analytic.xml"],
'installable': True,
}
24 changes: 24 additions & 0 deletions analytic_base_department/i18n/analytic_base_department.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * analytic_department
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.0.1\n"
"Report-Msgid-Bugs-To: amos.oviedo@gmail.es\n"
"POT-Creation-Date: 2011-03-02 12:04:59+0000\n"
"PO-Revision-Date: 2011-03-02 12:19+0100\n"
"Last-Translator: Amós Oviedo <amos.oviedo@gmail.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"

#. module: analytic_department
#: field:account.analytic.account,department_id:0
#: view:account.analytic.account:0
#: field:account.analytic.line,department_id:0
#: view:account.analytic.line:0
msgid "Department"
msgstr ""
26 changes: 26 additions & 0 deletions analytic_base_department/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Spanish translation for openobject-addons
# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011
# This file is distributed under the same license as the openobject-addons package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2011-03-02 12:04+0000\n"
"PO-Revision-Date: 2011-03-14 09:43+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Spanish <es@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2011-04-16 07:04+0000\n"
"X-Generator: Launchpad (build 12735)\n"

#. module: analytic_department
#: field:account.analytic.account,department_id:0
#: view:account.analytic.account:0
#: field:account.analytic.line,department_id:0
#: view:account.analytic.line:0
msgid "Department"
msgstr "Departamento"
26 changes: 26 additions & 0 deletions analytic_base_department/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Spanish translation for openobject-addons
# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011
# This file is distributed under the same license as the openobject-addons package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2011-03-02 12:04+0000\n"
"PO-Revision-Date: 2011-03-14 09:43+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Spanish <es@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2011-04-16 07:04+0000\n"
"X-Generator: Launchpad (build 12735)\n"

#. module: analytic_department
#: field:account.analytic.account,department_id:0
#: view:account.analytic.account:0
#: field:account.analytic.line,department_id:0
#: view:account.analytic.line:0
msgid "Department"
msgstr "Departamento"
5 changes: 5 additions & 0 deletions analytic_base_department/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2011 Joël Grand-Guillaume (Camptocamp)
# © 2013 Daniel Reis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import analytic
39 changes: 39 additions & 0 deletions analytic_base_department/models/analytic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# © 2011 Joël Grand-Guillaume (Camptocamp SA)
# © 2013 Daniel Reis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, fields, models


class AnalyticAccount(models.Model):
_inherit = "account.analytic.account"

department_id = fields.Many2one(
'hr.department',
'Department')


class AnalyticLine(models.Model):
_inherit = "account.analytic.line"

@api.multi
def _get_department(self):
emp_model = self.env['hr.employee']
department_id = False
employee = emp_model.search([('user_id', '=', self.env.uid)], limit=1)
if employee and employee.department_id:
department_id = employee.department_id.id
return department_id

department_id = fields.Many2one(
'hr.department',
'Department',
default=_get_department,
help="User's related department")
account_department_id = fields.Many2one(
comodel_name='hr.department',
related='account_id.department_id',
string='Account Department',
store=True,
readonly=True,
help="Account's related department")
4 changes: 4 additions & 0 deletions analytic_base_department/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Yannick Vaucher (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_line_department
19 changes: 19 additions & 0 deletions analytic_base_department/tests/test_line_department.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# © 2016 Yannick Vaucher (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests.common import TransactionCase


class LineDepartmentCase(TransactionCase):

def test_default_department(self):
"""In a new users form, a user set only the firstname."""
aal = self.env['account.analytic.line'].sudo(self.user).new()
department_id = aal.default_get(['department_id']).get('department_id')
self.assertEqual(department_id, self.dep.id)

def setUp(self):
super(LineDepartmentCase, self).setUp()
# base.user_demo --> hr.employee_qdp --> hr.dep_rd
self.user = self.env.ref('base.user_demo')
self.dep = self.env.ref('hr.dep_rd')
16 changes: 16 additions & 0 deletions analytic_base_department/views/analytic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<openerp>
<data>

<record id="view_account_analytic_account_form" model="ir.ui.view">
<field name="name">account.analytic.account.form</field>
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="analytic.view_account_analytic_account_form"/>
<field name="arch" type="xml">
<field name="code" position="after">
<field name="department_id"/>
</field>
</field>
</record>

</data>
</openerp>