File tree Expand file tree Collapse file tree 4 files changed +29
-5
lines changed
sale_stock_mto_as_mts_orderpoint/models Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 1- from . import product
1+ from . import product_template
2+ from . import product_product
23from . import sale_order
34from . import stock_move
45from . import stock_warehouse
Original file line number Diff line number Diff line change 1+ # Copyright 2023 Camptocamp SA
2+ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
3+
4+ from odoo import models
5+
6+ class ProductProduct (models .Model ):
7+ _inherit = "product.product"
8+
9+ def _variant_is_mto (self ):
10+ self .ensure_one ()
11+ mto_route = self .env .ref ("stock.route_warehouse0_mto" , raise_if_not_found = False )
12+ return mto_route in self .route_ids
13+
14+ def _variant_is_not_mto (self ):
15+ return not self ._variant_is_mto ()
Original file line number Diff line number Diff line change @@ -20,13 +20,21 @@ def write(self, vals):
2020 products_to_update ._archive_orderpoints_on_mto_removal ()
2121 return res
2222
23+ def _template_is_mto (self ):
24+ self .ensure_one ()
25+ mto_route = self .env .ref ("stock.route_warehouse0_mto" , raise_if_not_found = False )
26+ return mto_route in self .route_ids
27+
28+ def _template_is_not_mto (self ):
29+ self .ensure_one ()
30+ return not self ._template_is_mto ()
31+
2332 def _filter_mto_products (self , mto = True ):
2433 mto_route = self .env .ref ("stock.route_warehouse0_mto" , raise_if_not_found = False )
2534 if mto :
26- func = lambda p : mto_route in p . route_ids # noqa
35+ return self . filtered ( lambda t : t . _template_is_mto ())
2736 else :
28- func = lambda p : mto_route not in p .route_ids # noqa
29- return self .filtered (func )
37+ return self .filtered (lambda t : t ._template_is_not_mto ())
3038
3139 def _get_orderpoints_to_archive_domain (self ):
3240 warehouses = self .env ["stock.warehouse" ].search ([])
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def _run_orderpoints_for_mto_products(self):
2727 for delivery_move in delivery_moves :
2828 if (
2929 not delivery_move .is_from_mto_route
30- and mto_route not in delivery_move .product_id .route_ids
30+ and not line .product_id ._variant_is_mto ()
3131 ):
3232 continue
3333 if not delivery_move .warehouse_id .mto_as_mts :
You can’t perform that action at this time.
0 commit comments