Merge lp:~akretion-team/multi-company/multi-company-action-user into lp:multi-company

Proposed by Benoit Guillot - http://www.akretion.com
Status: Needs review
Proposed branch: lp:~akretion-team/multi-company/multi-company-action-user
Merge into: lp:multi-company
Diff against target: 156 lines (+136/-0)
4 files modified
multi_company_action_user/__init__.py (+23/-0)
multi_company_action_user/__openerp__.py (+41/-0)
multi_company_action_user/res_company.py (+43/-0)
multi_company_action_user/res_company_view.xml (+29/-0)
To merge this branch: bzr merge lp:~akretion-team/multi-company/multi-company-action-user
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp Needs Resubmitting
Ana Juaristi Olalde (community) Approve
Pedro Manuel Baeza Needs Information
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+179179@code.launchpad.net

Description of the change

Hello,

I propose a new module in this branch : multi_company_action_user

This module is a generic module. It adds a field on the company : automatic_action_user_id.

This field defines a user for a company that will be used in the code for intercompany automatic actions. For instance, automatic intercompany invoices, sales ...

Best regards.

Benoît

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

I expect that the use of this module will become clear in future modules, so I only have a couple of nits:

- better to remove the empty lines at the end of __init__.py
- l.114..119 will probably look more elegant if you break the line after the parenthesis and align with the 'o' in 'automatic'.
- l. 127 you can use orm.except_orm instead, so that you do not have to import osv at all

review: Needs Fixing
6. By Benoit Guillot - http://www.akretion.com

[FIX] clean code

Revision history for this message
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote :

Thanks Stefan for the review.

Indeed, the field is used in other modules that I will propose for merging too.

I made the changes ask in your comment.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for the changes!

review: Approve
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM, The same as Stefan, I do not see the use of that field and I'm curious about the rest of modules here.

review: Approve (code review, no tests)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Eric Caudal has said that Elico is working on some modules for providing multi-company documents automations, so I would like to know if this module has something to do with that or is another work in progress for the same purpose. If it's so, I would recommend to talk each other to shyncronize you to avoid duplicating efforts.

Regards.

review: Needs Information
Revision history for this message
Sylvain LE GAL (GRAP) (sylvain-legal) wrote :

Hi,

There wasn't any answer to Pedro's question. Does this MP need review ?

Regards.

Revision history for this message
Ana Juaristi Olalde (ajuaristio) wrote :

If this could help... Joël's questions help try:

When it's necesary creating an automated document from one company to another one and user working on origin company has not permission on the destiny document, any creation action produces an error so I think the field is to avoid using hardcode user_id = 1 to be passed as parameter between functions.

Just my 2 cents.

I just aprove the idea and code. Not tested code.

If you find it usefull we have got several multi-company processes created for 6.1. They have been made especifically for a customer with a very specific proccesses but maybe some code/ideas/functional aproach could be reused to build generic Odoo's full multicompany requirements. Just an idea.

I published several screencast about requirements and solution we have built (it's in spanish, sorry for that):
http://www.aula-openerp.com/soluciones-específicas-61-3/procesos-intercompañía-entre-3-empresas/
Our modules are published and available, but please contact me if you need more information about them.

review: Approve
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Could you update the description of the module to make it clear that there is no magic done in the module.

Suggestion:

'description': """Defines a user to be used for automatic action

This module adds a field 'automatic_action_user_id'
on the company to define a specific user to be used for the automatic actions. This field can
then be used by other modules defining such actions."""

Even then, the concept of "automatic action" is not clear to me. An example would be welcome.

review: Needs Information (code review, no tests)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Hello,

The management of the project has moved to Github: https://github.com/OCA/multi-company

Please migrate your merge proposal to Github. You may want to check https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub for an explanation on how to proceed.

Thanks for contributing to the project

review: Needs Resubmitting

Unmerged revisions

6. By Benoit Guillot - http://www.akretion.com

[FIX] clean code

5. By Benoit Guillot - http://www.akretion.com

[ADD] new module to add a specific user to the company to make actions on this company

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'multi_company_action_user'
2=== added file 'multi_company_action_user/__init__.py'
3--- multi_company_action_user/__init__.py 1970-01-01 00:00:00 +0000
4+++ multi_company_action_user/__init__.py 2013-08-13 08:36:36 +0000
5@@ -0,0 +1,23 @@
6+# -*- coding: utf-8 -*-
7+###############################################################################
8+# #
9+# multi_company_action_user for OpenERP #
10+# Copyright (C) 2013 Akretion Benoît GUILLOT <benoit.guillot@akretion.com> #
11+# #
12+# This program is free software: you can redistribute it and/or modify #
13+# it under the terms of the GNU Affero General Public License as #
14+# published by the Free Software Foundation, either version 3 of the #
15+# License, or (at your option) any later version. #
16+# #
17+# This program is distributed in the hope that it will be useful, #
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20+# GNU Affero General Public License for more details. #
21+# #
22+# You should have received a copy of the GNU Affero General Public License #
23+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24+# #
25+###############################################################################
26+
27+import res_company
28+
29
30=== added file 'multi_company_action_user/__openerp__.py'
31--- multi_company_action_user/__openerp__.py 1970-01-01 00:00:00 +0000
32+++ multi_company_action_user/__openerp__.py 2013-08-13 08:36:36 +0000
33@@ -0,0 +1,41 @@
34+# -*- coding: utf-8 -*-
35+###############################################################################
36+# #
37+# multi_company_action_user for OpenERP #
38+# Copyright (C) 2013 Akretion Benoît GUILLOT <benoit.guillot@akretion.com> #
39+# #
40+# This program is free software: you can redistribute it and/or modify #
41+# it under the terms of the GNU Affero General Public License as #
42+# published by the Free Software Foundation, either version 3 of the #
43+# License, or (at your option) any later version. #
44+# #
45+# This program is distributed in the hope that it will be useful, #
46+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
47+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
48+# GNU Affero General Public License for more details. #
49+# #
50+# You should have received a copy of the GNU Affero General Public License #
51+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
52+# #
53+###############################################################################
54+
55+
56+
57+{
58+ 'name': 'multi_company_action_user',
59+ 'version': '0.1',
60+ 'category': 'Generic Modules/Others',
61+ 'license': 'AGPL-3',
62+ 'description': """This module adds a field 'automatic_action_user_id' """
63+ """on the company to define a specific user to be used for the automatic actions.""",
64+ 'author': 'Akretion',
65+ 'website': 'http://www.akretion.com/',
66+ 'depends': ['base'],
67+ 'data': [
68+ 'res_company_view.xml',
69+ ],
70+ 'demo': [],
71+ 'installable': True,
72+ 'active': False,
73+}
74+
75
76=== added file 'multi_company_action_user/res_company.py'
77--- multi_company_action_user/res_company.py 1970-01-01 00:00:00 +0000
78+++ multi_company_action_user/res_company.py 2013-08-13 08:36:36 +0000
79@@ -0,0 +1,43 @@
80+# -*- coding: utf-8 -*-
81+###############################################################################
82+# #
83+# multi_company_action_user for OpenERP #
84+# Copyright (C) 2013 Akretion Benoît GUILLOT <benoit.guillot@akretion.com> #
85+# #
86+# This program is free software: you can redistribute it and/or modify #
87+# it under the terms of the GNU Affero General Public License as #
88+# published by the Free Software Foundation, either version 3 of the #
89+# License, or (at your option) any later version. #
90+# #
91+# This program is distributed in the hope that it will be useful, #
92+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
93+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
94+# GNU Affero General Public License for more details. #
95+# #
96+# You should have received a copy of the GNU Affero General Public License #
97+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
98+# #
99+###############################################################################
100+
101+from openerp.osv import fields, orm
102+from tools.translate import _
103+
104+
105+class res_company(orm.Model):
106+ _inherit = "res.company"
107+
108+ _columns = {
109+ 'automatic_action_user_id': fields.many2one(
110+ 'res.users', 'Automatic actions user',
111+ help='This user is the one used for all the actions '
112+ '(create(), write(),...) to make on this company.'),
113+ }
114+
115+ def get_company_action_user(self, cr, uid, company_id, context=None):
116+ user_id = self.read(cr, uid, company_id,
117+ ['automatic_action_user_id'],
118+ context=context)['automatic_action_user_id']
119+ if not user_id:
120+ raise orm.except_orm(_('Error !'),
121+ _('You need to define an automatic action user for the company !'))
122+ return user_id[0]
123
124=== added file 'multi_company_action_user/res_company_view.xml'
125--- multi_company_action_user/res_company_view.xml 1970-01-01 00:00:00 +0000
126+++ multi_company_action_user/res_company_view.xml 2013-08-13 08:36:36 +0000
127@@ -0,0 +1,29 @@
128+<?xml version="1.0" encoding="utf-8"?>
129+<!--
130+ multi_company_action_user for OpenERP
131+ Copyright (C) 2013 Akretion Benoît GUILLOT <benoit.guillot@akretion.com>
132+ The licence is in the file __openerp__.py
133+-->
134+
135+<openerp>
136+ <data>
137+
138+ <!-- INHERITED VIEW FOR THE OBJECT : res_company -->
139+
140+ <record id="res_company_view_form" model="ir.ui.view">
141+ <field name="name">base_multi_company.res_company.view_form</field>
142+ <field name="model">res.company</field>
143+ <field name="inherit_id" ref="base.view_company_form" />
144+ <field name="type">form</field>
145+ <field name="arch" type="xml">
146+ <data>
147+ <page string="Configuration" position="inside">
148+ <separator string="Multi-company" colspan="4"/>
149+ <field name="automatic_action_user_id"/>
150+ </page>
151+ </data>
152+ </field>
153+ </record>
154+
155+ </data>
156+</openerp>

Subscribers

People subscribed via source and target branches