Skip to content

Commit

Permalink
Merge PR OCA#2310 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by HviorForgeFlow
  • Loading branch information
OCA-git-bot committed Jun 21, 2024
2 parents bc84a21 + e6ee1fd commit b19a159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion purchase_order_type/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ def _default_order_type(self):

@api.onchange("company_id")
def _onchange_company(self):
self.order_type = self._default_order_type()
if not self.order_type or (
self.order_type
and self.order_type.company_id not in [self.company_id, False]
):
self.order_type = self._default_order_type()
3 changes: 3 additions & 0 deletions purchase_order_type/tests/test_purchase_order_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def test_purchase_order_change_company(self):
order.onchange_partner_id()
self.assertEqual(order.order_type, self.type2)
order._onchange_company()
self.assertEqual(order.order_type, self.type2)
order.write({"order_type": False})
order._onchange_company()
self.assertEqual(order.order_type, order._default_order_type())

def test_purchase_order_type_company_error(self):
Expand Down

0 comments on commit b19a159

Please sign in to comment.