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

[17.0][MIG] delivery_roulier: Migration to 17.0 #826

Merged
merged 101 commits into from
Jul 12, 2024

Conversation

yankinmax
Copy link
Contributor

@yankinmax yankinmax commented Jun 4, 2024

@yankinmax yankinmax force-pushed the 17.0-mig-delivery_roulier branch 2 times, most recently from 2b31945 to 14f3bb5 Compare June 5, 2024 08:51
@yankinmax yankinmax force-pushed the 17.0-mig-delivery_roulier branch 2 times, most recently from e569ac5 to 71d8f32 Compare June 18, 2024 08:28
Copy link

@Camille0907 Camille0907 left a comment

Choose a reason for hiding this comment

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

Migration technically LGTM

delivery_roulier/models/stock_move_line.py Outdated Show resolved Hide resolved
@@ -290,3 +290,17 @@ def open_website_url(self):
action["domain"] = [("id", "in", packages.ids)]
action["context"] = {"picking_id": self.id}
return action

def _put_in_pack(self, move_line_ids):
Copy link
Contributor Author

@yankinmax yankinmax Jun 28, 2024

Choose a reason for hiding this comment

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

I've splitted correctly the migration commit to pre-commit one.
Here is the latest fixup to update quant_ids on the package with all quants from move lines in this package.
@rousseldenis @Camille0907
thanks for the reviews

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello,
I don't get why we need this, not why it is in this module. Is this necessary for this module to work ? Why ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @florian-dacosta
From my POV, when the package is created and quants are put in pack, it should be linked to a package.
Probably it was a case in previous versions, but not in v17.
As a result here:

def _roulier_get_parcel(self, picking):
        self.ensure_one()
        weight = self.shipping_weight or self.weight
        parcel = {"weight": weight, "reference": self.name}
        return parcel

shipping_weight or weight are missed and roulier response is wrong.
If you can check the code and suggest better solution it would be great.
BTW, I'm not an expert using this module. But, I need it to be migrated for my project.
Thanks in advance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I believe it has always been this way. When you click on "put in pack" button, the pack is set on the operations (stock.move.line) but if you check the pack, it is still empty (no quant inside). This is not specific to the v17.
I understand it may be an issue, if you want to generate the label, before validating the picking, which is not the way odoo works.

The label generation is triggered at the end of "stock.picking._action_done". At this stage, the quant are already linked to the pack, so the weight is ok.

I guess it would be nice to be able to generate label before the validation of the shipping, but :

  • This is not a problem specific to delivery_roulier, I think it could be an issue for any module managing the carrier label. If I should pick a module with something like that, I'd probably create a new dedicated module, which you could choose to install or not, along with delivery_roulier (or any other module managing shipping labels).
  • The way to do it does not seem ok to me. Indeed, the button put_in_pack is optional, you can also set the result_package_id of the stock.move.line manually (in this case the weight won't be ok either)
    After you set a result package id, you can remove it manually... You can delete the stock.move.line, you can change the pack, you can do anything. Then, the package on some quants will be wrong, which is an issue.
    Also, you have a source package and a result package on stock.move.line. When a quant is already in a pack, when you transfer it, the source package is filled. If you write the pack on the quant with the "put in pack" button, then the source package should probably be set, not sure about the impacts.

Anyway, I have no solution to propose around this subject now, but this one should definitely not go here and should probably be well tested as well, with the different cases.

@yankinmax
Copy link
Contributor Author

@rousseldenis is this migration ok now?

@@ -290,3 +290,17 @@ def open_website_url(self):
action["domain"] = [("id", "in", packages.ids)]
action["context"] = {"picking_id": self.id}
return action

def _put_in_pack(self, move_line_ids):
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I believe it has always been this way. When you click on "put in pack" button, the pack is set on the operations (stock.move.line) but if you check the pack, it is still empty (no quant inside). This is not specific to the v17.
I understand it may be an issue, if you want to generate the label, before validating the picking, which is not the way odoo works.

The label generation is triggered at the end of "stock.picking._action_done". At this stage, the quant are already linked to the pack, so the weight is ok.

I guess it would be nice to be able to generate label before the validation of the shipping, but :

  • This is not a problem specific to delivery_roulier, I think it could be an issue for any module managing the carrier label. If I should pick a module with something like that, I'd probably create a new dedicated module, which you could choose to install or not, along with delivery_roulier (or any other module managing shipping labels).
  • The way to do it does not seem ok to me. Indeed, the button put_in_pack is optional, you can also set the result_package_id of the stock.move.line manually (in this case the weight won't be ok either)
    After you set a result package id, you can remove it manually... You can delete the stock.move.line, you can change the pack, you can do anything. Then, the package on some quants will be wrong, which is an issue.
    Also, you have a source package and a result package on stock.move.line. When a quant is already in a pack, when you transfer it, the source package is filled. If you write the pack on the quant with the "put in pack" button, then the source package should probably be set, not sure about the impacts.

Anyway, I have no solution to propose around this subject now, but this one should definitely not go here and should probably be well tested as well, with the different cases.

@yankinmax
Copy link
Contributor Author

I'll remove the part I've proposed.
I don't have any other better solution for now.

@florian-dacosta
Copy link
Contributor

I'll remove the part I've proposed. I don't have any other better solution for now.

Thanks, I'll approve then.
Can you also have a look here #851 and make a cherry pick to include the v16 fix here please?

@yankinmax
Copy link
Contributor Author

I'll remove the part I've proposed. I don't have any other better solution for now.

Thanks, I'll approve then. Can you also have a look here #851 and make a cherry pick to include the v16 fix here please?

of course, thanks

@yankinmax
Copy link
Contributor Author

@florian-dacosta I've checked your fix in v17. Still the same issue:

_____________________________________________________________________________________ DeliveryRoulierCase.test_roulier _____________________________________________________________________________________

self = <odoo.addons.delivery_roulier.tests.test_delivery_roulier.DeliveryRoulierCase testMethod=test_roulier>

    def test_roulier(self):
        roulier.get_carriers_action_available = MagicMock(
            return_value={"test": ["get_label"]}
        )
        with patch("roulier.roulier.get") as mock_roulier:
            mock_roulier.return_value = roulier_ret
            self.picking.send_to_shipper()
            roulier_args = mock_roulier.mock_calls[0][1]
            self.assertEqual("get_label", roulier_args[1])
            roulier_payload = roulier_args[2]
            self.assertEqual(len(roulier_payload["parcels"]), 1)
>           self.assertEqual(roulier_payload["parcels"][0].get("weight"), 1.2)
E           AssertionError: 0.0 != 1.2

so weight is not properly updated in _roulier_get_parcel

@florian-dacosta
Copy link
Contributor

@florian-dacosta I've checked your fix in v17. Still the same issue:

_____________________________________________________________________________________ DeliveryRoulierCase.test_roulier _____________________________________________________________________________________

self = <odoo.addons.delivery_roulier.tests.test_delivery_roulier.DeliveryRoulierCase testMethod=test_roulier>

    def test_roulier(self):
        roulier.get_carriers_action_available = MagicMock(
            return_value={"test": ["get_label"]}
        )
        with patch("roulier.roulier.get") as mock_roulier:
            mock_roulier.return_value = roulier_ret
            self.picking.send_to_shipper()
            roulier_args = mock_roulier.mock_calls[0][1]
            self.assertEqual("get_label", roulier_args[1])
            roulier_payload = roulier_args[2]
            self.assertEqual(len(roulier_payload["parcels"]), 1)
>           self.assertEqual(roulier_payload["parcels"][0].get("weight"), 1.2)
E           AssertionError: 0.0 != 1.2

so weight is not properly updated in _roulier_get_parcel

The fix was not related to the weight issue, it was about picking tracking link.
Where do you see this error ? The test on this PR seem fine, am I missing something ?

@yankinmax
Copy link
Contributor Author

ah sorry I forgot to update, wait a sec

@yankinmax
Copy link
Contributor Author

yankinmax commented Jul 9, 2024

@florian-dacosta
For this error my fix was applied with put_in_pack override:
https://github.com/OCA/delivery-carrier/actions/runs/9856183670/job/27212631968?pr=826#step:8:74

@florian-dacosta
Copy link
Contributor

florian-dacosta commented Jul 9, 2024

Oh, I understand. After checking the test both on v16 and v17, here is the change that did break the delivery_roulier test :
99e3d58#diff-8e3509b96799ba2c6bfb09b79df02a224f2ed73f5b529a0e2fa210f105fd64d2R25
Condition was changed from if not pack.quant_ids to if pack.quant_ids
I don't understand why this was changed, but this is the reason of the test failing now.

@yankinmax
Copy link
Contributor Author

Oh, I understand. After checking the test both on v16 and v17, here is the change that did break the delivery_roulier test : 99e3d58#diff-8e3509b96799ba2c6bfb09b79df02a224f2ed73f5b529a0e2fa210f105fd64d2R25 Condition was changed from if not pack.quant_ids to if pack.quant_ids I don't understand why this was changed, but this is the reason of the test failing now.

I'll prepare a fix

@yankinmax
Copy link
Contributor Author

@florian-dacosta I'm feeling like we can finish the job finally)
Can you approve?

@yankinmax
Copy link
Contributor Author

BTW, if we could merge this one today we can also merge one more so it can be a very fast line day 😄

@florian-dacosta
Copy link
Contributor

@rousseldenis I guess your comment is now obsolete, but if you could confirm it changing your review it would be great!

@yankinmax
Copy link
Contributor Author

@rousseldenis can you please update your review and in case you approve trigger the merge?

delivery_roulier/models/delivery_carrier.py Outdated Show resolved Hide resolved
delivery_roulier/tests/test_delivery_roulier.py Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
@simahawk
Copy link
Contributor

/ocabot migration delivery_roulier

@OCA-git-bot OCA-git-bot added this to the 17.0 milestone Jul 11, 2024
@yankinmax
Copy link
Contributor Author

@simahawk updated with fixup

Copy link
Contributor

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

@yankinmax cool, tnx. Don't forget to squash 😉

@simahawk
Copy link
Contributor

/ocabot merge nopbump

@OCA-git-bot
Copy link
Contributor

Hi @simahawk. Your command failed:

Invalid options for command merge: nopbump.

Ocabot commands

  • ocabot merge major|minor|patch|nobump
  • ocabot rebase
  • ocabot migration {MODULE_NAME}

More information

@simahawk
Copy link
Contributor

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 17.0-ocabot-merge-pr-826-by-simahawk-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 8f86277 into OCA:17.0 Jul 12, 2024
5 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at f219c96. Thanks a lot for contributing to OCA. ❤️

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.