product_warehouse_quantity.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. #################################################################################
  3. #
  4. # Odoo, Open Source Management Solution
  5. # Copyright (C) 2017 Ascetic Business Solution <www.asceticbs.com>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. #################################################################################
  21. from openerp import models, fields, api, exceptions
  22. from openerp.tools.translate import _
  23. class SaleProductWarehouseQuantity(models.TransientModel):
  24. _name = "sale.product.warehouse.quantity"
  25. _description = "Sales Product Warehouse Quantity"
  26. def _default_warehouse_quantity(self):
  27. if self.env.context.get('active_model', '') == 'sale.order.line':
  28. ids = self.env.context['active_ids']
  29. order_lines = self.env['sale.order.line'].browse(ids)
  30. if order_lines:
  31. for line in order_lines:
  32. warehouse_quantity = line.warehouse_quantity
  33. return warehouse_quantity
  34. warehouse_quantity = fields.Char(string = 'Stock Quantity per Warehouse', default=_default_warehouse_quantity, required=True, readonly=True)