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

[16.0][FIX] product_supplierinfo_stock_picking_type: rename on change picking type method #1777

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.onchange("picking_type_id")
def onchange_picking_type_id(self):
AlexPForgeFlow marked this conversation as resolved.
Show resolved Hide resolved
def onchange_picking_type_id_onchange_product(self):
# Method name is to avoid conflicts with mrp_subcontracting_dropshipping
# that have an onchange method named onchange_picking_type_id
Copy link
Member

Choose a reason for hiding this comment

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

I think you can keep the same method but call the super if the method exists.

if hasattr(super(), "onchange_picking_type_id"):
    getattr(super(), "onchange_picking_type_id)

Copy link
Author

Choose a reason for hiding this comment

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

Hi @victoralmau !
No, as I already mentioned, the Odoo function is overriding the method, so in the module hierarchy, product_supplierinfo_stock_picking_type comes before mrp_subcontracting_dropshipping. For this reason, the method is being overridden. To implement your solution, we would need to add it to Odoo's method.

for line in self.order_line:
line.onchange_product_id()
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ def test_product_picking_type_c(self):
po = self._create_purchase_order(self.picking_in_c)
self.assertEqual(po.order_line.price_unit, 20)
po.picking_type_id = self.picking_in_a
po.onchange_picking_type_id()
po.onchange_picking_type_id_onchange_product()
self.assertEqual(po.order_line.price_unit, 5)
Loading