19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:47 +01:00
parent accf5918df
commit 6e65e8c877
688 changed files with 225434 additions and 199401 deletions

View file

@ -2,5 +2,5 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import stock_picking_return
from . import mrp_consumption_warning
from . import change_production_qty
from . import mrp_production_serial_numbers

View file

@ -11,12 +11,3 @@ class ChangeProductionQty(models.TransientModel):
def _need_quantity_propagation(self, move, qty):
res = super()._need_quantity_propagation(move, qty)
return res and not any(m.is_subcontract for m in move.move_dest_ids)
@api.model
def _update_product_qty(self, move, qty):
res = super()._update_product_qty(move, qty)
subcontract_moves = move.move_dest_ids.filtered(lambda m: m.is_subcontract and m.from_immediate_transfer)
if subcontract_moves:
subcontract_moves[0].with_context(cancel_backorder=False).write({'product_uom_qty': subcontract_moves[0].product_uom_qty + qty})
return res

View file

@ -1,19 +0,0 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class MrpConsumptionWarning(models.TransientModel):
_inherit = 'mrp.consumption.warning'
def action_confirm(self):
if self.mrp_production_ids._get_subcontract_move():
return self.mrp_production_ids.with_context(skip_consumption=True).subcontracting_record_component()
return super().action_confirm()
def action_cancel(self):
mo_subcontracted_move = self.mrp_production_ids._get_subcontract_move()
if mo_subcontracted_move:
return mo_subcontracted_move.filtered(lambda move: move.state not in ('done', 'cancel'))._action_record_components()
return super().action_cancel()

View file

@ -0,0 +1,48 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class MrpProductionSerials(models.TransientModel):
_inherit = 'mrp.production.serials'
def action_apply(self):
self.ensure_one()
sbc_move = self.production_id._get_subcontract_move()
if not sbc_move or not self.serial_numbers:
return super().action_apply()
lots = list(filter(lambda serial_number: len(serial_number.strip()) > 0, self.serial_numbers.split('\n'))) if self.serial_numbers else []
existing_lots = self.env['stock.lot'].search([
'|', ('company_id', '=', False), ('company_id', '=', self.production_id.company_id.id),
('product_id', '=', self.production_id.product_id.id),
('name', 'in', lots),
])
existing_lot_names = existing_lots.mapped('name')
new_lots = []
sequence = self.production_id.product_id.lot_sequence_id
for lot_name in sorted(lots):
if lot_name in existing_lot_names:
continue
if sequence and lot_name == sequence.get_next_char(sequence.number_next_actual):
sequence.sudo().number_next_actual += 1
new_lots.append({
'name': lot_name,
'product_id': self.production_id.product_id.id
})
all_lots = existing_lots + self.env['stock.lot'].create(new_lots)
self.production_id.with_context(mrp_subcontracting=True).write({
'lot_producing_ids': all_lots[0],
'product_qty': 1,
})
picking = sbc_move.picking_id
sbc_move.move_line_ids.create([
{
'product_id': lot.product_id.id,
'lot_id': lot.id,
'move_id': sbc_move.id,
'picking_id': picking.id,
'quantity': 1,
} for lot in all_lots[1:]
])
return picking.action_show_subcontract_details()

View file

@ -4,26 +4,22 @@
from odoo import api, models, fields
class ReturnPicking(models.TransientModel):
class StockReturnPicking(models.TransientModel):
_inherit = 'stock.return.picking'
subcontract_location_id = fields.Many2one('stock.location', compute='_compute_subcontract_location_id')
def _prepare_picking_default_values(self):
vals = super()._prepare_picking_default_values()
if all(return_line.quantity > 0 and return_line.move_id.is_subcontract for return_line in self.product_return_moves):
vals['location_dest_id'] = self.picking_id.partner_id.with_company(self.picking_id.company_id).property_stock_subcontractor.id
return vals
@api.depends('picking_id')
def _compute_subcontract_location_id(self):
for record in self:
record.subcontract_location_id = record.picking_id.partner_id.with_company(
record.picking_id.company_id
).property_stock_subcontractor
@api.onchange('picking_id')
def _onchange_picking_id(self):
res = super(ReturnPicking, self)._onchange_picking_id()
if any(return_line.quantity > 0 and return_line.move_id.is_subcontract for return_line in self.product_return_moves):
self.location_id = self.picking_id.partner_id.with_company(self.picking_id.company_id).property_stock_subcontractor
return res
class StockReturnPickingLine(models.TransientModel):
_inherit = 'stock.return.picking.line'
def _prepare_move_default_values(self, return_line, new_picking):
vals = super(ReturnPicking, self)._prepare_move_default_values(return_line, new_picking)
def _prepare_move_default_values(self, new_picking):
vals = super()._prepare_move_default_values(new_picking)
if self.move_id.is_subcontract:
vals['location_dest_id'] = new_picking.partner_id.with_company(new_picking.company_id).property_stock_subcontractor.id
vals['is_subcontract'] = False
return vals

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_stock_return_picking_form_subcontracting" model="ir.ui.view">
<field name="name">Return lines</field>
<field name="model">stock.return.picking</field>
<field name="inherit_id" ref="stock.view_stock_return_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='location_id']" position="before">
<field name="subcontract_location_id" invisible="1"/>
<field name="original_location_id" invisible="1"/>
</xpath>
<xpath expr="//field[@name='location_id']" position="attributes">
<attribute name="domain">
['|', '|', ('id', '=', original_location_id), ('return_location', '=', True), ('id', '=', subcontract_location_id)]
</attribute>
</xpath>
</field>
</record>
</odoo>