diff --git a/stock_usability/procurement.py b/stock_usability/procurement.py index 9c3cf01..ee6c112 100644 --- a/stock_usability/procurement.py +++ b/stock_usability/procurement.py @@ -1,26 +1,9 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Procurement Usability module for Odoo -# Copyright (C) 2015 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields +from odoo import models, fields, api from datetime import datetime import logging @@ -30,15 +13,14 @@ logger = logging.getLogger(__name__) class ProcurementOrder(models.Model): _inherit = 'procurement.order' + @api.model def _procure_orderpoint_confirm( - self, cr, uid, use_new_cursor=False, company_id=False, - context=None): + self, use_new_cursor=False, company_id=False): logger.info( 'procurement scheduler: START to create procurements from ' 'orderpoints') res = super(ProcurementOrder, self)._procure_orderpoint_confirm( - cr, uid, use_new_cursor=use_new_cursor, company_id=company_id, - context=context) + use_new_cursor=use_new_cursor, company_id=company_id) logger.info( 'procurement scheduler: END creation of procurements from ' 'orderpoints') @@ -46,38 +28,36 @@ class ProcurementOrder(models.Model): # Why is this code in stock_usability and not in procurement_usability ? # For a very good reason - # The stock module inherits run_scheduler(). So, if we want to have the START and - # END log message and a good end date for procurement.scheduler.log - # the method below must be called first, so we must be "above" all - # modules that call run_scheduler() + # The stock module inherits run_scheduler(). So, if we want to have the + # START and END log message and a good end date + # for procurement.scheduler.log, the method below must be called first, + # so we must be "above" all modules that call run_scheduler() + @api.model def run_scheduler( - self, cr, uid, use_new_cursor=False, company_id=False, - context=None): + self, use_new_cursor=False, company_id=False): '''Inherit to add info logs''' logger.info( 'START procurement scheduler ' '(company ID=%d, uid=%d, use_new_cursor=%s)', - company_id, uid, use_new_cursor) + company_id, self._uid, use_new_cursor) start_datetime = datetime.now() res = super(ProcurementOrder, self).run_scheduler( - cr, uid, use_new_cursor=use_new_cursor, company_id=company_id, - context=context) + use_new_cursor=use_new_cursor, company_id=company_id) logger.info( 'END procurement scheduler ' '(company ID=%d, uid=%d, use_new_cursor=%s)', - company_id, uid, use_new_cursor) + company_id, self._uid, use_new_cursor) try: # I put it in a try/except, to be sure that, even if the user # the execute the scheduler doesn't have create right on # procurement.scheduler.log - self.pool['procurement.scheduler.log'].create( - cr, uid, { - 'company_id': company_id, - 'start_datetime': start_datetime, - }, context=context) + self.env['procurement.scheduler.log'].create({ + 'company_id': company_id, + 'start_datetime': start_datetime, + }) # If I don't do an explicit cr.commit(), it doesn't create # the procurement.scheduler.log... I don't know why - cr.commit() + self._cr.commit() except: logger.warning('Could not create procurement.scheduler.log') return res diff --git a/stock_usability/procurement_view.xml b/stock_usability/procurement_view.xml index 46d96ba..9d78375 100644 --- a/stock_usability/procurement_view.xml +++ b/stock_usability/procurement_view.xml @@ -1,22 +1,25 @@ - - - + stock_usability.procurement.group.form procurement.group - + + + + + + @@ -31,7 +34,7 @@ - + @@ -59,5 +62,4 @@ action="procurement_scheduler_log_action" parent="stock.menu_stock_sched" sequence="22"/> - - + diff --git a/stock_usability/stock.py b/stock_usability/stock.py index c6496f7..39a5657 100644 --- a/stock_usability/stock.py +++ b/stock_usability/stock.py @@ -49,6 +49,10 @@ class StockLocationRoute(models.Model): class StockWarehouseOrderpoint(models.Model): _inherit = 'stock.warehouse.orderpoint' + # This SQL constraint blocks the use of the "active" field + # but I think it's not very useful to have such an "active" field + # on orderpoints ; when you think the order point is bad, you update + # the min/max values, you don't de-active it ! _sql_constraints = [( 'company_wh_location_product_unique', 'unique(company_id, warehouse_id, location_id, product_id)', @@ -68,12 +72,13 @@ class StockMove(models.Model): # availability = fields.Float( # digits=dp.get_precision('Product Unit of Measure')) - def name_get(self, cr, uid, ids, context=None): + @api.multi + def name_get(self): '''name_get of stock_move is important for the reservation of the quants: so want to add the name of the customer and the expected date in it''' res = [] - for line in self.browse(cr, uid, ids, context=context): + for line in self: name = line.location_id.name + ' > ' + line.location_dest_id.name if line.product_id.code: name = line.product_id.code + ': ' + name @@ -88,13 +93,6 @@ class StockMove(models.Model): return res -class StockQuant(models.Model): - _inherit = 'stock.quant' - - uom_id = fields.Many2one( - 'product.uom', related='product_id.uom_id', readonly=True) - - class StockIncoterms(models.Model): _inherit = 'stock.incoterms' diff --git a/stock_usability/stock_view.xml b/stock_usability/stock_view.xml index 0184e9a..270ceed 100644 --- a/stock_usability/stock_view.xml +++ b/stock_usability/stock_view.xml @@ -1,13 +1,11 @@ - - - + @@ -18,8 +16,8 @@ {} - - + + "{'group_by': 'min_date:day'}" - - - @@ -98,11 +96,14 @@ stock.move + @@ -128,6 +129,7 @@ stock.move + @@ -148,6 +150,8 @@ + + stock.usability.warehouse.form stock.warehouse - + - + - + stock.location - + - - - - - - Push Rules - stock.location.path - tree,form - - - - - - - stock.usability.transfer_details.form - stock.transfer_details - - - - Total - + @@ -235,39 +216,10 @@ in the quantities for his reception --> Total Qty - - - - - - - - stock.usability.quant.form - stock.quant - - - - - - - - - - stock.usability.stock.move.tree2 - stock.move - - - - 0 - + +--> + - - stock_usability.procurement.group.form - procurement.group - - - - - - - - - - - - +