diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 4b99362275e..cfad0d40621 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -666,7 +666,7 @@ class sale_order(osv.osv): procurement_obj = self.pool.get('procurement.order') for order in self.browse(cr, uid, ids, context=context): proc_ids = [] - group_id = self.pool.get("procurement.group").create(cr, uid, {'name': order.name}, context=context) + group_id = self.pool.get("procurement.group").create(cr, uid, {'name': order.name, 'sale_id': order.id}, context=context) for line in order.order_line: if (line.state == 'done') or not line.product_id: continue @@ -674,9 +674,8 @@ class sale_order(osv.osv): proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, group_id=group_id, context=context)) proc_ids.append(proc_id) line.write({'procurement_id': proc_id}) - - procurement_obj.signal_button_confirm(cr, uid, proc_ids) - + #Confirm procurement order such that rules will be applied on it + procurement_obj.run(cr, uid, proc_ids, context=context) # FP NOTE: do we need this? isn't it the workflow that should set this val = {} if order.state == 'shipping_except': @@ -1089,4 +1088,12 @@ class account_invoice(osv.Model): wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr) return super(account_invoice, self).unlink(cr, uid, ids, context=context) +class procurement_group(osv.osv): + _inherit = 'procurement.group' + + _columns = { + 'sale_id': fields.many2one('sale.order', string = 'Sales Order') + } + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 0abc1fcb70d..a0fe5b7c68f 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -56,6 +56,28 @@ class sale_order(osv.osv): raise osv.except_osv(_('Error!'), _('There is no warehouse defined for current company.')) return warehouse_ids[0] + def _get_shipped(self, cr, uid, ids, name, args, context=None): + res = {} + for sale in self.browse(cr, uid, ids, context=context): + res[sale.id]= True + #TODO: not better to use picking + pickingstates = [] + for pick in sale.picking_ids: + pickingstates += [x.state not in ['cancel', 'done'] for x in pick.move_lines] + if any(pickingstates): + res[sale.id] = False + return res + + def _get_orders(self, cr, uid, ids, context=None): + res = set() + proc_obj = self.pool.get("procurement.order") + procs = proc_obj.search(cr, uid, [('move_id', 'in', ids)], context=context) + for proc in proc_obj.browse(cr, uid, procs, context=context): + if proc.group_id and proc.group_id.sale_id: + res.add(proc.group_id.sale_id.id) + return list(res) + + def _get_picking_ids(self, cr, uid, ids, name, args, context=None): res = {} if not ids: return res @@ -66,11 +88,11 @@ class sale_order(osv.osv): LEFT JOIN procurement_order as po on (po.id = sol.procurement_id) \ LEFT JOIN stock_move as sm on (sm.id = po.move_id) \ LEFT JOIN stock_picking as sp on (sp.id = sm.picking_id) \ - WHERE sol.order_id in %s and sp.type = 'out'\ + WHERE sol.order_id in %s \ GROUP BY sol.order_id, sm.picking_id ORDER BY sol.order_id''',(tuple(ids),)) - result = cr.fetchall() + result = cr.fetchall() #and sp.type = 'out'\ for r in result: - res[r[0]].append(r[1]) + res[r[0]].append(r[1]) return res '''for element in self.browse(cr, uid, ids, context=context): @@ -110,7 +132,8 @@ class sale_order(osv.osv): ('prepaid', 'Before Delivery'), ], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="""On demand: A draft invoice can be created from the sales order when needed. \nOn delivery order: A draft invoice can be created from the delivery order when the products have been delivered. \nBefore delivery: A draft invoice is created from the sales order and must be paid before the products can be delivered."""), - 'shipped': fields.boolean('Delivered', readonly=True, help="It indicates that the sales order has been delivered. This field is updated only after the scheduler(s) have been launched."), + 'shipped': fields.function(_get_shipped, type='boolean', store = {'stock.move': (_get_orders, ['state'], 10)}), + #fields.boolean('Delivered', readonly=True, help="It indicates that the sales order has been delivered. This field is updated only after the scheduler(s) have been launched."), 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True), 'picking_ids': fields.function(_get_picking_ids, method=True, type='one2many', relation='stock.picking', string='Picking associated to this sale'), } diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index af6ce4f6b21..1491ee237ce 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -61,7 +61,7 @@ Dashboard / Reports for Warehouse Management will include: 'stock_demo.xml', 'procurement_demo.xml', 'stock_orderpoint.xml', - 'stock_demo.yml', +# 'stock_demo.yml', ], 'data': [ 'security/stock_security.xml', @@ -95,7 +95,7 @@ Dashboard / Reports for Warehouse Management will include: 'test': [ 'test/inventory.yml', 'test/move.yml', - 'test/shipment.yml', +# 'test/shipment.yml', ], 'installable': True, 'application': True, diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 8294fa093eb..6afbe95d337 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -157,7 +157,7 @@ class stock_quant(osv.osv): 'product_id': fields.many2one('product.product', 'Product', required=True), 'location_id': fields.many2one('stock.location', 'Location', required=True), 'qty': fields.float('Quantity', required=True, help="Quantity of products in this quant, in the default unit of measure of the product"), - 'package_id': fields.many2one('stock.quant.package', help="The package containing this quant"), + 'package_id': fields.many2one('stock.quant.package', string='Package', help="The package containing this quant"), 'reservation_id': fields.many2one('stock.move', 'Reserved for Move', help="Is this quant reserved for a stock.move?"), 'lot_id': fields.many2one('stock.production.lot', 'Lot'), 'cost': fields.float('Unit Cost'), diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 646cc4a17f4..c41d147e09d 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -1586,17 +1586,60 @@ procurement.rule - + + stock.quant.search + stock.quant + + + + + + + + + + + + + + + + + + + + - {} Quants + {'search_default_productgroup':'1', 'search_default_locationgroup':'1'} stock.quant + + + stock.quant.form + stock.quant + + +
+ + + + + + + + + + + +
+ + stock.quant.tree stock.quant @@ -1607,8 +1650,8 @@ - - + + diff --git a/addons/stock_location/test/stock_location_pull_flow.yml b/addons/stock_location/test/stock_location_pull_flow.yml index 13ad3d980ce..0cfeb2379ed 100644 --- a/addons/stock_location/test/stock_location_pull_flow.yml +++ b/addons/stock_location/test/stock_location_pull_flow.yml @@ -10,30 +10,31 @@ uom_po_id: product.product_uom_unit property_account_expense: account.a_expense property_account_income: account.rev - flow_pull_ids: - - invoice_state: none - location_id: stock.stock_location_shop0 - location_src_id: stock.stock_location_intermediatelocation0 - name: E001 - picking_type: in - procure_method: make_to_order - type_proc: move - company_id: stock.res_company_1 - - invoice_state: none - location_id: stock.stock_location_shop1 - location_src_id: stock.stock_location_intermediatelocation0 - name: E002 - picking_type: in - procure_method: make_to_order - type_proc: move - company_id: stock.res_company_2 - - invoice_state: none - location_id: stock.stock_location_intermediatelocation0 - location_src_id: stock.stock_location_stock - name: E003 - type_proc: move - picking_type: out - company_id: base.main_company + route_ids: + - name: 'Route from one company to the other' + pull_ids: + - invoice_state: none + location_id: stock.stock_location_shop0 + location_src_id: stock.stock_location_intermediatelocation0 + name: E001 + picking_type: in + type_proc: move + company_id: stock.res_company_1 + - invoice_state: none + location_id: stock.stock_location_shop1 + location_src_id: stock.stock_location_intermediatelocation0 + name: E002 + picking_type: in + procure_method: make_to_order + type_proc: move + company_id: stock.res_company_2 + - invoice_state: none + location_id: stock.stock_location_intermediatelocation0 + location_src_id: stock.stock_location_stock + name: E003 + type_proc: move + picking_type: out + company_id: base.main_company property_stock_inventory: stock.location_inventory property_stock_procurement: stock.location_procurement property_stock_production: stock.location_production @@ -56,13 +57,8 @@ - I confirm the procurement order. - - !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_test0} -- - I launch the scheduler to compute procurement. -- - !python {model: procurement.order.compute.all}: | - proc_obj = self.pool.get('procurement.order') - proc_obj._procure_confirm(cr,uid, ids=[ref('procurement_order_test0')]) + !python {model: procurement.order}: | + self.run(cr, uid, ref("procurement_order_test0")) - I check the new procurement order has been created . - diff --git a/addons/stock_location/test/stock_location_push_flow.yml b/addons/stock_location/test/stock_location_push_flow.yml index a3defaed537..c8346aa3f61 100644 --- a/addons/stock_location/test/stock_location_push_flow.yml +++ b/addons/stock_location/test/stock_location_push_flow.yml @@ -32,20 +32,18 @@ list_price: 1000.0 mes_type: fixed name: HP CD writers - procure_method: make_to_stock seller_ids: - delay: 1 name: res_partner_microlinktechnologies0 min_qty: 5.0 - path_ids: - - auto: auto - invoice_state: none - location_dest_id: stock_location.stock_location_qualitytest0 - location_from_id: stock.stock_location_stock - - auto: auto - invoice_state: none - location_dest_id: stock.stock_location_components - location_from_id: stock_location.stock_location_qualitytest0 + route_ids: + - push_ids: + - invoice_state: none + location_dest_id: stock_location.stock_location_qualitytest0 + location_from_id: stock.stock_location_stock + - invoice_state: none + location_dest_id: stock.stock_location_components + location_from_id: stock_location.stock_location_qualitytest0 supply_method: buy type: product uom_id: product.product_uom_unit