-
-
Notifications
You must be signed in to change notification settings - Fork 605
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] pos_stock_available_online: stock move updates #1250
base: 16.0
Are you sure you want to change the base?
[16.0][FIX] pos_stock_available_online: stock move updates #1250
Conversation
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.
LGTM!
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.
LGTM
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.
@danielduqma Thank you for your contribution, please check out the small comments
_name = "stock.notifier.pos.mixin" | ||
_description = "Stock Notifier POS Mixin" | ||
|
||
def _prepare_pos_message(self, warehouse=None): |
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.
The _prepare_pos_message
is called directly in the warehouse loop in the _notify_pos
method, which gets the list of warehouses using the _get_warehouses_to_notify
method in this case warehouse will always be in the argument values, so it can be left as a mandatory argument.
def _prepare_pos_message(self, warehouse):
"""
Return prepared message to send to POS
"""
self.ensure_one()
return warehouse._prepare_vals_for_pos(self.product_id)
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're right, this was a first approach but the logic was moved to _get_warehouses_to_notify
|
||
def _get_warehouses_to_notify(self): | ||
self.ensure_one() | ||
return self.warehouse_id |
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.
Since the current model is a mixin and can be plugged into any model this field may be missing which will cause an error, possible solution is to either return the model object return self.env["stock.warehouse"]
or throw an exception raise NotImplementedError()
In the models where this mixin is connected, implement a method that returns the necessary warehouses
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 mixin was intended just to be inherited by stock.move
and stock.quant
, but I modified it as you proposed to be more extendable
LGTM |
Make stock updates not only on quant updates, but also when a stock move changes its state. This fixes two bugs: - Stock is not updated when a new incoming move is ready, or when a ready one is cancelled - Stock is decreased twice because when quant is updated, move is taken in account because it is not yet on 'done' state
47225e9
to
c9675a5
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.
Code LGTM
Make stock updates not only on quant updates, but also when a stock move changes its state.
This fixes two bugs:
Stock is not updated when a new incoming move is ready, or when a ready one is cancelled. This triggers notification in both outgoing and incoming warehouses
Stock is decreased twice because when quant is updated, move is taken in account because it is not yet on 'done' state. This was reported in After refund of 1 qty, POS qty display increased by 2 qty #1039, but the proposed solution in [16.0][FIX] pos_stock_available_online: FIX For After refund of 1 qty, POS qty display increased by 2 qty #1041 was local and only concerned moves from PoS orders
FL-556-4139