flectra/addons/stock/wizard/stock_warn_insufficient_qty.py
2018-01-16 02:34:37 -08:00

35 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra import api, fields, models
from flectra.tools import float_compare
class StockWarnInsufficientQty(models.AbstractModel):
_name = 'stock.warn.insufficient.qty'
product_id = fields.Many2one('product.product', 'Product', required=True)
location_id = fields.Many2one( 'stock.location', 'Location', domain="[('usage', '=', 'internal')]", required=True)
quant_ids = fields.Many2many('stock.quant', compute='_compute_quant_ids')
@api.one
@api.depends('product_id')
def _compute_quant_ids(self):
self.quant_ids = self.env['stock.quant'].search([
('product_id', '=', self.product_id.id),
('location_id.usage', '=', 'internal')
])
def action_done(self):
raise NotImplementedError()
class StockWarnInsufficientQtyScrap(models.TransientModel):
_name = 'stock.warn.insufficient.qty.scrap'
_inherit = 'stock.warn.insufficient.qty'
scrap_id = fields.Many2one('stock.scrap', 'Scrap')
def action_done(self):
return self.scrap_id.do_scrap()