-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
[16.0][MIG] stock_picking_analytic: Migration to 16.0 #527
Conversation
4718794
to
88a8944
Compare
88a8944
to
8b8ae36
Compare
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
/ocabot migration stock_picking_analytic |
@yostashiro Shouldn't this deserves a migration script ? |
@rousseldenis I was thinking no, as I thought the whole point of having analytic account (analytic distribution now) in the picking was to propagate the value to stock moves, and few people would care about the data persistency of itself (but I might be wrong). If anything, migration script should be added in https://github.com/OCA/account-analytic/tree/16.0/stock_analytic for analytic distribution of stock moves? |
2b9e8e8
to
0c7d0f8
Compare
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.
Functional review is ok.
@rousseldenis I agree with this |
LGTM +1 |
This PR has the |
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're including commits that are not merged in the stable branch, some of which are even WIP:
Those are migration commits to 15.0, but this module is not migrated to 15.0 yet. I'd suggest either:
- removing those ones from this migration
- Or creating (first) a migration PR to 15.0 and, after that one is merged, resume this one
On the other hand:
"pre-commit" -> "pre-commit stuff"
# Assign a dummy search arg to the field to avoid triggering the warning. | ||
# Without this, use of move_ids_without_package in @api.depends() of the compute | ||
# method would trigger a warning from | ||
# https://github.com/odoo/odoo/blob/ae94f14a844352f66490ec326fe2d1a716023891/odoo/fields.py#L808-L812 # noqa |
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.
If you use a shorter hash, line won't be as long and noqa won't be required, e.g.:
# https://github.com/odoo/odoo/blob/ae94f14a844352f66490ec326fe2d1a716023891/odoo/fields.py#L808-L812 # noqa | |
# https://github.com/odoo/odoo/blob/ae94f14a/odoo/fields.py#L808-L812 |
"move_ids": [ | ||
( | ||
0, | ||
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.
Prefer the Command syntax
Same below
Check analytic distribution on picking is set | ||
""" | ||
picking = self.picking | ||
self.assertNotEqual(len(picking.move_ids), 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.
self.assertNotEqual(len(picking.move_ids), 0) | |
self.assertTrue(picking.move_ids) |
Same below
<field name="inherit_id" ref="stock.view_picking_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group/group/field[@name='picking_type_id']" position="after"> | ||
<!-- groups="analytic.group_analytic_accounting" has been removed from |
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 just need to add the field again as invisible, so the field is included no matter if current user belongs to the group
PR description is a comprehensive one, it would be a shame if it's not included also in commit description. |
@yostashiro Hello, you can apply the suggested changes |
@luisg123v @desdelinux Thanks for your review comments. Will try and follow up on them but give me some time. A bit swamped at the moment. |
@yostashiro Any news on this ? |
I plan to update the PR this weekend. |
…in depends + tests
0c7d0f8
to
bc92469
Compare
@luisg123v @desdelinux @rousseldenis Thanks for waiting. Just updated the PR. I believe I took care of all the points in the feedback. |
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.
Functional Review is ok.
@luisg123v could you review this PR? |
widget="analytic_distribution" | ||
groups="analytic.group_analytic_accounting" | ||
/> | ||
<!-- Just to prevent error in subsequent context update - assigining |
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.
Typo: assigining -> assigning
But I think this comment should be removed, this is not a special case but just the way v16 works. Most of views containing fields with groups (e.g. almost all views with the company_id
field) define the same field as invisible.
A similar case occurred in previous versions when using a field in attrs that was not already present in the view
an invisible field that is accessible to everyone. --> | ||
<field | ||
name="analytic_distribution" | ||
widget="analytic_distribution" |
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.
Since it's invisible, widget is meaningless
) | ||
picking.move_ids_without_package.write( | ||
picking.move_ids_without_package.update( |
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.
Why update instead of write?
write is preferred, because update writes fields one by one
Same below
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.
write()
would throw an error for picking.move_ids_without_package
not having the database record when tests started. I have switched to assign move_ids
instead of move_ids_without_package
to the picking in the setup to use write()
in tests.
- Switch field from analytic_account_id to analytic_distribution. - Assign a dummy search arg to move_ids_without_package field (stock.picking) to bypass the warning from https://github.com/odoo/odoo/blob/0f84366/odoo/fields.py#L808-L812. - Add an invisible analytic distribution field without group assignment in the picking form, due to newly added check in odoo/odoo@0501bbd.
bc92469
to
def630d
Compare
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.
Functional Review is ok.
@OCA/accounting-maintainers This one is ready |
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 👍
Could you review/merge, please? Regards, |
This PR has the |
/ocabot merge nobump |
Hey, thanks for contributing! Proceeding to merge this for you. |
analytic_account_id
toanalytic_distribution
.Change depends referenced field fromAdd dummy search arg tomove_ids_without_package
tomove_ids
.move_ids_without_package
is a non-stored compute field and therefore is not appropriate to be used as a trigger (you get a warning message in running tests without this change).move_ids_without_package
to bypass warning.groups="analytic.group_analytic_accounting"
from theanalytic_distribution
field added in the picking form, because it would cause an errorField 'analytic_distribution' used in context ({'default_company_id': company_id, 'default_date': scheduled_date, 'default_date_deadline': date_deadline, 'picking_type_code': picking_type_code, 'default_picking_id': id, 'form_view_ref': 'stock.view_move_form', 'address_in_id': partner_id, 'default_picking_type_id': picking_type_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id, 'default_partner_id': partner_id, 'default_analytic_distribution': analytic_distribution}) is restricted to the group(s) analytic.group_analytic_accounting
in loading the view. Looks like this refactoring odoo/odoo@0501bbd has added the check. Not sure there is a good way to still add the group to the field, however there is not much point doint it since the module wouldn't be installed without enabling the analytic accounting. -> Add an invisibleanalytic_distribution
field without group assignment (thanks @luisg123v ).Extension of the search view to addanalytic_distribution
field is disabled as the search on json fields do not work in a meaningful manner as of now.@qrtl