This commit is contained in:
2026-04-26 11:30:59 +02:00
parent 530f2f9d97
commit e40a32e796

View File

@@ -2898,17 +2898,21 @@ class LotInvoiceStart(ModelView):
}) })
@fields.depends('type') @fields.depends('type')
def on_change_with_action(self, name=None): def on_change_with_action(self, name=None):
if self.lot_p and self.type == 'purchase': if self.lot_p and self.type == 'purchase':
if self.lot_p[0].lot.line.purchase.wb.qt_type in [e.quantity_type for e in self.lot_p[0].lot.lot_hist]: purchase = getattr(getattr(self.lot_p[0].lot, 'line', None), 'purchase', None)
return 'final' wb = getattr(purchase, 'wb', None)
else: if wb and wb.qt_type in [e.quantity_type for e in self.lot_p[0].lot.lot_hist]:
return 'prov' return 'final'
if self.lot_s and self.type == 'sale': else:
if self.lot_s[0].lot.sale_line.sale.wb.qt_type in [e.quantity_type for e in self.lot_s[0].lot.lot_hist]: return 'prov'
return 'final' if self.lot_s and self.type == 'sale':
else: sale = getattr(getattr(self.lot_s[0].lot, 'sale_line', None), 'sale', None)
return 'prov' wb = getattr(sale, 'wb', None)
if wb and wb.qt_type in [e.quantity_type for e in self.lot_s[0].lot.lot_hist]:
return 'final'
else:
return 'prov'
@fields.depends('lot_p','type','quantity') @fields.depends('lot_p','type','quantity')
def on_change_with_quantity(self, name=None): def on_change_with_quantity(self, name=None):