[18.0][IMP] pos_sale_picking_keep: Add a strategy to keep sale pickings and/or POS pickings too#1545
[18.0][IMP] pos_sale_picking_keep: Add a strategy to keep sale pickings and/or POS pickings too#1545rousseldenis wants to merge 5 commits into
Conversation
|
Hi @pedrobaeza, |
pedrobaeza
left a comment
There was a problem hiding this comment.
If you mix directly items from PoS from other loaded from sales, I think there's no discussion: both should be preserved, the ones from PoS in the PoS picking, and the sales one in the sales pickings, so I think there shouldn't be an option, just to proceed that way.
We were previously discarding everything from PoS, because we don't have that mixed option (for now), but if having it in the future, I don't conceive another option except that.
I wanted to keep your behaviour as I didn't know if you have particular processes on your side. So, I keep the option activation or not through a Boolean in place of Selection. |
| if all( | ||
| picking.state == "done" for picking in pos_lines.order_id.picking_ids | ||
| ): |
There was a problem hiding this comment.
not sure if we should prevent empty list (all([]) == True) here ?
| if all( | |
| picking.state == "done" for picking in pos_lines.order_id.picking_ids | |
| ): | |
| if pos_lines.order_id.picking_ids and all( | |
| picking.state == "done" for picking in pos_lines.order_id.picking_ids | |
| ): |
There was a problem hiding this comment.
@petrus-v In fact, no. We should wait : odoo/odoo#253333
|
@rousseldenis you can go directly with no possible choice :) |
I'd prefer not as using stuffs for tests in code is not my cup of tea ;-) |
|
I don't get you. What do you mean by |
You want to say, install this module and the behaviour changes. Correct ? |
|
Well, yes, so I get your point. Let's keep the activation by pos config. |
…t pickings As in some cases, you want to mix in POS orders the payment of an existing sale and added products in the same POS order, you still want to keep both pickings linked to sale orders AND pos orders. This introduces the keep picking strategy that allows to choose per POS configuration the strategy that fits the best to your case.
The behaviour should be the same when the configuration is applied for both POS pickings and sale orders one.
3438237 to
2d43560
Compare
| lines_to_launch = self.filtered( | ||
| lambda line: not line.order_id.pos_config.keep_picking | ||
| or ( | ||
| line.order_id.pos_config.picking_keep_strategy |
There was a problem hiding this comment.
The picking_keep_strategy field does not exist; you should use keep_picking instead.
| return super()._convert_qty(sale_line=sale_line, qty=qty, direction=direction) | ||
| # Mimic what is done at pos_sale level but lowering the quantity | ||
| # TODO: Delete if merged https://github.com/odoo/odoo/pull/253333 | ||
| def update_qty_delivered_from_pickings(sale_line, pos_lines): |
There was a problem hiding this comment.
Personally, I don't like all this extra logic; the way it works now — https://github.com/OCA/pos/blob/18.0/pos_sale_picking_keep/models/sale_order_line.py#L9-L19 — is enough, right? In that case, I think it’s best to leave it as is and try to merge it with odoo/odoo#253333
| state_field = self.env["stock.picking"]._fields["state"] | ||
| picking_values = {} | ||
| # Save picking state values | ||
| for picking in pickings: | ||
| picking_values[picking.id] = picking.state | ||
| # Don't mark the concerned pickings state as dirty to avoid | ||
| # unwanted recomputations | ||
| with self.env.protecting([state_field], pickings): | ||
| pickings.state = "draft" | ||
| res = super().sync_from_ui(orders) | ||
| for picking in pickings: | ||
| picking.state = picking_values[picking.id] |
There was a problem hiding this comment.
Why are these changes necessary? IMO, the current behavior at https://github.com/OCA/pos/blob/18.0/pos_sale_picking_keep/models/pos_order.py#L30-L33 should be enough, right?
@victoralmau @pedrobaeza