-
-
Notifications
You must be signed in to change notification settings - Fork 20
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][MIG] stock_orderpoint_mto_as_mts #14
[16.0][MIG] stock_orderpoint_mto_as_mts #14
Conversation
c3e741c
to
fba9cc7
Compare
26327d1
to
f405e88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG good with @jbaudoux changes
f405e88
to
65bb160
Compare
def _get_warehouse_missing_orderpoint_for_mto(self): | ||
res = {} | ||
wh_obj = self.env["stock.warehouse"] | ||
for product in self: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for product in self: | |
for product in self: | |
if not product.purchase_ok: | |
continue |
There's no point to create a orderpoints for products that can not be purchased.
That is in conflict with the validation done in purchase_reorder_control
Unpurchaseable Products cannot be reordered
https://github.com/OCA/purchase-workflow/blob/e113f0a3a046ad832f2e324df50301c276932fa4/purchase_reorder_control/models/stock_warehouse_orderpoint.py#L21
65bb160
to
cbf3127
Compare
For user without proper rights the confirmation of a sale.order can lead to an access error on the orderpoint creation. The sudo fixes that.
cbf3127
to
4c6119b
Compare
4c6119b
to
fc51a5d
Compare
self.ensure_one() | ||
res = False | ||
wh_obj = self.env["stock.warehouse"] | ||
for product in self: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop for loop as you have ensure_one()
that have no orderpoint yet. | ||
""" | ||
for product in self: | ||
wh = product._get_warehouse_missing_orderpoint_for_mto() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where you check it is a mto product
mto_products = self._filter_mto_products()
return products | ||
|
||
def write(self, vals): | ||
# Archive orderpoints when MTO route is removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is misplaced
/ocabot migration stock_orderpoint_mto_as_mts |
There's no issue in this repo with the title 'Migration to version 16.0' and the milestone 16.0, so not possible to add the comment. |
products.sudo()._ensure_default_orderpoint_for_mto() | ||
return products | ||
|
||
def write(self, vals): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to look invals
for is_mto
or company_id
. Those are on product.template
, so you need to move the hook to write on the right model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the method
res = super().write(vals)
if vals.get("is_mto"):
# when is_mto is set
self.sudo()._ensure_default_orderpoint_for_mto()
elif not vals.get("is_mto", True):
# when is_mto is removed
self.sudo()._archive_orderpoints_on_mto_removal()
elif "company_id" in vals:
# when company is changed
self.sudo()._archive_orderpoints_on_mto_removal()
self.sudo()._ensure_default_orderpoint_for_mto()
return res
|
||
_inherit = "stock.warehouse" | ||
|
||
mto_as_mts = fields.Boolean(default=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you flag this, you could archive from the MTO route the rule for this warehouse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default=False
is useless
Depends on:
Notes:
is_mto
on product (depend on product-attribute/product_route_mto)is_mto
on route instead of xmlid (provided by stock-logistics-warehouse/stock_route_mto - already pulled by product_route_mto)product.product
:product.template
and refactored itis_from_mto_route
onstock.move
. That should not be in this module, not related to orderpoint