diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 6e9ebc0068e..3ea85fc0d73 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -123,10 +123,9 @@
-
Reception is ready for process so now done the reception.
-
- !python {model: stock.partial.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001")).picking_ids
- partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ picking_id = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001")).picking_ids[0]
+ picking_id.do_partial(context=context)
-
I check the Stock Interim account (Received) is credited successfully.
-
@@ -189,7 +188,6 @@
-
!record {model: stock.picking, id: stock_picking_out001}:
partner_id: base.res_partner_13
- invoice_state: 2binvoiced
move_lines:
- company_id: base.main_company
location_id: stock.stock_location_stock
@@ -198,29 +196,28 @@
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
move_type: direct
- type: out
+ picking_type_id: stock.picking_type_out
-
I need to check the availability of the product, So I make my picking order for processing later.
-
!python {model: stock.picking}: |
- self.draft_force_assign(cr, uid, [ref("stock_picking_out001")], {"lang": "en_US", "search_default_available":
- 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
- "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
- })
+ self.action_confirm(cr, uid, [ref('stock_picking_out001')], context=context)
+
-
I check the product availability, Product is available in the stock and ready to be sent.
-
!python {model: stock.picking}: |
- self.action_assign(cr, uid, [ref("stock_picking_out001")], {"lang": "en_US", "search_default_available":
- 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
- "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
- })
+ picking = self.browse(cr, uid, ref("stock_picking_out001"))
+ assert picking.state == "confirmed", "Picking should be confirmed."
+ for move_line in picking.move_lines:
+ assert move_line.state == "confirmed", "Move should be confirmed."
+
-
I process the delivery.
-
- !python {model: stock.partial.picking}: |
- partial_id = self.create(cr, uid, {}, context={'active_model':'stock.picking','active_ids':[ref('stock_picking_out001')]})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ picking = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001"))
+ picking.do_partial(context=context)
-
I check Stock Interim account (Delivery) is debited successfully.
-
diff --git a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
index f7d52f4f5a8..bb6200e148b 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -131,10 +131,9 @@
-
Reception is ready for process so now done the reception.
-
- !python {model: stock.partial.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo")).picking_ids
- partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ picking_id = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo")).picking_ids[0]
+ picking_id.do_partial(context=context)
-
I check the Stock Interim account (Received) is credit successfully.
-
@@ -192,7 +191,6 @@
-
!record {model: stock.picking, id: stock_picking_out001_fifo}:
partner_id: base.res_partner_13
- invoice_state: 2binvoiced
move_lines:
- company_id: base.main_company
location_id: stock.stock_location_stock
@@ -200,29 +198,26 @@
product_qty: 1.0
location_dest_id: stock.stock_location_customers
move_type: direct
- type: out
+ picking_type_id: stock.picking_type_out
-
I need to check the availability of the product, So I make my picking order for processing later.
-
!python {model: stock.picking}: |
- self.draft_force_assign(cr, uid, [ref("stock_picking_out001_fifo")], {"lang": "en_US", "search_default_available":
- 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
- "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
- })
+ self.action_confirm(cr, uid, [ref('stock_picking_out001')], context=context)
-
I check the product availability, Product is available in the stock and ready to be sent.
-
!python {model: stock.picking}: |
- self.action_assign(cr, uid, [ref("stock_picking_out001_fifo")], {"lang": "en_US", "search_default_available":
- 1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
- "active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
- })
+ picking = self.browse(cr, uid, ref("stock_picking_out001"))
+ assert picking.state == "confirmed", "Picking should be confirmed."
+ for move_line in picking.move_lines:
+ assert move_line.state == "confirmed", "Move should be confirmed."
-
I process the delivery.
-
- !python {model: stock.partial.picking}: |
- partial_id = self.create(cr, uid, {}, context={'active_model':'stock.picking','active_ids':[ref('stock_picking_out001_fifo')]})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ picking = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001_fifo"))
+ picking.do_partial(context=context)
-
I check Stock Interim account (Delivery) is debited successfully.
-
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index 2782f822149..591f65cf925 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -700,7 +700,7 @@ class pos_order(osv.osv):
picking_id = picking_obj.create(cr, uid, {
'origin': order.name,
'partner_id': addr.get('delivery',False),
- 'type': 'out',
+ 'picking_type_id': self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id,
'company_id': order.company_id.id,
'move_type': 'direct',
'note': order.note or "",
diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py
index eeba6cab676..fac55c593e7 100644
--- a/addons/point_of_sale/wizard/pos_return.py
+++ b/addons/point_of_sale/wizard/pos_return.py
@@ -213,7 +213,7 @@ class add_product(osv.osv_memory):
'name':'%s (Added)' %order_id.name,
'move_lines':[],
'state':'draft',
- 'type':'out',
+ 'picking_type_id': self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id,
'date':date_cur
})
stock_move_obj.create(cr, uid, {
diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py
index 56512be09da..a0bb133dd46 100644
--- a/addons/purchase/__openerp__.py
+++ b/addons/purchase/__openerp__.py
@@ -81,7 +81,6 @@ Dashboard / Reports for Purchase Management will include:
'test/ui/duplicate_order.yml',
'test/ui/delete_order.yml',
'test/average_price.yml',
- 'test/lifo_price.yml',
],
'demo': [
'purchase_order_demo.yml',
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 79df9f31103..660b70a488c 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -150,6 +150,10 @@ class purchase_order(osv.osv):
limit=1)
return res and res[0] or False
+ def _get_picking_in(self, cr, uid, context=None):
+ obj_data = self.pool.get('ir.model.data')
+ return obj_data.get_object_reference(cr, uid, 'stock','picking_type_in')[1]
+
STATE_SELECTION = [
('draft', 'Draft PO'),
('sent', 'RFQ Sent'),
@@ -230,6 +234,7 @@ class purchase_order(osv.osv):
'journal_id': fields.many2one('account.journal', 'Journal'),
'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"),
'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"),
+ 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This will determine picking type of incoming shipment"),
}
_defaults = {
'date_order': fields.date.context_today,
@@ -241,7 +246,8 @@ class purchase_order(osv.osv):
'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id,
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c),
'journal_id': _get_journal,
- 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
+ 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id,
+ 'picking_type_id': _get_picking_in,
}
_sql_constraints = [
('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'),
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index e3af7bd6243..973757770c4 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -198,6 +198,7 @@
+
diff --git a/addons/purchase/test/average_price.yml b/addons/purchase/test/average_price.yml
index 0fa2dfb0a4f..79bae838f7e 100644
--- a/addons/purchase/test/average_price.yml
+++ b/addons/purchase/test/average_price.yml
@@ -55,10 +55,9 @@
-
Process the reception of purchase order 1
-
- !python {model: stock.partial.picking}: |
+ !python {model: stock.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_average1")).picking_ids
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ self.do_partial(cr, uid, [pick_ids[0].id])
-
Check the standard price of the product (average icecream).
-
@@ -69,10 +68,9 @@
-
Process the reception of purchase order 2
-
- !python {model: stock.partial.picking}: |
+ !python {model: stock.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_average2")).picking_ids
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ self.do_partial(cr, uid, [pick_ids[0].id])
-
Check the standard price
-
@@ -82,7 +80,7 @@
Create picking to send some goods
-
!record {model: stock.picking, id: outgoing_average_shipment}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Create move for picking
-
@@ -91,18 +89,12 @@
product_id: product_average_icecream
product_uom: product.product_uom_kgm
product_qty: 20.0
- type: out
-
- I assign this outgoing shipment
+ I assign this outgoing shipment and process the delivery
-
!python {model: stock.picking}: |
self.action_assign(cr, uid, [ref("outgoing_average_shipment")])
--
- Process the delivery of the outgoing shipment
--
- !python {model: stock.partial.picking}: |
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_average_shipment")], 'default_type':'out'})
- self.do_partial(cr, uid, [partial_id])
+ self.do_partial(cr, uid, [ref("outgoing_average_shipment")])
-
Check the standard price (60 * 10 + 30 * 80) / 40 = 75.0 did not change
-
@@ -129,10 +121,9 @@
-
Process the reception of purchase order 3 in grams
-
- !python {model: stock.partial.picking}: |
+ !python {model: stock.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_average3")).picking_ids
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ self.do_partial(cr, uid, [pick_ids[0].id])
-
Check price is (75.0*20 + 500) / 20.5 = 97.56097561
-
diff --git a/addons/purchase/test/process/generate_invoice_from_reception.yml b/addons/purchase/test/process/generate_invoice_from_reception.yml
index 6390413b418..37cf615c6ec 100644
--- a/addons/purchase/test/process/generate_invoice_from_reception.yml
+++ b/addons/purchase/test/process/generate_invoice_from_reception.yml
@@ -11,9 +11,9 @@
-
Now I create an invoice for order on reception.
-
- !python {model: stock.picking}: |
- pick_ids = self.search(cr, uid, [('purchase_id','=',ref('purchase_order_2'))])
- self.action_invoice_create(cr, uid, pick_ids, ref('account.expenses_journal'))
+ !python {model: purchase.order}: |
+ pick_ids = [self.browse(cr, uid, ref("purchase_order_2")).id]
+ self.action_invoice_create(cr, uid, pick_ids)
-
I check that the invoice of order.
-
diff --git a/addons/purchase/test/process/rfq2order2done.yml b/addons/purchase/test/process/rfq2order2done.yml
index ff9158b3c09..a6999686026 100644
--- a/addons/purchase/test/process/rfq2order2done.yml
+++ b/addons/purchase/test/process/rfq2order2done.yml
@@ -45,10 +45,9 @@
-
Reception is ready for process so now done the reception.
-
- !python {model: stock.partial.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_1")).picking_ids
- partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_1")).picking_ids[0]
+ pick_ids.do_partial(context=context)
-
I check that purchase order is shipped.
-
diff --git a/addons/sale_stock/__init__.py b/addons/sale_stock/__init__.py
index 9c74739d4c9..72b3d5672d5 100644
--- a/addons/sale_stock/__init__.py
+++ b/addons/sale_stock/__init__.py
@@ -20,9 +20,7 @@
##############################################################################
import sale_stock
-import stock
import report
import company
import res_config
-import wizard
diff --git a/addons/sale_stock/__openerp__.py b/addons/sale_stock/__openerp__.py
index b1686bebb20..059c5a59c1d 100644
--- a/addons/sale_stock/__openerp__.py
+++ b/addons/sale_stock/__openerp__.py
@@ -51,7 +51,6 @@ You can choose flexible invoicing methods:
'security/sale_stock_security.xml',
'security/ir.model.access.csv',
'company_view.xml',
- 'wizard/stock_invoice_onshipping_view.xml',
'sale_stock_view.xml',
'sale_stock_workflow.xml',
'stock_view.xml',
diff --git a/addons/sale_stock/sale_stock_view.xml b/addons/sale_stock/sale_stock_view.xml
index 03731bd737c..9e14ce46ce1 100644
--- a/addons/sale_stock/sale_stock_view.xml
+++ b/addons/sale_stock/sale_stock_view.xml
@@ -104,21 +104,7 @@
groups="sale.group_delivery_invoice_address"
/>
-
- stock.picking.form.inherit
- stock.picking
-
-
-
-
-
-
-
-
-
-
- stock.picking.search.inherit
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index e28b4b066d4..f903d160400 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -31,20 +31,14 @@
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
order = self.browse(cr, uid, ref("sale.sale_order_6"))
for order_line in order.order_line:
- procurement = order_line.procurement_id
- sale_order_date = self.date_to_datetime(cr, uid, order.date_order, context)
- date_planned = datetime.strptime(sale_order_date, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=order_line.delay or 0.0)
+ procurement = order_line.procurement_ids[0]
+ date_planned = datetime.strptime(order.date_order, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=order_line.delay or 0.0)
date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
assert procurement.date_planned == date_planned, "Scheduled date is not correspond."
assert procurement.product_id.id == order_line.product_id.id, "Product is not correspond."
assert procurement.product_qty == order_line.product_uom_qty, "Qty is not correspond."
assert procurement.product_uom.id == order_line.product_uom.id, "UOM is not correspond."
- assert procurement.procure_method == order_line.type, "Procurement method is not correspond."
--
- I run the scheduler.
--
- !python {model: procurement.order}: |
- self.run_scheduler(cr, uid)
+ assert procurement.move_ids[0].procure_method == order_line.type, "Procurement method is not correspond."
-
I check the details of delivery order after confirmed quotation.
-
@@ -57,7 +51,7 @@
for picking in sale_order.picking_ids:
assert picking.state == "auto" or "confirmed", "Delivery order should be in 'Waitting Availability' state."
assert picking.origin == sale_order.name,"Origin of Delivery order is not correspond with sequence number of sale order."
- assert picking.type == 'out',"Shipment should be Outgoing."
+ assert picking.picking_type_id == self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context),"Shipment should be Outgoing."
assert picking.move_type == sale_order.picking_policy,"Delivery Method is not corresponding with delivery method of sale order."
assert picking.partner_id.id == sale_order.partner_shipping_id.id,"Shipping Address is not correspond with sale order."
assert picking.note == sale_order.note,"Note is not correspond with sale order."
@@ -66,9 +60,8 @@
location_id = sale_order.warehouse_id.lot_stock_id.id
output_id = sale_order.warehouse_id.lot_output_id.id
for move in picking.move_lines:
- order_line = move.sale_line_id
- sale_order_date = self.date_to_datetime(cr, uid, sale_order.date_order, context)
- date_planned = datetime.strptime(sale_order_date, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=order_line.delay or 0.0)
+ order_line = move.procurement_id.sale_line_id
+ date_planned = datetime.strptime(sale_order.date_order, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=order_line.delay or 0.0)
date_planned = (date_planned - timedelta(days=sale_order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
assert datetime.strptime(move.date_expected, DEFAULT_SERVER_DATETIME_FORMAT) == datetime.strptime(date_planned, DEFAULT_SERVER_DATETIME_FORMAT), "Excepted Date is not correspond with Planned Date."
assert move.product_id.id == order_line.product_id.id,"Product is not correspond."
@@ -84,13 +77,17 @@
-
Now, I dispatch delivery order.
-
- !python {model: stock.partial.picking}: |
+ !python {model: stock.picking}: |
order = self.pool.get('sale.order').browse(cr, uid, ref("sale.sale_order_6"))
for pick in order.picking_ids:
data = pick.force_assign()
if data == True:
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick.id]})
- self.do_partial(cr, uid, [partial_id])
+ pick.do_partial(context=context)
+-
+ I run the scheduler.
+-
+ !python {model: procurement.order}: |
+ self.run_scheduler(cr, uid)
-
I check sale order to verify shipment.
-
@@ -123,7 +120,7 @@
assert invoice.reference == order.client_order_ref or order.name,"Reference is not correspond."
assert invoice.partner_id.id == order.partner_invoice_id.id,"Customer does not correspond."
assert invoice.currency_id.id == order.pricelist_id.currency_id.id, "Currency is not correspond."
- assert invoice.comment == (order.note or ''),"Note is not correspond."
+ assert (invoice.comment or '') == (order.note or ''),"Note is not correspond."
assert invoice.journal_id.id in journal_ids,"Sales Journal is not link on Invoice."
assert invoice.payment_term.id == order.payment_term.id, "Payment term is not correspond."
for so_line in order.order_line:
diff --git a/addons/sale_stock/test/prepaid_order_policy.yml b/addons/sale_stock/test/prepaid_order_policy.yml
index e35a9a82cf9..38652cb165d 100644
--- a/addons/sale_stock/test/prepaid_order_policy.yml
+++ b/addons/sale_stock/test/prepaid_order_policy.yml
@@ -1,12 +1,27 @@
+-
+ In order to test the Prepaid Order Policy, I create a product
+-
+ !record {model: product.product, id: product_prepaid1}:
+ name: 'OpenERP Documentation Book'
+ list_price: 60.60
+-
+ Now i create a sale order that uses my new product
+-
+ !record {model: sale.order, id: sale_order_prepaid1}:
+ partner_id: base.res_partner_2
+ order_policy: prepaid
+ order_line:
+ - product_id: sale_stock.product_prepaid1
+ product_uom_qty: 10
-
Now I confirm the Quotation with "Pay before delivery" policy.
-
- !workflow {model: sale.order, action: order_confirm, ref: sale.sale_order_4}
+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_prepaid1}
-
I check that delivery order should not created before invoice is paid.
-
!python {model: sale.order}: |
- sale_order = self.browse(cr, uid, ref("sale.sale_order_4"))
+ sale_order = self.browse(cr, uid, ref("sale_order_prepaid1"))
assert len(sale_order.picking_ids) == False, "Delivery order should not created before invoice."
assert sale_order.invoice_ids, "Invoice should be created."
diff --git a/addons/sale_stock/wizard/__init__.py b/addons/sale_stock/wizard/__init__.py
deleted file mode 100644
index e32a95fef96..00000000000
--- a/addons/sale_stock/wizard/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# 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 .
-#
-##############################################################################
-
-import stock_invoice_onshipping
diff --git a/addons/sale_stock_location/sale_stock_location_view.xml b/addons/sale_stock_location/sale_stock_location_view.xml
index 0a8ad68f060..7fd0f1853b2 100644
--- a/addons/sale_stock_location/sale_stock_location_view.xml
+++ b/addons/sale_stock_location/sale_stock_location_view.xml
@@ -30,7 +30,10 @@
sale.order
-
+
+
+
+
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index 7f36871b9d1..392e65d1c91 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -40,7 +40,7 @@ class procurement_rule(osv.osv):
'location_id': fields.many2one('stock.location', 'Destination Location'),
'location_src_id': fields.many2one('stock.location', 'Source Location',
help="Source location is action=move"),
- 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True,
+ 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type',
help="Picking Type determines the way the picking should be shown in the view, reports, ...")
}
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index f4be5ee0bfa..740e60b9a50 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -318,8 +318,22 @@ class stock_quant(osv.osv):
def _price_update(self, cr, uid, quant, newprice, context=None):
self.write(cr, uid, [quant.id], {'cost': newprice}, context=context)
+ def write(self, cr, uid, ids, vals, context=None):
+ #We want to trigger the move with nothing on reserved_quant_ids for the store of the remaining quantity
+ if 'reservation_id' in vals:
+ reservation_ids = self.browse(cr, uid, ids, context=context)
+ moves_to_warn = set()
+ for reser in reservation_ids:
+ if reser.reservation_id:
+ moves_to_warn.add(reser.reservation_id.id)
+ self.pool.get('stock.move').write(cr, uid, list(moves_to_warn), {'reserved_quant_ids': []}, context=context)
+ return super(stock_quant, self).write(cr, uid, ids, vals, context=context)
+
def quants_unreserve(self, cr, uid, move, context=None):
- cr.execute('update stock_quant set reservation_id=NULL where reservation_id=%s', (move.id,))
+ #cr.execute('update stock_quant set reservation_id=NULL where reservation_id=%s', (move.id,))
+ #need write for related store of remaining qty
+ related_quants = self.search(cr, uid, [('reservation_id', '=', move.id)], context=context)
+ self.write(cr, uid, related_quants, {'reservation_id': False}, context=context)
return True
#
@@ -516,7 +530,8 @@ class stock_picking(osv.osv):
picking_obj = self.browse(cr, uid, id, context=context)
if ('name' not in default) or (picking_obj.name == '/'):
default['name'] = '/'
- default['backorder_id'] = False
+ if not default.get('backorder_id'):
+ default['backorder_id'] = False
return super(stock_picking, self).copy(cr, uid, id, default, context)
def action_confirm(self, cr, uid, ids, context=None):
@@ -610,16 +625,18 @@ class stock_picking(osv.osv):
backorder_moves = picking.move_lines
backorder_move_ids = [x.id for x in backorder_moves if x.state not in ('done','cancel')]
- backorder_id = self.copy(cr, uid, picking.id, {
- 'name': '/',
- 'move_lines': [],
- 'pack_operation_ids': [],
- 'backorder_id': picking.id,
- })
- back_order_name = self.browse(cr, uid, backorder_id, context=context).name
- self.message_post(cr, uid, picking.id, body=_("Back order %screated.") % (back_order_name), context=context)
- self.pool.get('stock.move').write(cr, uid, backorder_move_ids, {'picking_id': backorder_id}, context=context)
- return backorder_id
+ if backorder_move_ids:
+ backorder_id = self.copy(cr, uid, picking.id, {
+ 'name': '/',
+ 'move_lines': [],
+ 'pack_operation_ids': [],
+ 'backorder_id': picking.id,
+ })
+ back_order_name = self.browse(cr, uid, backorder_id, context=context).name
+ self.message_post(cr, uid, picking.id, body=_("Back order %screated.") % (back_order_name), context=context)
+ self.pool.get('stock.move').write(cr, uid, backorder_move_ids, {'picking_id': backorder_id}, context=context)
+ return backorder_id
+ return False
def do_prepare_partial(self, cr, uid, picking_ids, context=None):
context = context or {}
@@ -684,6 +701,13 @@ class stock_picking(osv.osv):
moves.append(move)
return moves
+ def do_rereserve(self, cr, uid, picking_ids, context=None):
+ '''
+ Needed for parameter create
+ '''
+ self.rereserve(cr, uid, picking_ids, context=context)
+
+
def rereserve(self, cr, uid, picking_ids, create=False, context=None):
"""
This will unreserve all products and reserve the quants from the operations
@@ -704,6 +728,7 @@ class stock_picking(osv.osv):
for ops in picking.pack_operation_ids:
#Find moves that correspond
if ops.product_id:
+ #TODO: Should have order such that things with lots and packings are searched first
move_ids = move_obj.search(cr, uid, [('picking_id','=',picking.id), ('product_id', '=', ops.product_id.id), ('remaining_qty', '>', 0.0)], context=context)
qty_to_do = ops.product_qty
while qty_to_do > 0 and move_ids:
@@ -764,9 +789,6 @@ class stock_picking(osv.osv):
If no pack operation, we close the whole move
Otherwise, do the pack operations
"""
- #TODO: this variable should be in argument
- quant_obj = self.pool.get('stock.quant')
- quant_package_obj = self.pool.get('stock.quant.package')
stock_move_obj = self.pool.get('stock.move')
for picking in self.browse(cr, uid, picking_ids, context=context):
if not picking.pack_operation_ids:
@@ -777,6 +799,7 @@ class stock_picking(osv.osv):
res = self.rereserve(cr, uid, [picking.id], create = True, context = context) #This time, quants need to be created
orig_moves = picking.move_lines
#Add moves that operations need extra
+ extra_moves = []
for ops in res[0].keys():
for prod in res[0][ops].keys():
product = self.pool.get('product.product').browse(cr, uid, prod, context=context)
@@ -795,31 +818,15 @@ class stock_picking(osv.osv):
'reserved_quant_ids': quant and [(4, quant.id)] or [],
'picking_type_id': picking.picking_type_id.id
}, context=context)
+ extra_moves.append(move_id)
res2 = res[1]
for move in res2.keys():
if res2[move] > 0:
mov = stock_move_obj.browse(cr, uid, move, context=context)
newmove_id = stock_move_obj.split(cr, uid, mov, res2[move], context=context)
-
- for move in orig_moves:
- stock_move_obj.action_done(cr, uid, [move.id], context=context)
- #TODO: op.package_id can not work as quants_get is not defined on quant package => gives traceback
-# if op.package_id:
-# for quant in quant_package_obj.browse(cr, uid, op.package_id.id, context=context).quant_ids:
-# self._do_partial_product_move(cr, uid, picking, quant.product_id, quant.qty, quant, context=context)
-# op.package_id.write(cr, uid, {
-# 'parent_id': op.result_package_id.id
-# }, context=context)
-# elif op.product_id:
-# moves = self._do_partial_product_move(cr, uid, picking, op.product_id, op.product_qty, op.quant_id, context=context)
-# quants = []
-# for m in moves:
-# for quant in m.quant_ids:
-# quants.append(quant.id)
-# quant_obj.write(cr, uid, quants, {
-# 'package_id': op.result_package_id.id
-# }, context=context)
+ stock_move_obj.action_done(cr, uid, extra_moves + [x.id for x in orig_moves], context=context)
+ picking.refresh()
self._create_backorder(cr, uid, picking, context=context)
return True
@@ -1012,7 +1019,6 @@ class stock_move(osv.osv):
return res
-
def _get_lot_ids(self, cr, uid, ids, field_name, args, context=None):
res = dict.fromkeys(ids, False)
for move in self.browse(cr, uid, ids, context=context):
@@ -1112,7 +1118,8 @@ class stock_move(osv.osv):
'reserved_quant_ids': fields.one2many('stock.quant', 'reservation_id', 'Reserved quants'),
'remaining_qty': fields.function(_get_remaining_qty, type='float', string='Remaining Quantity',
digits_compute=dp.get_precision('Product Unit of Measure'), states={'done': [('readonly', True)]},
- store = {'stock.quant': (_get_move, ['reservation_id'], 10)}),
+ store = {'stock.move': (lambda self, cr, uid, ids, c={}: ids , ['product_qty', 'product_uom', 'reserved_quant_ids'], 10),
+ 'stock.quant': (_get_move, ['reservation_id'], 10)}),
'procurement_id': fields.many2one('procurement.order', 'Procurement'),
'group_id': fields.related('procurement_id', 'group_id', type='many2one', relation="procurement.group", string='Procurement Group'),
'rule_id': fields.many2one('procurement.rule', 'Procurement Rule'),
@@ -1414,6 +1421,7 @@ class stock_move(osv.osv):
for m2 in move.move_orig_ids:
for q in m2.quant_ids:
dp.append(str(q.id))
+ qty -= q.qty
domain = ['|', ('reservation_id', '=', False), ('reservation_id', '=', move.id)]
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order = dp and ('id not in ('+','.join(dp)+')') or False, context=context)
#Will only reserve physical quants, no negative
@@ -1459,7 +1467,6 @@ class stock_move(osv.osv):
"""
context = context or {}
quant_obj = self.pool.get("stock.quant")
- picking_obj = self.pool.get('stock.picking')
todo = [move.id for move in self.browse(cr, uid, ids, context=context) if move.state == "draft"]
if todo:
@@ -2075,15 +2082,15 @@ class stock_pack_operation(osv.osv):
}
def _get_preferred_order(self, cr, uid, id, context=None):
- pack = self.browse(cr, uid, id, context=context)
+ ops = self.browse(cr, uid, id, context=context)
res = ""
- if pack.package_id:
- res += "package_id <> " + pack.package_id.id
- if pack.lot_id:
+ if ops.package_id:
+ res += "package_id <> " + str(ops.package_id.id)
+ if ops.lot_id:
if res:
- res += ", lot_id <> " + pack.lot_id.id
+ res += ", lot_id <> " + str(ops.lot_id.id)
else:
- res += "lot_id <> " + pack.lot_id.id
+ res += "lot_id <> " + str(ops.lot_id.id)
return res
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index c0c6ba97976..30038952ce7 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -493,6 +493,7 @@
stock.warehouse
@@ -583,7 +585,7 @@
-
+
@@ -804,7 +806,7 @@
-
+
@@ -1451,10 +1453,41 @@
-
+
+
+
+
+ stock.procurement.form
+ procurement.rule
+
+
+
+
+
+
@@ -1538,6 +1571,7 @@
+
diff --git a/addons/stock/wizard/orderpoint_procurement_view.xml b/addons/stock/wizard/orderpoint_procurement_view.xml
index 227b79b3234..20250bb78dd 100644
--- a/addons/stock/wizard/orderpoint_procurement_view.xml
+++ b/addons/stock/wizard/orderpoint_procurement_view.xml
@@ -31,6 +31,7 @@
target="new"
key2="client_action_multi"
id="action_procurement_compute"/>
+
diff --git a/addons/stock_account/__init__.py b/addons/stock_account/__init__.py
index 3bab8f50207..d74ac75cb98 100644
--- a/addons/stock_account/__init__.py
+++ b/addons/stock_account/__init__.py
@@ -21,5 +21,6 @@
import product
import stock_account
+import stock
import wizard
diff --git a/addons/stock_account/__openerp__.py b/addons/stock_account/__openerp__.py
index 93ffe4006ec..6a22e327bb1 100644
--- a/addons/stock_account/__openerp__.py
+++ b/addons/stock_account/__openerp__.py
@@ -49,6 +49,7 @@ Dashboard / Reports for Warehouse Management will include:
'data': [
'stock_account_data.xml',
'wizard/stock_change_standard_price_view.xml',
+ 'wizard/stock_invoice_onshipping_view.xml',
'product_data.xml',
'product_view.xml',
'stock_account_view.xml',
diff --git a/addons/sale_stock/stock.py b/addons/stock_account/stock.py
similarity index 100%
rename from addons/sale_stock/stock.py
rename to addons/stock_account/stock.py
diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py
index 2dc3d804ccd..f9e62fa80e2 100644
--- a/addons/stock_account/stock_account.py
+++ b/addons/stock_account/stock_account.py
@@ -34,6 +34,12 @@ import openerp.addons.decimal_precision as dp
import logging
_logger = logging.getLogger(__name__)
+#----------------------------------------------------------
+# Invoice state
+#----------------------------------------------------------
+
+
+
#----------------------------------------------------------
# Stock Location
diff --git a/addons/stock_account/stock_account_view.xml b/addons/stock_account/stock_account_view.xml
index cf9aaebf236..a7e6bc8afe9 100644
--- a/addons/stock_account/stock_account_view.xml
+++ b/addons/stock_account/stock_account_view.xml
@@ -16,5 +16,21 @@
+
+
+ stock.picking.form.inherit
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/stock_account/wizard/__init__.py b/addons/stock_account/wizard/__init__.py
index ecb883ed6fb..001a39e763e 100644
--- a/addons/stock_account/wizard/__init__.py
+++ b/addons/stock_account/wizard/__init__.py
@@ -20,3 +20,4 @@
##############################################################################
import stock_change_standard_price
+import stock_invoice_onshipping
diff --git a/addons/sale_stock/wizard/stock_invoice_onshipping.py b/addons/stock_account/wizard/stock_invoice_onshipping.py
similarity index 100%
rename from addons/sale_stock/wizard/stock_invoice_onshipping.py
rename to addons/stock_account/wizard/stock_invoice_onshipping.py
diff --git a/addons/sale_stock/wizard/stock_invoice_onshipping_view.xml b/addons/stock_account/wizard/stock_invoice_onshipping_view.xml
similarity index 100%
rename from addons/sale_stock/wizard/stock_invoice_onshipping_view.xml
rename to addons/stock_account/wizard/stock_invoice_onshipping_view.xml
diff --git a/addons/stock_complex_routes/__openerp__.py b/addons/stock_complex_routes/__openerp__.py
index 5426e2c7aca..872f42d98b5 100644
--- a/addons/stock_complex_routes/__openerp__.py
+++ b/addons/stock_complex_routes/__openerp__.py
@@ -38,7 +38,7 @@ This adds a route on the sales order and sales order line (mini module)
'init_xml': [],
'update_xml': ['stock_complex_routes.xml'],
'demo_xml': [],
- 'test': [],
+ 'test': ['test/lifo_price.yml'],
'installable': True,
'auto_install': True,
}
diff --git a/addons/purchase/test/lifo_price.yml b/addons/stock_complex_routes/test/lifo_price.yml
similarity index 78%
rename from addons/purchase/test/lifo_price.yml
rename to addons/stock_complex_routes/test/lifo_price.yml
index ea30317b996..4bf1922c251 100644
--- a/addons/purchase/test/lifo_price.yml
+++ b/addons/stock_complex_routes/test/lifo_price.yml
@@ -1,8 +1,12 @@
-
- Set product category removal strategy as LIFO
+ Set product category removal strategy as LIFO
-
- !record {model: product.category, id: product.product_category_1}:
- removal_strategy: lifo
+ !record {model: product.category, id: product.product_category_001}:
+ name : Lifo Category
+ removal_strategy_ids:
+ - product_categ_id: product.product_category_1
+ method: lifo
+ location_id: stock.stock_location_stock
-
Set a product as using lifo price
-
@@ -58,10 +62,9 @@
-
Process the reception of purchase order 1
-
- !python {model: stock.partial.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo1")).picking_ids
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo1")).picking_ids[0]
+ order.do_partial(context=context)
-
Check the standard price of the product (lifo icecream)
-
@@ -74,10 +77,9 @@
-
Process the reception of purchase order 2
-
- !python {model: stock.partial.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo2")).picking_ids
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_lifo2")).picking_ids[0]
+ order.do_partial(context=context)
-
Check the standard price should not have changed
-
@@ -87,7 +89,7 @@
Let us send some goods
-
!record {model: stock.picking, id: outgoing_lifo_shipment}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@@ -95,8 +97,10 @@
picking_id: outgoing_lifo_shipment
product_id: product_lifo_icecream
product_uom: product.product_uom_kgm
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
product_qty: 20.0
- type: out
+ picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@@ -105,9 +109,9 @@
-
Process the delivery of the outgoing shipment
-
- !python {model: stock.partial.picking}: |
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_lifo_shipment")], 'default_type':'out'})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_lifo_shipment"))
+ pick_order.do_partial(context=context)
-
Check standard price became 80 euro
-
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index 7f27496ff0d..77d1a67149a 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -28,20 +28,29 @@ class stock_location_route(osv.osv):
_name = 'stock.location.route'
_description = "Inventory Routes"
_order = 'sequence'
+
+ def _default_warehouse(self, cr, uid, context=None):
+ user = self.pool.get('res.users').browse(cr, uid, uid, context)
+ res = self.pool.get('stock.warehouse').search(cr, uid, [('company_id', '=', user.company_id.id)], limit=1, context=context)
+ return res and res[0] or False
+
_columns = {
'name': fields.char('Route Name', required=True),
'sequence': fields.integer('Sequence'),
'pull_ids': fields.one2many('procurement.rule', 'route_id', 'Pull Rules'),
'push_ids': fields.one2many('stock.location.path', 'route_id', 'Push Rules'),
+ 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse'),
}
_defaults = {
'sequence': lambda self,cr,uid,ctx: 0,
+ 'warehouse_id': _default_warehouse,
}
class stock_warehouse(osv.osv):
_inherit = 'stock.warehouse'
_columns = {
'route_id': fields.many2one('stock.location.route', 'Default Logistic Route', help='Default route through the warehouse', required=True),
+ 'route_ids': fields.one2many('stock.location.route', 'warehouse_id', 'All Routes'),
}
@@ -60,7 +69,7 @@ class stock_location_path(osv.osv):
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")], "Invoice Status",
required=True,),
- 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This is the picking type associated with the different pickings"),
+ 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True, help="This is the picking type associated with the different pickings"),
'auto': fields.selection(
[('auto','Automatic Move'), ('manual','Manual Operation'),('transparent','Automatic No Step Added')],
'Automatic Move',
@@ -215,7 +224,7 @@ class product_category(osv.osv):
_inherit = 'product.category'
_columns = {
'route_ids': fields.many2many('stock.location.route', 'stock_location_route_categ', 'categ_id', 'route_id', 'Routes'),
- #'removal_strategy_ids': fields.one2many('product.removal', 'product_categ_id', 'Removal Strategies'),
+ 'removal_strategy_ids': fields.one2many('product.removal', 'product_categ_id', 'Removal Strategies'),
#'putaway_strategy_ids': fields.one2many('product.putaway', 'product_categ_id', 'Put Away Strategies'),
}
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index 8a42f2afb46..f3a0a0726c9 100644
--- a/addons/stock_location/stock_location_view.xml
+++ b/addons/stock_location/stock_location_view.xml
@@ -2,6 +2,26 @@
+
+ stock.procurement.rule.inherit.form
+ procurement.rule
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ stock.location.form
@@ -137,6 +157,14 @@
+
+
+
+
+
+
+
+
@@ -147,6 +175,7 @@
+
@@ -159,6 +188,7 @@
You can define here the main logistic routes that run through
your warehouses and that define the flows of your products. These
- routes can be assigned to a product, a product category or on a
- location.
+ routes can be assigned to a product, a product category or be fixed
+ on procurement or sales order.
@@ -191,5 +221,17 @@
+
+
+
+ procurement.order.form.view.inherit
+
+ procurement.order
+
+
+
+
+
+
diff --git a/addons/stock_location/test/stock_location_push_flow.yml b/addons/stock_location/test/stock_location_push_flow.yml
index 3a6f0a1b2c3..0d9c71acd48 100644
--- a/addons/stock_location/test/stock_location_push_flow.yml
+++ b/addons/stock_location/test/stock_location_push_flow.yml
@@ -32,9 +32,11 @@
- invoice_state: none
location_dest_id: stock_location.stock_location_qualitytest0
location_from_id: stock.stock_location_stock
+ picking_type_id: stock.picking_type_internal
- invoice_state: none
location_dest_id: stock.stock_location_components
location_from_id: stock_location.stock_location_qualitytest0
+ picking_type_id: stock.picking_type_internal
-
!record {model: product.product, id: product_product_hpcdwriters01}:
list_price: 1000.0