19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:29:53 +01:00
parent 6e54c1af6c
commit 3ca647e428
1087 changed files with 132065 additions and 108499 deletions

View file

@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import pos_order
from . import stock_move

View file

@ -3,6 +3,7 @@
from odoo import models
class PosOrderLine(models.Model):
_inherit = "pos.order.line"
@ -12,10 +13,11 @@ class PosOrderLine(models.Model):
if not bom:
return super()._get_stock_moves_to_consider(stock_moves, product)
boms, components = bom.explode(product, self.qty)
#Get a flat list of all bom_line_ids
bom_line_ids = [item.id for x in boms for item in x[0].bom_line_ids if set(item.bom_product_template_attribute_value_ids.ids).issubset(product.product_template_variant_value_ids.ids)]
ml_product_to_consider = (product.bom_ids and [comp[0].product_id.id for comp in components]) or [product.id]
if len(boms) > 1:
return stock_moves.filtered(lambda ml: ml.product_id.id in ml_product_to_consider and ml.bom_line_id)
return stock_moves.filtered(lambda ml: ml.product_id.id in ml_product_to_consider and (ml.bom_line_id in bom.bom_line_ids))
return stock_moves.filtered(lambda ml: ml.product_id.id in ml_product_to_consider and (ml.bom_line_id.id in bom_line_ids)).with_context(pos_order_line_id=self.id, bom_id=bom.id)
class PosOrder(models.Model):
_inherit = "pos.order"
@ -29,6 +31,6 @@ class PosOrder(models.Model):
for comp in components:
price_unit = super()._get_pos_anglo_saxon_price_unit(comp[0].product_id, partner_id, comp[1]['qty'])
price_unit = comp[0].product_id.uom_id._compute_price(price_unit, comp[0].product_uom_id)
qty_per_kit = comp[1]['qty'] / bom.product_qty / quantity
qty_per_kit = comp[1]['qty'] / bom.product_qty / (quantity or 1)
total_price_unit += price_unit * qty_per_kit
return total_price_unit

View file

@ -0,0 +1,18 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class StockMove(models.Model):
_inherit = 'stock.move'
def _get_price_unit(self):
pos_order_line_id = self.env.context.get('pos_order_line_id')
bom_id = self.env.context.get('bom_id')
if not pos_order_line_id or not bom_id:
return super()._get_price_unit()
pos_order_line = self.env['pos.order.line'].browse(pos_order_line_id)
bom = self.env['mrp.bom'].browse(bom_id)
if pos_order_line and bom:
return self._get_kit_price_unit(pos_order_line.product_id, bom, pos_order_line.qty)
return super()._get_price_unit()