From 2f7265eadab35ba5c5522725976063f14fb43fc4 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sat, 12 Sep 2015 22:30:01 +0200 Subject: [PATCH] [IMP] procurement_jit: validates sales order picking automatically --- addons/procurement_jit/__init__.py | 1 + addons/procurement_jit/__openerp__.py | 2 +- addons/procurement_jit/procurement_jit.py | 9 --------- addons/procurement_jit/sale.py | 17 +++++++++++++++++ addons/sale_stock/sale_stock.py | 1 - 5 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 addons/procurement_jit/sale.py diff --git a/addons/procurement_jit/__init__.py b/addons/procurement_jit/__init__.py index 029aed6db76..93f0b78639b 100644 --- a/addons/procurement_jit/__init__.py +++ b/addons/procurement_jit/__init__.py @@ -2,3 +2,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import procurement_jit +import sale diff --git a/addons/procurement_jit/__openerp__.py b/addons/procurement_jit/__openerp__.py index c344e90a268..a6faf73dd69 100644 --- a/addons/procurement_jit/__openerp__.py +++ b/addons/procurement_jit/__openerp__.py @@ -21,7 +21,7 @@ as possible and the scheduler time range is not taken into account anymore. In that case, you can not use priorities any more on the different picking. """, 'website': 'https://www.odoo.com/page/manufacturing', - 'depends': ['procurement', 'stock'], + 'depends': ['sale_stock'], 'data': [], 'demo': [], 'test': ['test/procurement_jit.yml'], diff --git a/addons/procurement_jit/procurement_jit.py b/addons/procurement_jit/procurement_jit.py index a3cf916a036..b48ad5f937b 100644 --- a/addons/procurement_jit/procurement_jit.py +++ b/addons/procurement_jit/procurement_jit.py @@ -21,12 +21,3 @@ class procurement_order(osv.osv): return result return res -# TODO FP: This code should be uncommented to assign delivery orders directly -# Vut there is code to fix in stock.py before, to not have purchase tests that fails -# class stock_move(osv.osv): -# _inherit = "stock.move" -# -# def action_confirm(self, cr, uid, ids, context=None): -# res = super(stock_move, self).action_confirm(cr, uid, ids, context=context or {}) -# super(stock_move, self).action_assign(cr, uid, ids, context=context or {}) -# return res diff --git a/addons/procurement_jit/sale.py b/addons/procurement_jit/sale.py new file mode 100644 index 00000000000..bff11a5524e --- /dev/null +++ b/addons/procurement_jit/sale.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from openerp import api, fields, models, _ + +class SaleOrder(models.Model): + _inherit = "sale.order" + + @api.multi + def action_confirm(self): + res = super(SaleOrder, self).action_confirm() + for order in self: + for pick in order.picking_ids: + print pick.state + order.picking_ids.filtered(lambda x: x.state=='confirmed').action_assign() + return res + diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 9b9c4900e0d..04006e46e5e 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -86,7 +86,6 @@ class SaleOrder(models.Model): res.update({'move_type': self.picking_policy, 'partner_id': self.partner_shipping_id.id}) return res - class SaleOrderLine(models.Model): _inherit = 'sale.order.line'