2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-16 11:34:37 +01:00
|
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
2018-01-16 06:58:15 +01:00
|
|
|
|
2018-01-16 11:34:37 +01:00
|
|
|
from flectra import api, fields, models
|
|
|
|
from flectra.tools import float_compare
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
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()
|