extended warning when lot already has been used.
(sequence in stock.move derived from sale_order_line)develop
parent
eefe70e33e
commit
73dd7ec7c3
|
|
@ -19,7 +19,9 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from odoo import fields, models, api, tools
|
from odoo import fields, models, api, tools, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tools.float_utils import float_compare, float_is_zero
|
||||||
|
|
||||||
|
|
||||||
class StockProductionLot(models.Model):
|
class StockProductionLot(models.Model):
|
||||||
|
|
@ -61,18 +63,26 @@ class StockPicking(models.Model):
|
||||||
res = lang_obj.format('%.' + str(2) + 'f', value, grouping=True, monetary=True)
|
res = lang_obj.format('%.' + str(2) + 'f', value, grouping=True, monetary=True)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
class StockMove(models.Model):
|
class StockMove(models.Model):
|
||||||
_inherit = "stock.move"
|
_inherit = "stock.move"
|
||||||
|
|
||||||
manu_lots_visible = fields.Boolean(compute='_compute_manu_lots_visible')
|
manu_lots_visible = fields.Boolean(compute='_compute_manu_lots_visible')
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
res = super(StockMove, self).create(vals)
|
||||||
|
for move in res:
|
||||||
|
move.update({'sequence': move.sale_line_id.sequence,})
|
||||||
|
return res
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
|
def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
vals = super(StockMove, self)._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant)
|
vals = super(StockMove, self)._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant)
|
||||||
if self.sale_line_id.lot_id and not self.sale_line_id.product_id.can_be_sold_unconfigured:
|
if self.sale_line_id.lot_id and not self.sale_line_id.product_id.can_be_sold_unconfigured:
|
||||||
move_lot = self.sale_line_id.lot_id.id
|
move_lot = self.sale_line_id.lot_id.id
|
||||||
vals.update({'lot_id': move_lot, })
|
vals.update({'lot_id': move_lot,})
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
def _compute_manu_lots_visible(self):
|
def _compute_manu_lots_visible(self):
|
||||||
|
|
@ -99,3 +109,20 @@ class StockMove(models.Model):
|
||||||
move.weight += (move.product_qty * move.product_id.weight)
|
move.weight += (move.product_qty * move.product_id.weight)
|
||||||
|
|
||||||
# print(move.weight)
|
# print(move.weight)
|
||||||
|
|
||||||
|
|
||||||
|
class StockQuant(models.Model):
|
||||||
|
_inherit = "stock.quant"
|
||||||
|
|
||||||
|
@api.constrains('quantity')
|
||||||
|
def check_quantity(self):
|
||||||
|
info = ''
|
||||||
|
for quant in self:
|
||||||
|
if float_compare(quant.quantity, 1, precision_rounding=quant.product_uom_id.rounding) > 0 and quant.lot_id and quant.product_id.tracking == 'serial':
|
||||||
|
smls = self.env['stock.move.line'].search([('lot_id', '=', quant.lot_id.id)])
|
||||||
|
for sml in smls:
|
||||||
|
sm = self.env['stock.move'].search([('id', '=', sml.move_id.id)])
|
||||||
|
info += '\n %s; %s; %s: %s' % (sm.origin,sm.reference,sm.sequence,quant.lot_id.name)
|
||||||
|
|
||||||
|
if info:
|
||||||
|
raise ValidationError(_('A serial number should only be linked to a single product.') + info)
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,9 @@
|
||||||
<strong>Voraussichtliches Lieferdatum:</strong>
|
<strong>Voraussichtliches Lieferdatum:</strong>
|
||||||
<span t-field="order_line.delivery_date"/>
|
<span t-field="order_line.delivery_date"/>
|
||||||
</t>
|
</t>
|
||||||
|
<p t-if="order_line.lot_id">
|
||||||
|
<span t-esc="order_line.lot_id.name.split('.')[2]"/>
|
||||||
|
</p>
|
||||||
-->
|
-->
|
||||||
<p t-if="order_line.lot_id.notes">
|
<p t-if="order_line.lot_id.notes">
|
||||||
<span t-field="order_line.lot_id.notes"/>
|
<span t-field="order_line.lot_id.notes"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue