19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:07 +01:00
parent ba20ce7443
commit 768b70e05e
2357 changed files with 1057103 additions and 712486 deletions

View file

@ -1,51 +1,44 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, models
from collections import defaultdict
from odoo import models
class StockMove(models.Model):
_inherit = "stock.move"
def _filter_anglo_saxon_moves(self, product):
res = super(StockMove, self)._filter_anglo_saxon_moves(product)
res += self.filtered(lambda m: m.bom_line_id.bom_id.product_tmpl_id.id == product.product_tmpl_id.id)
return res
def _generate_analytic_lines_data(self, unit_amount, amount):
vals = super()._generate_analytic_lines_data(unit_amount, amount)
if self.raw_material_production_id.analytic_account_id:
vals['name'] = _('[Raw] %s', self.product_id.display_name)
vals['ref'] = self.raw_material_production_id.display_name
vals['category'] = 'manufacturing_order'
return vals
def _get_analytic_account(self):
account = self.raw_material_production_id.analytic_account_id
if account:
return account
return super()._get_analytic_account()
def _get_src_account(self, accounts_data):
if not self.unbuild_id:
return super()._get_src_account(accounts_data)
else:
return self.location_dest_id.valuation_out_account_id.id or accounts_data['stock_input'].id
def _get_dest_account(self, accounts_data):
if not self.unbuild_id:
return super()._get_dest_account(accounts_data)
else:
return self.location_id.valuation_in_account_id.id or accounts_data['stock_output'].id
def _is_returned(self, valued_type):
if self.unbuild_id:
return True
return super()._is_returned(valued_type)
def _should_force_price_unit(self):
def _get_value_from_production(self, quantity, at_date=None):
# TODO: Maybe move _cal_price here
self.ensure_one()
return self.picking_type_id.code == 'mrp_operation' or super()._should_force_price_unit()
if not self.production_id:
return super()._get_value_from_production(quantity, at_date)
value = quantity * self.price_unit
return {
'value': value,
'quantity': quantity,
'description': self.env._('%(value)s for %(quantity)s %(unit)s from %(production)s',
value=self.company_currency_id.format(value), quantity=quantity, unit=self.product_id.uom_id.name,
production=self.production_id.display_name),
}
def _ignore_automatic_valuation(self):
return bool(self.raw_material_production_id)
def _get_all_related_sm(self, product):
moves = super()._get_all_related_sm(product)
return moves | self.filtered(
lambda m:
m.bom_line_id.bom_id.type == 'phantom' and
m.bom_line_id.bom_id == moves.bom_line_id.bom_id
)
def _get_kit_price_unit(self, product, kit_bom, valuated_quantity):
""" Override the value for kit products """
_dummy, exploded_lines = kit_bom.explode(product, valuated_quantity)
total_price_unit = 0
component_qty_per_kit = defaultdict(float)
for line in exploded_lines:
component_qty_per_kit[line[0].product_id] += line[1]['qty']
for component, valuated_moves in self.grouped('product_id').items():
price_unit = super(StockMove, valuated_moves)._get_price_unit()
qty_per_kit = component_qty_per_kit[component] / kit_bom.product_qty
total_price_unit += price_unit * qty_per_kit
return total_price_unit / valuated_quantity if not product.uom_id.is_zero(valuated_quantity) else 0