-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
[11.0] mig operating unit #99
[11.0] mig operating unit #99
Conversation
gdgellatly
commented
Nov 3, 2017
- Change groups_id inheritance in view to specific group as groups_id gets replaced by a same priority view.
- Remove encodings
- Bump Version
- Test
- Add known issues for docs - if you know the answer I can update docs.
- Update name_search signature to match BaseModel
Review URL 5592d2c to make it easier for reviewers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code seems ok to me. Functional ok also so 👍
|
||
* Eficent <contact@eficent.com> | ||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add yourself as contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter. I don't usually unless its a substantial amount of work.
@gdgellatly regarding the issue mentioned, the partner means to contain the operating unit information. That is, address, logo, phone all contact information that can be used to customized printouts by operating unit or provide the address to other contacts. |
@aheficent alright simple enough, I added a help message to partner id and removed the known issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
As far as I tested, this seems OK for the first migration. Do you need / want further testing before making it available for v11? |
@gustavovalverde if you think this is ok to be merged you can approved this PR and then it will be merged. Currently it has 3 approvals but all of them are from @eficent team |
@gdgellatly there are too many commits from older versions, can you squash those a little bit? |
@aheficent Nope, it keeps failing on rebase. |
operating_unit/README.rst
Outdated
To configure this module, you need to: | ||
|
||
* Assign *Multi Operating Unit* group to user. | ||
* Go to *Settings / Companies / Operating Units* and create Operating Units. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Settings / Users & Companies / Operating Units
operating_unit/README.rst
Outdated
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/213/10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/11.0
operating_unit/__init__.py
Outdated
@@ -0,0 +1,5 @@ | |||
# © 2015-2017 Eficent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace ©️ w/ "Copyright"
operating_unit/__manifest__.py
Outdated
"author": "Eficent, " | ||
"Serpent Consulting Services Pvt. Ltd.," | ||
"Odoo Community Association (OCA)", | ||
"website": "http://www.eficent.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operating_unit/models/__init__.py
Outdated
@@ -0,0 +1,7 @@ | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove coding from *.py
operating_unit/models/res_users.py
Outdated
@api.model | ||
def operating_unit_default_get(self, uid2): | ||
if not uid2: | ||
uid2 = self._uid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user = self.env.user
if uid2:
user = self.env['res.users'].browse(uid2)
operating_unit/models/res_users.py
Outdated
|
||
@api.model | ||
def _get_operating_unit(self): | ||
return self.operating_unit_default_get(self._uid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this the same as passing nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simahawk Honestly I don't know, not the original author and I just couldn't understand why it was like it was. Plus I've not looked at this in months. But it is different, passing nothing would give an error.
I think I changed most of this file, then reverted it because other modules used this code.
But in practice I've found these methods are unsuitable anyway and have rewritten because the only time you really care about a users default operating unit is in creation of a business document, and then you get all sorts of weird issues (like in a sales order, the warehouse, Sales Team, salesperson and the user entering might all belong to different OU's and in multicompany it is a nightmare).
EDIT: I guess what I'm saying is I don't even know why these methods exist, especially the plural one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gdgellatly we are already doing it https://github.com/OCA/operating-unit/blob/10.0/sale_operating_unit/models/sale.py#L14
This is implementation is really old, there's no reason to keep it as it is.
The ones that rely on this old way will have to migrate modules to v11 as well.
So, this is the right time to make this change ;)
Same goes for the indirection of default methods: ppl used to add 2 methods to make them overridable but if you use lambda to proxy the call you don't need the double step anymore.
operating_unit/models/res_users.py
Outdated
|
||
@api.model | ||
def _get_operating_units(self): | ||
return self._get_operating_unit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a lambda to proxy the method call instead of referencing the method's object:
default=lambda self: self._default_operating_units()
[...]
default=lambda self: self._default_operating_unit()
Note the change in the name of the methods ;)
<record id="ir_rule_operating_unit_allowed_operating_units" | ||
model="ir.rule"> | ||
<field name="model_id" ref="model_operating_unit"/> | ||
<field name="domain_force">[('id','in',[g.id for g in user.operating_unit_ids])]</field> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for list comprehension, use .ids
: [('id','in', user.operating_unit_ids.ids])]
<field name="model">operating.unit</field> | ||
<field name="arch" type="xml"> | ||
<form string="Operating Unit" version="7.0"> | ||
<group> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name groups, for the sake of future extension (when you'll add a new group you will copy paste it w/ a name attr ;))
@api.model | ||
def name_search(self, name='', args=None, operator='ilike', limit=100): | ||
# Make a search with default criteria | ||
names1 = super(models.Model, self).name_search( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calls to super()
no longer require arguments as of Python3 🙂
When will this be merged? |
@simahawk @gdgellatly anything that can be added to improve the original PR or shall we add some FIXME in the code? |
@elicoidal to me those methods should be fixed now before merge. Is not a big change BTW. |
I'll fix them. Just got new laptop so it takes a while to set up.
…On Wed, 14 Feb 2018, 8:31 PM Simone Orsi, ***@***.***> wrote:
@elicoidal <https://github.com/elicoidal> to me those methods should be
fixed now before merge. Is not a big change BTW.
I'm not blocking tho, if we put some #FIXME comment 😉
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#99 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE23kPQShdNACO57qPLDX-unpw-ddR3sks5tUovOgaJpZM4QQmqw>
.
|
Hey @gdgellatly, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
is CLA a me or you issue? |
@gdgellatly the problem is the last commit I think. The email address of the author it's different as the one it's registered. It will be solved by amending the last commit and changing the author. |
@simahawk happy now :). btw, ignore the CLA message, I force committed after. New laptop had wrong git config. |
Can you rebase? I am not able to merge. |
@jbeficent I can try, but should be nothing to rebase. |
I am getting a message: |
@jbeficent don't worry, new laptop issues, had remotes around wrong way, will fix up now |
…per the OCA guidelines.
* [MIG] operating_unit to v10.0
@simahawk @jbeficent Wow I made some messes for myself. Had been force pushing to this repo on 2 seperate branches mig-operating-unit and mig-operating_unit and then through some magic these were merging into each other. And then my upstream repo wasn't oca but a personal one. I seem to recall why this arrangement made sense when I started this, but months later forgot I did it. So what I did was copy the files from the last branch I was working on which was what was reviewed. So please just give it one final check and make sure I've not messed/missed anything in this process. I've given it a run through and it seems fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 From my side this is ready to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gdgellatly seems good. Just 2 small comments. Most important: translation of sql constraints.
|
||
_sql_constraints = [ | ||
('code_company_uniq', 'unique (code,company_id)', | ||
'The code of the operating unit must ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this translatable?
code = fields.Char('Code', required=True) | ||
active = fields.Boolean('Active', default=True) | ||
company_id = fields.Many2one( | ||
'res.company', 'Company', required=True, default=lambda self: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All seems good.