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

[11.0] mig operating unit #99

Merged
merged 20 commits into from
Feb 20, 2018
Merged

[11.0] mig operating unit #99

merged 20 commits into from
Feb 20, 2018

Conversation

gdgellatly
Copy link
Contributor

  • 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

@gdgellatly gdgellatly mentioned this pull request Nov 3, 2017
1 task
@pedrobaeza pedrobaeza mentioned this pull request Nov 3, 2017
11 tasks
@pedrobaeza pedrobaeza added this to the 11.0 milestone Nov 3, 2017
@gdgellatly gdgellatly mentioned this pull request Nov 3, 2017
2 tasks
@gdgellatly
Copy link
Contributor Author

Review URL 5592d2c to make it easier for reviewers

Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a 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>

Copy link
Contributor

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

Copy link
Contributor Author

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.

@AaronHForgeFlow
Copy link
Contributor

@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.

@gdgellatly
Copy link
Contributor Author

@aheficent alright simple enough, I added a help message to partner id and removed the known issues

Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@gustavovalverde
Copy link
Member

As far as I tested, this seems OK for the first migration. Do you need / want further testing before making it available for v11?

@AaronHForgeFlow
Copy link
Contributor

@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

@AaronHForgeFlow
Copy link
Contributor

@gdgellatly there are too many commits from older versions, can you squash those a little bit?

@gdgellatly
Copy link
Contributor Author

@aheficent Nope, it keeps failing on rebase.

To configure this module, you need to:

* Assign *Multi Operating Unit* group to user.
* Go to *Settings / Companies / Operating Units* and create Operating Units.
Copy link

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


.. 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/11.0

@@ -0,0 +1,5 @@
# © 2015-2017 Eficent
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace ©️ w/ "Copyright"

"author": "Eficent, "
"Serpent Consulting Services Pvt. Ltd.,"
"Odoo Community Association (OCA)",
"website": "http://www.eficent.com",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove coding from *.py

@api.model
def operating_unit_default_get(self, uid2):
if not uid2:
uid2 = self._uid
Copy link

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)


@api.model
def _get_operating_unit(self):
return self.operating_unit_default_get(self._uid)
Copy link

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?

Copy link
Contributor Author

@gdgellatly gdgellatly Feb 8, 2018

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.

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.


@api.model
def _get_operating_units(self):
return self._get_operating_unit()
Copy link

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>
Copy link

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>
Copy link

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(
Copy link

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 🙂

@edsersolis
Copy link

When will this be merged?

@elicoidal
Copy link

@simahawk @gdgellatly anything that can be added to improve the original PR or shall we add some FIXME in the code?

@simahawk
Copy link

@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 😉

@gdgellatly
Copy link
Contributor Author

gdgellatly commented Feb 14, 2018 via email

@oca-clabot
Copy link

Hey @gdgellatly, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/website.cla
Here is a list of the users:

  • Graeme Gellatly (no github login found)

Appreciation of efforts,
OCA CLAbot

@gdgellatly
Copy link
Contributor Author

is CLA a me or you issue?

@AaronHForgeFlow
Copy link
Contributor

@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.

@gdgellatly
Copy link
Contributor Author

@simahawk happy now :). btw, ignore the CLA message, I force committed after. New laptop had wrong git config.

@JordiBForgeFlow
Copy link
Sponsor Member

Can you rebase? I am not able to merge.

@gdgellatly
Copy link
Contributor Author

@jbeficent I can try, but should be nothing to rebase.

@JordiBForgeFlow
Copy link
Sponsor Member

I am getting a message:
This branch cannot be rebased safely
Rebasing the commits of this branch on top of the base branch cannot be performed automatically as this would create a different result than a regular merge.

@gdgellatly
Copy link
Contributor Author

@jbeficent don't worry, new laptop issues, had remotes around wrong way, will fix up now

@gdgellatly
Copy link
Contributor Author

@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.
Delete original branches.
Restarted migration process from scratch.
Copy files back
Commit
Force push.

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.

Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a 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.

Copy link

@simahawk simahawk left a 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 '

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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping :)

Copy link

@edsersolis edsersolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All seems good.

@JordiBForgeFlow JordiBForgeFlow merged commit f31a1cf into OCA:11.0 Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet