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

[IMP] stock: Add hybrid procure method 'mts_else_mto' #32642

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
6 participants
@arbaes
Copy link
Contributor

arbaes commented Apr 12, 2019

In some occasions, products can be available in a location, but are still ignored when the MTO is set on those products.
(e.g.: When a product is returned)

To avoid this, we add a procure_method named mts_else_mto, allowing procurement to reserve the products if enough of them are available in his source location.
In order to achieve this, we apply the MTS or the MTO procure_method on the moves from the procurement depending on whether or not there are enough quantities of the needed products in the source location ('All or nothing' logic).

TaskID: 1831347

@robodoo robodoo added the seen 🙂 label Apr 12, 2019

@C3POdoo C3POdoo added the RD label Apr 12, 2019

@robodoo robodoo added the CI 🤖 label Apr 12, 2019

@arbaes arbaes force-pushed the odoo-dev:master-mtso-arb branch from 14254ce to 224edbc Apr 12, 2019

@robodoo robodoo removed the CI 🤖 label Apr 12, 2019

self.assertEqual(so1.order_line.mapped('qty_delivered'), [1, 1, 1])

def test_mtso_mto(self):

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Apr 12, 2019

Contributor

move to stock in TestRoutes

self.assertEquals(picking.move_lines.procure_method, 'make_to_order')

# TODO: To update if we change the 'all or nothing' mechanism

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Apr 12, 2019

Contributor

remove

@@ -44,10 +44,13 @@ class StockRule(models.Model):
route_id = fields.Many2one('stock.location.route', 'Route', required=True, ondelete='cascade')
procure_method = fields.Selection([
('make_to_stock', 'Take From Stock'),
('make_to_order', 'Trigger Another Rule')], string='Move Supply Method',
('make_to_order', 'Trigger Another Rule'),
('mts_then_mto', 'Take From Stock, if Unavailable, Trigger Another Rule')], string='Move Supply Method',

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Apr 12, 2019

Contributor

weird capitals

def _get_procure_method(self, product, qty_needed, location):
""" When the procure_method of the rule is 'mts_then_mto', we need to get the quantity available to know if
we have to apply MTS or MTO on the moves of the procurement.
:param product: The product of the move

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Apr 12, 2019

Contributor

newline

@@ -167,6 +172,21 @@ def _push_prepare_move_copy_values(self, move_to_copy, new_date):
}
return new_move_vals

def _get_procure_method(self, product, qty_needed, location):
""" When the procure_method of the rule is 'mts_then_mto', we need to get the quantity available to know if

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Apr 12, 2019

Contributor

quantity forecasted?

:return: The procure_method to apply on the move
"""
if self.procure_method == 'mts_then_mto':
qty_available = product.with_context(location=location.id).virtual_available

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Apr 12, 2019

Contributor

can't you batch virtual_available? read it for all products where the rule is mts_then_mto and pass the values there

@robodoo robodoo added the CI 🤖 label Apr 12, 2019

@rvalyi

This comment has been minimized.

Copy link
Contributor

rvalyi commented Apr 12, 2019

Hello, great news! Eventually you will want to check it covers the same features as this OCA module by Akretion we had since Odoo 8 https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_mts_mto_rule

@blaggacao

This comment has been minimized.

Copy link
Contributor

blaggacao commented Apr 12, 2019

Standing ovations! (There is no emoji for this)

@arbaes arbaes force-pushed the odoo-dev:master-mtso-arb branch from 224edbc to 4ead7e3 Apr 15, 2019

@robodoo robodoo removed the CI 🤖 label Apr 15, 2019

@arbaes arbaes changed the title [IMP] stock: Add hybrid procure method 'mts_then_mto' [IMP] stock: Add hybrid procure method 'mts_else_mto' Apr 15, 2019

[IMP] stock: Add hybrid procure method 'mts_else_mto'
In some occasions, products can be available in a location, but are still ignored when the MTO is set on those products.
(e.g.: When a product is returned)

To avoid this, we add a `procure_method` named `mts_else_mto`, allowing procurement to reserve the products if enough of them are available in his source location.
In order to achieve this,  we apply the MTS or the MTO `procure_method` on the moves from the procurement depending on whether or not there are enough quantities of the needed products in the source location ('All or nothing' logic).

TaskID: 1831347

@arbaes arbaes force-pushed the odoo-dev:master-mtso-arb branch from 4ead7e3 to 8c29c02 Apr 15, 2019

@robodoo robodoo added the CI 🤖 label Apr 15, 2019

@arbaes arbaes closed this Apr 17, 2019

@arbaes arbaes deleted the odoo-dev:master-mtso-arb branch Apr 17, 2019

@robodoo robodoo added closed 💔 and removed CI 🤖 labels Apr 17, 2019

@arbaes

This comment has been minimized.

Copy link
Contributor Author

arbaes commented Apr 17, 2019

Will be replaced by #32778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.