From d342adbee8c533a53b32ad16bf207fb509321f8b Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Wed, 7 Aug 2013 11:58:11 +0200
Subject: [PATCH 01/97] [FIX]stock_inventory_test: fix stock inventory test
bzr revid: csn@openerp.com-20130807095811-jz95nfuguigwv90j
---
addons/stock/stock.py | 1 +
addons/stock/test/inventory.yml | 75 +++++++++++++++++----------------
2 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 5bd89fdd44c..eb4cb46b0d5 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1566,6 +1566,7 @@ class stock_inventory(osv.osv):
for inv in self.browse(cr, uid, ids, context=context):
if not inv.move_ids:
self.action_check(cr, uid, [inv.id], context=context)
+ inv.refresh()
move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context)
self.write(cr, uid, [inv.id], {'state': 'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
return True
diff --git a/addons/stock/test/inventory.yml b/addons/stock/test/inventory.yml
index 3a9d4a4c5db..d5376e82348 100644
--- a/addons/stock/test/inventory.yml
+++ b/addons/stock/test/inventory.yml
@@ -1,24 +1,38 @@
-
- I create an inventory of 10 products
+ I create an inventory
-
!record {model: stock.inventory, id: inventory_test0}:
name: Test
- inventory_line_id:
- - product_id: product.product_product_3
- product_qty: 10
- location_id: stock.stock_location_14
-
- I post this inventory
+ I create the wizard to confirm the inventory
+-
+ !record {model: stock.fill.inventory, id: inventory_test0_wizard}:
+ set_stock_zero: False
+-
+ I fill this inventory
+-
+ !python {model: stock.inventory.line}: |
+ context = {'active_ids': [ref('inventory_test0')]}
+ self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context)
+-
+ I create an inventory line with 10 product
+-
+ !record {model: stock.inventory.line, id: inventory_testline0}:
+ inventory_id: stock.inventory_test0
+ product_id: product.product_product_3
+ product_qty: 10
+ location_id: stock.stock_location_14
+-
+ I confirm this inventory
-
!python {model: stock.inventory}: |
- self.action_confirm(cr, uid, [ref('inventory_test0')], context=context)
self.action_done(cr, uid, [ref('inventory_test0')], context=context)
-
I check that this inventory has a stock.move and a quant
-
!python {model: stock.inventory}: |
inv = self.browse(cr, uid, ref('inventory_test0'), context=context)
- assert len(inv.move_ids) == 1, "No move created for the inventory."
+ assert len(inv.move_ids) >= 1, "No move created for the inventory."
assert len(inv.move_ids[0].quant_ids) >= 1, "No quant created for this inventory"
-
I check that the quantity on hand is 10 on the location and it's parent.
@@ -38,21 +52,30 @@
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==0, 'Expecting 0 products, got %.2f on location stock_location_components!' % (product.qty_available,)
-
- I create an inventory of 20 products
+ I create another inventory
-
!record {model: stock.inventory, id: inventory_test1}:
name: Test
- inventory_line_id:
- - product_id: product.product_product_3
- product_qty: 20
- location_id: stock.stock_location_14
-
- I post this new inventory
+ I fill this new inventory
+-
+ !python {model: stock.inventory}: |
+ context = {'active_ids': [ref('inventory_test1')]}
+ self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context)
+ self.action_done(cr, uid, [ref('inventory_test1')], context=context)
+-
+ I create an inventory line with 20 product on this new inventory
+-
+ !record {model: stock.inventory.line, id: inventory_testline0}:
+ inventory_id: stock.inventory_test1
+ product_id: product.product_product_3
+ product_qty: 20
+ location_id: stock.stock_location_14
+-
+ I confirm this inventory
-
!python {model: stock.inventory}: |
- self.action_confirm(cr, uid, [ref('inventory_test1')], context=context)
self.action_done(cr, uid, [ref('inventory_test1')], context=context)
-
-
I check that the quantity on hand is 20 on the location and it's parent.
-
@@ -60,24 +83,4 @@
context['location'] = ref('stock.stock_location_14')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)
--
- !record {model: stock.inventory, id: inventory_test2}:
- name: Test
- inventory_line_id:
- - product_id: product.product_product_3
- product_qty: 18
- location_id: stock.stock_location_14
--
- I post this new inventory
--
- !python {model: stock.inventory}: |
- self.action_confirm(cr, uid, [ref('inventory_test2')], context=context)
- self.action_done(cr, uid, [ref('inventory_test2')], context=context)
--
- I check that the quantity on hand is 18 on the location and it's parent.
--
- !python {model: product.product}: |
- context['location'] = ref('stock.stock_location_14')
- product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
- assert product.qty_available==18, 'Expecting 18 products, got %.2f on location stock_location_14!' % (product.qty_available,)
From 5a4f0fec0c1613fc438e3464bc2c4fdbff3358ec Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Wed, 7 Aug 2013 12:08:49 +0200
Subject: [PATCH 02/97] [FIX]remove extra line
bzr revid: csn@openerp.com-20130807100849-bnkyo20suoky18gc
---
addons/stock/test/inventory.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/addons/stock/test/inventory.yml b/addons/stock/test/inventory.yml
index d5376e82348..9fc2fc32b10 100644
--- a/addons/stock/test/inventory.yml
+++ b/addons/stock/test/inventory.yml
@@ -62,7 +62,6 @@
!python {model: stock.inventory}: |
context = {'active_ids': [ref('inventory_test1')]}
self.pool.get('stock.fill.inventory').fill_inventory(cr, uid, [ref('inventory_test0_wizard')], context=context)
- self.action_done(cr, uid, [ref('inventory_test1')], context=context)
-
I create an inventory line with 20 product on this new inventory
-
From bbf8ca67fa11a3c399020413d3885f040e9ceb2d Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Tue, 13 Aug 2013 10:54:24 +0530
Subject: [PATCH 03/97] [IMP] make chnages anglo_saxon_yml
bzr revid: rma@tinyerp.com-20130813052424-bdolzw3yl93kggay
---
.../account_anglo_saxon/test/anglo_saxon.yml | 40 +++++++++++--------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 6e9ebc0068e..77dc05836bc 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -123,10 +123,15 @@
-
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}: |
+ order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001"))
+ for pick in order.picking_ids:
+ self.pool.get('stock.pack.operation').create(cr, uid, {
+ 'picking_id': pick.id,
+ 'product_qty': 1
+ })
+ pick.do_partial(context=context)
+
-
I check the Stock Interim account (Received) is credited successfully.
-
@@ -189,7 +194,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 +202,31 @@
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
move_type: direct
- type: out
+ picking_type_id: 1
-
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"),
- })
+ self.action_confirm(cr, uid, [ref('stock_picking_out001')], context=context)
+
-
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}: |
+ order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001"))
+ pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001"))
+ for pick in pick_order.picking_ids:
+ self.pool.get('stock.pack.operation').create(cr, uid, {
+ 'picking_id': pick.id,
+ 'product_qty': 1
+ })
+ pick.do_partial(context=context)
-
I check Stock Interim account (Delivery) is debited successfully.
-
From ea891054bc7ea9e5de6bd759edbcccf6fef16928 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Tue, 13 Aug 2013 12:57:14 +0530
Subject: [PATCH 04/97] [IMP] improve anglo_saxon_yml
bzr revid: rma@tinyerp.com-20130813072714-7apay9hbt5m0ja6o
---
addons/account_anglo_saxon/test/anglo_saxon.yml | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 77dc05836bc..ecb5d291535 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -202,7 +202,7 @@
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
move_type: direct
- picking_type_id: 1
+ picking_type_id: self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id
-
I need to check the availability of the product, So I make my picking order for processing later.
-
@@ -213,20 +213,21 @@
I check the product availability, Product is available in the stock and ready to be sent.
-
!python {model: stock.picking}: |
- self.action_confirm(cr, uid, [ref('stock_picking_out001')], context=context)
+ 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.picking}: |
- order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001"))
pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001"))
- for pick in pick_order.picking_ids:
- self.pool.get('stock.pack.operation').create(cr, uid, {
- 'picking_id': pick.id,
- 'product_qty': 1
+ self.pool.get('stock.pack.operation').create(cr, uid, {
+ 'picking_id': pick_order.id,
+ 'product_qty': 1
})
- pick.do_partial(context=context)
+ pick_order.do_partial(context=context)
-
I check Stock Interim account (Delivery) is debited successfully.
-
From b46d71d2b3ff56ce8c1ab9238e57caf511a5c8a2 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Tue, 13 Aug 2013 15:07:15 +0530
Subject: [PATCH 05/97] [IMP] make changes in acc_anglo_saxon_lifo
bzr revid: rma@tinyerp.com-20130813093715-mqgkxfd8suxy9nye
---
.../account_anglo_saxon/test/anglo_saxon.yml | 2 +-
.../test/anglo_saxon_avg_fifo.yml | 38 ++++++++++---------
.../wizard/stock_invoice.py | 2 +-
3 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index ecb5d291535..73034497d14 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -202,7 +202,7 @@
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
move_type: direct
- picking_type_id: self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id
+ picking_type_id: 1
-
I need to check the availability of the product, So I make my picking order for processing later.
-
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..387f9bce715 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,14 @@
-
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}: |
+ order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo"))
+ for pick in order.picking_ids:
+ self.pool.get('stock.pack.operation').create(cr, uid, {
+ 'picking_id': pick.id,
+ 'product_qty': 1
+ })
+ pick.do_partial(context=context)
-
I check the Stock Interim account (Received) is credit successfully.
-
@@ -192,7 +196,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 +203,30 @@
product_qty: 1.0
location_dest_id: stock.stock_location_customers
move_type: direct
- type: out
+ picking_type_id: 1
-
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}: |
+ pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001_fifo"))
+ self.pool.get('stock.pack.operation').create(cr, uid, {
+ 'picking_id': pick_order.id,
+ 'product_qty': 1
+ })
+ pick_order.do_partial(context=context)
-
I check Stock Interim account (Delivery) is debited successfully.
-
diff --git a/addons/stock_invoice_directly/wizard/stock_invoice.py b/addons/stock_invoice_directly/wizard/stock_invoice.py
index ba41de626da..171eda3d5ab 100644
--- a/addons/stock_invoice_directly/wizard/stock_invoice.py
+++ b/addons/stock_invoice_directly/wizard/stock_invoice.py
@@ -22,7 +22,7 @@
from openerp.osv import fields, osv
class invoice_directly(osv.osv_memory):
- _inherit = 'stock.partial.picking'
+ _inherit = 'stock.picking'
def do_partial(self, cr, uid, ids, context=None):
"""Launch Create invoice wizard if invoice state is To be Invoiced,
From f8730cdf22d3624b589a9c049e6d815873046fb3 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Tue, 13 Aug 2013 15:43:28 +0530
Subject: [PATCH 06/97] [IMP] chnage picking_type_id
bzr revid: rma@tinyerp.com-20130813101328-f3qu81wr5yda69va
---
addons/account_anglo_saxon/test/anglo_saxon.yml | 2 +-
addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 73034497d14..1223c9472d7 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -202,7 +202,7 @@
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
move_type: direct
- picking_type_id: 1
+ 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.
-
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 387f9bce715..a98f6afc882 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -203,7 +203,7 @@
product_qty: 1.0
location_dest_id: stock.stock_location_customers
move_type: direct
- picking_type_id: 1
+ 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.
-
From ade7b86291a0dfdefec2dc52468f368c272b9930 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Tue, 13 Aug 2013 17:09:24 +0530
Subject: [PATCH 07/97] [IMP] remove extra changes
bzr revid: rma@tinyerp.com-20130813113924-wwvchvxf131qtk3d
---
addons/stock_invoice_directly/wizard/stock_invoice.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock_invoice_directly/wizard/stock_invoice.py b/addons/stock_invoice_directly/wizard/stock_invoice.py
index 171eda3d5ab..ba41de626da 100644
--- a/addons/stock_invoice_directly/wizard/stock_invoice.py
+++ b/addons/stock_invoice_directly/wizard/stock_invoice.py
@@ -22,7 +22,7 @@
from openerp.osv import fields, osv
class invoice_directly(osv.osv_memory):
- _inherit = 'stock.picking'
+ _inherit = 'stock.partial.picking'
def do_partial(self, cr, uid, ids, context=None):
"""Launch Create invoice wizard if invoice state is To be Invoiced,
From dfeb8597fd2ee7d58c34fe3ebfdadd5047c089b8 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Wed, 14 Aug 2013 11:34:17 +0530
Subject: [PATCH 08/97] [IMP] remove stock.pack.operation opeartion on
do_partial
bzr revid: rma@tinyerp.com-20130814060417-b5rggizg5lgzsk2w
---
addons/account_anglo_saxon/test/anglo_saxon.yml | 14 ++------------
.../test/anglo_saxon_avg_fifo.yml | 13 ++-----------
2 files changed, 4 insertions(+), 23 deletions(-)
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 1223c9472d7..2dadc420e41 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -124,14 +124,8 @@
Reception is ready for process so now done the reception.
-
!python {model: stock.picking}: |
- order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001"))
- for pick in order.picking_ids:
- self.pool.get('stock.pack.operation').create(cr, uid, {
- 'picking_id': pick.id,
- 'product_qty': 1
- })
- pick.do_partial(context=context)
-
+ order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001")).picking_ids[0]
+ order.do_partial(context=context)
-
I check the Stock Interim account (Received) is credited successfully.
-
@@ -223,10 +217,6 @@
-
!python {model: stock.picking}: |
pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001"))
- self.pool.get('stock.pack.operation').create(cr, uid, {
- 'picking_id': pick_order.id,
- 'product_qty': 1
- })
pick_order.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 a98f6afc882..4e9eb5d3738 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -132,13 +132,8 @@
Reception is ready for process so now done the reception.
-
!python {model: stock.picking}: |
- order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo"))
- for pick in order.picking_ids:
- self.pool.get('stock.pack.operation').create(cr, uid, {
- 'picking_id': pick.id,
- 'product_qty': 1
- })
- pick.do_partial(context=context)
+ order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo")).picking_ids[0]
+ order.do_partial(context=context)
-
I check the Stock Interim account (Received) is credit successfully.
-
@@ -222,10 +217,6 @@
-
!python {model: stock.picking}: |
pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001_fifo"))
- self.pool.get('stock.pack.operation').create(cr, uid, {
- 'picking_id': pick_order.id,
- 'product_qty': 1
- })
pick_order.do_partial(context=context)
-
I check Stock Interim account (Delivery) is debited successfully.
From 4af5d29679589d6b79608b17ccdcf8735a060c6c Mon Sep 17 00:00:00 2001
From: "Mansi Kariya (OpenERP Trainee)"
Date: Wed, 14 Aug 2013 17:55:54 +0530
Subject: [PATCH 09/97] [IMP] Added a product and sale order.
bzr revid: mansi.mk.179@gmail.com-20130814122554-dkjy8vjnmeibzqeu
---
.../sale_stock/test/prepaid_order_policy.yml | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
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."
From 592475349ab606b1bf758f94def99246b807d135 Mon Sep 17 00:00:00 2001
From: "Jitendra Prajapati (OpenERP)"
Date: Fri, 16 Aug 2013 12:33:09 +0530
Subject: [PATCH 10/97] [IMP]improve rfq2order2done yml
bzr revid: prajapatijitendra7969@gmail.com-20130816070309-k1rj401ltvxbkv93
---
addons/purchase/test/process/rfq2order2done.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/addons/purchase/test/process/rfq2order2done.yml b/addons/purchase/test/process/rfq2order2done.yml
index ff9158b3c09..8a8dd946c92 100644
--- a/addons/purchase/test/process/rfq2order2done.yml
+++ b/addons/purchase/test/process/rfq2order2done.yml
@@ -45,10 +45,10 @@
-
Reception is ready for process so now done the reception.
-
- !python {model: stock.partial.picking}: |
+ !python {model: stock.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])
+ self.do_prepare_partial(cr, uid, [pick_ids[0].id], context=context)
+ self.do_partial(cr, uid, [pick_ids[0].id], context=context)
-
I check that purchase order is shipped.
-
From 02aef6ff11218a66d366b0fa28a114e0945f5db5 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Mon, 19 Aug 2013 11:36:09 +0530
Subject: [PATCH 11/97] [IMP] improved according to new wms
bzr revid: bde@tinyerp.com-20130819060609-blgi8tornvbfztg4
---
.../sale_stock/test/picking_order_policy.yml | 25 +++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index e28b4b066d4..22e26f706b7 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -31,15 +31,15 @@
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)
+ procurements = order_line.procurement_ids
+ 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."
+ for procurement in procurements:
+ 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.move_dest_id.procure_method == order_line.type, "Procurement method is not correspond."
-
I run the scheduler.
-
@@ -57,7 +57,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,7 +66,7 @@
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
+ order_line = move.procurement_id.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)
date_planned = (date_planned - timedelta(days=sale_order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
@@ -84,13 +84,12 @@
-
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 check sale order to verify shipment.
-
From 735692618065cba85e7453350d36c794402acf85 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Mon, 19 Aug 2013 11:56:08 +0530
Subject: [PATCH 12/97] [ADD] added parameters in various methods in order to
get proper output for picking-order-policy-yml test cases of sale_stock
module
bzr revid: bde@tinyerp.com-20130819062608-o51cjq7s4ayhsttx
---
addons/sale/sale.py | 2 +-
addons/stock/procurement.py | 2 ++
addons/stock/stock.py | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index b55fccc8984..f733cfd9ff1 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -658,7 +658,7 @@ class sale_order(osv.osv):
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, 'partner_id': order.partner_shipping_id.id
+ 'name': order.name, 'partner_id': order.partner_shipping_id.id, 'move_type': order.picking_policy
}, context=context)
order.write({'procurement_group_id': group_id}, context=context)
for line in order.order_line:
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index 7f36871b9d1..4eeca78e0a1 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -86,6 +86,7 @@ class procurement_order(osv.osv):
'rule_id': procurement.rule_id.id,
'origin': procurement.origin,
'picking_type_id': procurement.rule_id.picking_type_id.id,
+ 'price_unit': procurement.sale_line_id.product_id.standard_price
}
def _run(self, cr, uid, procurement, context=None):
@@ -96,6 +97,7 @@ class procurement_order(osv.osv):
move_obj = self.pool.get('stock.move')
move_dict = self._run_move_create(cr, uid, procurement, context=context)
move_id = move_obj.create(cr, uid, move_dict, context=context)
+ self.write(cr, uid, procurement.id, {'move_dest_id': move_id}, context=context)
move_obj.action_confirm(cr, uid, [move_id], context=context)
return move_id
return super(procurement_order, self)._run(cr, uid, procurement, context)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 2dff89acfa2..af8e418002c 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1212,6 +1212,7 @@ class stock_move(osv.osv):
'state': 'confirmed',
'group_id': move.group_id and move.group_id.id or False,
'picking_type_id': move.picking_type_id and move.picking_type_id.id or False,
+ 'move_lines': [(6, 0, [move.id])]
}
pick = pick_obj.create(cr, uid, values, context=context)
move.write({'picking_id': pick})
From 64fee2e674ac8484fc8f8e1021ee8ecb63911f3b Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Wed, 21 Aug 2013 10:55:28 +0530
Subject: [PATCH 13/97] [IMP] value of invoice.comment should be blank if value
is False
bzr revid: bde@tinyerp.com-20130821052528-wfo71cmpwcu1593r
---
addons/sale_stock/test/picking_order_policy.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index 22e26f706b7..bdad1424b2a 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -122,7 +122,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:
From 0d3437e753cc4b4b9a42508efc7c8ea6435d13ea Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Wed, 21 Aug 2013 11:12:53 +0530
Subject: [PATCH 14/97] [IMP] As the system creates one procurement per sale
order line so checked the assert statements without for loop for procurements
bzr revid: bde@tinyerp.com-20130821054253-kbtjbyosjukc9con
---
addons/sale_stock/test/picking_order_policy.yml | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index bdad1424b2a..3cefc8e2529 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -31,15 +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:
- procurements = order_line.procurement_ids
+ 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)
- for procurement in procurements:
- 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.move_dest_id.procure_method == order_line.type, "Procurement method is not correspond."
+ 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.move_dest_id.procure_method == order_line.type, "Procurement method is not correspond."
-
I run the scheduler.
-
From 038aee2d06f89d97b075d825f9f862b3aabf3dfd Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Wed, 21 Aug 2013 15:07:42 +0530
Subject: [PATCH 15/97] [IMP] improved the code
bzr revid: bde@tinyerp.com-20130821093742-rt0lvwdw98aiwx3w
---
addons/stock/procurement.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index 4eeca78e0a1..e0c93957459 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -97,7 +97,6 @@ class procurement_order(osv.osv):
move_obj = self.pool.get('stock.move')
move_dict = self._run_move_create(cr, uid, procurement, context=context)
move_id = move_obj.create(cr, uid, move_dict, context=context)
- self.write(cr, uid, procurement.id, {'move_dest_id': move_id}, context=context)
move_obj.action_confirm(cr, uid, [move_id], context=context)
return move_id
return super(procurement_order, self)._run(cr, uid, procurement, context)
From b1139e0affd5635e5592cf3ded77ad63a9a9c87a Mon Sep 17 00:00:00 2001
From: "Jitendra Prajapati (OpenERP)"
Date: Thu, 22 Aug 2013 12:16:18 +0530
Subject: [PATCH 16/97] [IMP]improve rfq2order2done yml
bzr revid: prajapatijitendra7969@gmail.com-20130822064618-l03lwozp4d6fth5p
---
addons/purchase/test/process/rfq2order2done.yml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/addons/purchase/test/process/rfq2order2done.yml b/addons/purchase/test/process/rfq2order2done.yml
index 8a8dd946c92..a6999686026 100644
--- a/addons/purchase/test/process/rfq2order2done.yml
+++ b/addons/purchase/test/process/rfq2order2done.yml
@@ -46,9 +46,8 @@
Reception is ready for process so now done the reception.
-
!python {model: stock.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_1")).picking_ids
- self.do_prepare_partial(cr, uid, [pick_ids[0].id], context=context)
- self.do_partial(cr, uid, [pick_ids[0].id], context=context)
+ 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.
-
From ee59841b3d895f04aece275e0a55387b3acb48b5 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 22 Aug 2013 11:48:13 +0200
Subject: [PATCH 17/97] [WIP] Rereserve function for button + route_id on sales
order line form view
bzr revid: jco@openerp.com-20130822094813-jnvpa7rzsj6obr1p
---
addons/sale/sale_view.xml | 1 +
addons/stock/stock.py | 93 ++++++++++++++++++++++++++++++++++---
addons/stock/stock_view.xml | 2 +-
3 files changed, 88 insertions(+), 8 deletions(-)
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 967350a88ac..bc7353b771f 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -397,6 +397,7 @@
+
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 357da1a3927..046ae6bff83 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -201,7 +201,6 @@ class stock_quant(osv.osv):
else:
self._quant_split(cr, uid, quant, qty, context=context)
# FP Note: improve this using preferred locations
- location_to = move.location_dest_id
location_to = self.check_preferred_location(cr, uid, move, context=context)
self.write(cr, uid, [quant.id], {
'location_id': location_to.id,
@@ -239,7 +238,7 @@ class stock_quant(osv.osv):
# Create a negative quant in the source location if it's an internal location
# Reconcile a positive quant with a negative is possible
#
- def _quant_create(self, cr, uid, qty, move, context=None):
+ def _quant_create(self, cr, uid, qty, move, lot_id = False, context=None):
# FP Note: TODO: compute the right price according to the move, with currency convert
# QTY is normally already converted to main product's UoM
price_unit = move.price_unit
@@ -251,6 +250,7 @@ class stock_quant(osv.osv):
'history_ids': [(4, move.id)],
'in_date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'company_id': move.company_id.id,
+ 'lot_id': lot_id,
}
negative_quant_id = False
@@ -649,7 +649,7 @@ class stock_picking(osv.osv):
'cost': move.product_id.standard_price,
}, context=context)
- def _do_partial_product_move(self, cr, uid, picking, product, qty, quant=False, context=None):
+ def _do_partial_product_move(self, cr, uid, picking, product, qty, pack_id = False, lot_id = False, quant=False, context=None):
moves = []
stock_move_obj = self.pool.get('stock.move')
for move in picking.move_lines:
@@ -684,6 +684,66 @@ class stock_picking(osv.osv):
moves.append(move)
return moves
+ def rereserve(self, cr, uid, picking_ids, create=False, context=None):
+ """
+ This will unreserve all products and reserve the quants from the operations
+ """
+ quant_obj = self.pool.get("stock.quant")
+ move_obj = self.pool.get("stock.move")
+ op_obj = self.pool.get("stock.pack.operation")
+ for picking in self.browse(cr, uid, picking_ids, context=context):
+ # unreserve everything
+ for move in picking.move_lines:
+ quant_obj.quants_unreserve(cr, uid, move, context=context)
+# if picking.location_id.usage != 'internal' and picking.location_dest_id.usage == 'internal': #When to create the pickings?
+ ops_list = [(x.id, x.product_uom_qty) for x in picking.pack_operation_ids]
+ while ops_list:
+ ops = ops_list.pop()
+ #Find moves that correspond
+ if ops[0].product_id:
+ move_ids = move_obj.search(cr, uid, [('picking_id','=',picking.id), ('product_id', '=', ops[0].product_id), ('remaining_qty', '>', 0.0)], context=context)
+ for move in move_obj.browse(cr, uid, move_ids, context=context):
+ if move.remaining_qty > ops[1]:
+ qty = ops[1]
+ else:
+ qty = move.remaining_qty
+ # Add remaining quantity to the list
+ if ops[1] - qty > 0:
+ ops_list.append((ops[0] , ops[1] - qty),)
+
+ if create and move.location_id != 'internal':
+ # Create quants
+ vals = {
+ 'product_id': move.product_id.id,
+ 'location_id': move.location_id.id,
+ 'qty': qty,
+ #'cost': price_unit,
+ 'history_ids': [(4, move.id)],
+ 'in_date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
+ 'company_id': move.company_id.id,
+ 'lot_id': ops[0].lot_id and ops.lot_id.id or False,
+ 'reservation_id': move.id, #Reserve at once
+ 'package_id': ops[0].result_package_id and ops[0].result_package_id.id or False,
+ }
+ quant_id = quant_obj.create(cr, uid, vals, context=context)
+ else:
+ #Quants get
+ domain = [('reservation_id', '=', False)]
+ prefered_order = op_obj._get_preferred_order(cr, uid, ops[0].id, context=context)
+ quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order=prefered_order, context=context)
+ quant_obj.quants_reserve(cr, uid, quants, move, context=context)
+ elif ops[0].package_id:
+ lines = ops.package_id.quant_ids #_get_package_lines
+ to_reserve = [(x.id, x.product_uom_qty) for x in lines if not x.reservation_id]
+ quant_obj.quants_reserve(cr,uid, to_reserve, context=context)
+ #Need to check on which move
+# for line in lines:
+# if not line.reservation_id:
+# quant_obj.quants_reserve(cr, uid, [(line.id, line.product_uom_qty)], context=context)
+
+
+
+
def do_partial(self, cr, uid, picking_ids, context=None):
"""
If no pack operation, we close the whole move
@@ -699,21 +759,19 @@ class stock_picking(osv.osv):
for op in picking.pack_operation_ids:
#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.quants_get(cr, uid, op.package_id, context=context):
+ 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)
self._create_backorder(cr, uid, picking, context=context)
@@ -899,6 +957,8 @@ class stock_move(osv.osv):
res[move.id] -= self.pool.get('stock.quant.package')._get_product_total_qty(cr, uid, op.package_id, move.product_id.id, context=context)
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):
@@ -1352,7 +1412,13 @@ class stock_move(osv.osv):
# quant_obj.quants_move(cr, uid, quants, move, location_dest_id, context=context)
# should replace the above 2 lines
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 = 'reservation_id<>'+str(move.id), context=context)
+ prefered_order = 'reservation_id<>' + str(move.id)
+# if lot_id:
+# prefered_order = 'lot_id<>' + lot_id + ", " + prefered_order
+# if pack_id:
+# prefered_order = 'pack_id<>' + pack_id + ", " + prefered_order
+ quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order = prefered_order, context=context)
+
#Will move all quants_get and as such create negative quants
quant_obj.quants_move(cr, uid, quants, move, context=context)
quant_obj.quants_unreserve(cr, uid, move, context=context)
@@ -1944,6 +2010,19 @@ class stock_pack_operation(osv.osv):
'date': fields.date.context_today,
}
+ def _get_preferred_order(self, cr, uid, id, context=None):
+ pack = self.browse(cr, uid, id, context=context)
+ res = ""
+ if pack.package_id:
+ res += "package_id <> " + pack.package_id.id
+ if pack.lot_id:
+ if res:
+ res += ", lot_id <> " + pack.lot_id.id
+ else:
+ res += "lot_id <> " + pack.lot_id.id
+ return res
+
+
#TODO: this function can be refactored
def _search_and_increment(self, cr, uid, picking_id, key, context=None):
'''Search for an operation on an existing key in a picking, if it exists increment the qty (+1) otherwise create it
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 575712ad771..f6a8c12976c 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -803,7 +803,7 @@
-
+
From 95c6b17bdef105c13627986809247bc899e2fe97 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Thu, 22 Aug 2013 15:59:52 +0530
Subject: [PATCH 18/97] [IMP] improved the code
bzr revid: bde@tinyerp.com-20130822102952-3kep0jyz0gnbq5fx
---
addons/stock/procurement.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index e0c93957459..eae63e50642 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -86,7 +86,7 @@ class procurement_order(osv.osv):
'rule_id': procurement.rule_id.id,
'origin': procurement.origin,
'picking_type_id': procurement.rule_id.picking_type_id.id,
- 'price_unit': procurement.sale_line_id.product_id.standard_price
+ 'price_unit': procurement.sale_line_id.product_id and procurement.sale_line_id.product_id.standard_price,
}
def _run(self, cr, uid, procurement, context=None):
From 9e15fb27b6e2beda17d7f164e0b6999d07e6cd2a Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 22 Aug 2013 14:21:03 +0200
Subject: [PATCH 19/97] [WIP] rereserve + store on remaining qty in move +
remove route_id
bzr revid: jco@openerp.com-20130822122103-a4qgvukgho8vuwv9
---
addons/sale/sale_view.xml | 1 -
.../sale_stock_location_view.xml | 14 +++++++
addons/stock/stock.py | 39 ++++++++++++-------
.../test/stock_invoice_directly.yml | 2 +-
4 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index bc7353b771f..967350a88ac 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -397,7 +397,6 @@
-
diff --git a/addons/sale_stock_location/sale_stock_location_view.xml b/addons/sale_stock_location/sale_stock_location_view.xml
index 3d59828424c..2273831dce2 100644
--- a/addons/sale_stock_location/sale_stock_location_view.xml
+++ b/addons/sale_stock_location/sale_stock_location_view.xml
@@ -14,6 +14,20 @@
+
+
+ sale.order.line.form.sale.stock.location.open
+ sale.order.line
+
+
+
+
+
+
+
+
+
+
sale.order.line.tree.sale.stock.location
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 046ae6bff83..5a8e2641eff 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -697,19 +697,19 @@ class stock_picking(osv.osv):
quant_obj.quants_unreserve(cr, uid, move, context=context)
# if picking.location_id.usage != 'internal' and picking.location_dest_id.usage == 'internal': #When to create the pickings?
ops_list = [(x.id, x.product_uom_qty) for x in picking.pack_operation_ids]
- while ops_list:
- ops = ops_list.pop()
+ for ops in picking.pack_operation_ids:
#Find moves that correspond
- if ops[0].product_id:
- move_ids = move_obj.search(cr, uid, [('picking_id','=',picking.id), ('product_id', '=', ops[0].product_id), ('remaining_qty', '>', 0.0)], context=context)
- for move in move_obj.browse(cr, uid, move_ids, context=context):
- if move.remaining_qty > ops[1]:
- qty = ops[1]
+ if ops.product_id:
+ move_ids = move_obj.search(cr, uid, [('picking_id','=',picking.id), ('product_id', '=', ops.product_id), ('remaining_qty', '>', 0.0)], context=context)
+ qty_to_do = ops.product_uom_qty
+ while qty_to_do > 0 and move_ids:
+ move = move_obj.browse(cr, uid, move_ids.pop(), context=context)
+ if move.remaining_qty > qty_to_do:
+ qty = qty_to_do
+ qty_to_do = 0
else:
qty = move.remaining_qty
- # Add remaining quantity to the list
- if ops[1] - qty > 0:
- ops_list.append((ops[0] , ops[1] - qty),)
+ qty_to_do -= move.remaining_qty
if create and move.location_id != 'internal':
# Create quants
@@ -733,9 +733,12 @@ class stock_picking(osv.osv):
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order=prefered_order, context=context)
quant_obj.quants_reserve(cr, uid, quants, move, context=context)
elif ops[0].package_id:
- lines = ops.package_id.quant_ids #_get_package_lines
+ lines = ops[0].package_id.quant_ids #_get_package_lines
to_reserve = [(x.id, x.product_uom_qty) for x in lines if not x.reservation_id]
- quant_obj.quants_reserve(cr,uid, to_reserve, context=context)
+ for reserve in to_reserve:
+ move_ids = move_obj.search(cr, uid, [('picking_id', '=', picking.id), ('product_id', '=', reserve.product_id)])
+ quant_obj.quants_reserve(cr, uid, to_reserve, context=context)
+
#Need to check on which move
# for line in lines:
# if not line.reservation_id:
@@ -983,6 +986,14 @@ class stock_move(osv.osv):
res[move.id] = min(move.product_qty, availability)
return res
+
+ def _get_move(self, cr, uid, ids, context=None):
+ res = set()
+ for quant in self.browse(cr, uid, ids, context=context):
+ if quant.reservation_id:
+ res.add(quant.reservation_id.id)
+ return list(res)
+
_columns = {
'name': fields.char('Description', required=True, select=True),
'priority': fields.selection([('0', 'Not urgent'), ('1', 'Urgent')], 'Priority'),
@@ -1048,7 +1059,9 @@ class stock_move(osv.osv):
'quant_ids': fields.many2many('stock.quant', 'stock_quant_move_rel', 'move_id', 'quant_id', 'Quants'),
'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)]}),
+ '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)}),
'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'),
diff --git a/addons/stock_invoice_directly/test/stock_invoice_directly.yml b/addons/stock_invoice_directly/test/stock_invoice_directly.yml
index 53ecee5be8d..5e2daaccf4f 100644
--- a/addons/stock_invoice_directly/test/stock_invoice_directly.yml
+++ b/addons/stock_invoice_directly/test/stock_invoice_directly.yml
@@ -15,7 +15,7 @@
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.
-
From 79d4ed0b8fd8058ee990ccc2aeefa03de140e1fd Mon Sep 17 00:00:00 2001
From: "Pooja Zankhariya (OpenERP Trainee)"
Date: Thu, 22 Aug 2013 18:02:05 +0530
Subject: [PATCH 20/97] [IMP]Improved procurementexception yml
bzr revid: pooja.zakhariya@gmail.com-20130822123205-ia2qzcdy0ou7ltbv
---
addons/stock_complex_routes/__openerp__.py | 2 +-
.../test/procurementexception.yml | 98 ++++++++++++-------
2 files changed, 63 insertions(+), 37 deletions(-)
diff --git a/addons/stock_complex_routes/__openerp__.py b/addons/stock_complex_routes/__openerp__.py
index 5426e2c7aca..476066a78ed 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/procurementexception.yml'],
'installable': True,
'auto_install': True,
}
diff --git a/addons/stock_complex_routes/test/procurementexception.yml b/addons/stock_complex_routes/test/procurementexception.yml
index 67afc101089..f94bed726f0 100644
--- a/addons/stock_complex_routes/test/procurementexception.yml
+++ b/addons/stock_complex_routes/test/procurementexception.yml
@@ -1,37 +1,63 @@
--
- Create product with no seller_ids
-
-
--
- Create a sales order with 1 piece for that product and route crossdock
--
- !record{sale.order}
--
- Confirm sales order
--
- !python {
--
- Check there is a procurement in exception that has the procurement group of the sales order
--
- !python {
- assert
--
- Adjust the product that it has at least one seller_id
--
- !record{id: model: product.product) or in !python
--
- Run the Scheduler
--
- !python
--
- Check the status changed there is no procurement order in exception any more from that procurement group
--
- !python{model: procurement.order}
- search procurement from
--
- Check a purchase quotation was created
--
-
-
-
-
+ I create a product with no supplier define for it.
+-
+ !record {model: product.product, id: product_with_no_seller}:
+ name: 'product with no seller'
+ list_price: 20.00
+ standard_price: 15.00
+ categ_id: product.product_category_1
+-
+ I create a sales order with this product with route crossdock.
+-
+ !record {model: sale.order, id: sale_order_route_crossdock}:
+ partner_id: base.res_partner_2
+ partner_invoice_id: base.res_partner_address_3
+ partner_shipping_id: base.res_partner_address_3
+ note: crossdock route
+ payment_term: account.account_payment_term
+ order_line:
+ - product_id: product_with_no_seller
+ product_uom_qty: 1
+ route_id: stock_location.route_warehouse0_crossdock
+-
+ I confirm the sales order.
+-
+ !workflow {model: sale.order, ref: sale_order_route_crossdock, action: order_confirm}
+-
+ I check there is a procurement in exception that has the procurement group of the sales order created before.
+-
+ !python {model: procurement.order}: |
+ self.run_scheduler(cr, uid)
+ sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
+ proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')])
+ assert proc_id, 'No Procurement!'
+-
+ I set the at least one supplier on the product.
+-
+ !record {model: product.product, id: product_with_no_seller}:
+ seller_ids:
+ - delay: 1
+ name: base.res_partner_2
+ min_qty: 2.0
+-
+ I run the Scheduler.
+-
+ !python {model: procurement.order}: |
+ sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
+ proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')])
+ self.run(cr, uid, proc_id)
+-
+ I check the status changed there is no procurement order in exception any more from that procurement group
+-
+ !python {model: procurement.order}: |
+ sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
+ proc_id = self.search(cr, uid, [('group_id.name', '=', sale_id.name), ('state', '=', 'exception')])
+ assert not proc_id, 'Procurement should be in running state'
+-
+ I check a purchase quotation was created.
+-
+ !python {model: procurement.order}: |
+ sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
+ proc_ids = self.search(cr, uid, [('group_id.name', '=', sale_id.name)])
+ purchase_id = self.browse(cr, uid, proc_ids)[1].purchase_id
+ assert purchase_id, 'No Purchase Quotation is created'
From 67bcf36f137c2834965f9b55350db174b7c96b04 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Thu, 22 Aug 2013 18:21:50 +0530
Subject: [PATCH 21/97] [IMP] place lifo_price yml into complex_routs and make
changes
bzr revid: rma@tinyerp.com-20130822125150-zdj1lo96axkwor0e
---
addons/purchase/__openerp__.py | 28 +++++++-------
addons/stock_complex_routes/__openerp__.py | 2 +-
.../test/lifo_price.yml | 37 +++++++++++--------
3 files changed, 37 insertions(+), 30 deletions(-)
rename addons/{purchase => stock_complex_routes}/test/lifo_price.yml (76%)
diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py
index 56512be09da..36df07a95bd 100644
--- a/addons/purchase/__openerp__.py
+++ b/addons/purchase/__openerp__.py
@@ -67,20 +67,20 @@ Dashboard / Reports for Purchase Management will include:
'res_config_view.xml',
],
'test': [
- 'test/fifo_price.yml',
- 'test/fifo_returns.yml',
- #'test/costmethodchange.yml',
- 'test/process/cancel_order.yml',
- 'test/process/rfq2order2done.yml',
- 'test/process/generate_invoice_from_reception.yml',
- 'test/process/run_scheduler.yml',
- 'test/process/merge_order.yml',
- 'test/process/edi_purchase_order.yml',
- 'test/process/invoice_on_poline.yml',
- 'test/ui/print_report.yml',
- 'test/ui/duplicate_order.yml',
- 'test/ui/delete_order.yml',
- 'test/average_price.yml',
+# 'test/fifo_price.yml',
+# 'test/fifo_returns.yml',
+# #'test/costmethodchange.yml',
+# 'test/process/cancel_order.yml',
+# 'test/process/rfq2order2done.yml',
+# 'test/process/generate_invoice_from_reception.yml',
+# 'test/process/run_scheduler.yml',
+# 'test/process/merge_order.yml',
+# 'test/process/edi_purchase_order.yml',
+# 'test/process/invoice_on_poline.yml',
+# 'test/ui/print_report.yml',
+# 'test/ui/duplicate_order.yml',
+# 'test/ui/delete_order.yml',
+# 'test/average_price.yml',
'test/lifo_price.yml',
],
'demo': [
diff --git a/addons/stock_complex_routes/__openerp__.py b/addons/stock_complex_routes/__openerp__.py
index 5426e2c7aca..c9bdff7c7a8 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': ['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 76%
rename from addons/purchase/test/lifo_price.yml
rename to addons/stock_complex_routes/test/lifo_price.yml
index ea30317b996..5c3aa5bb3b6 100644
--- a/addons/purchase/test/lifo_price.yml
+++ b/addons/stock_complex_routes/test/lifo_price.yml
@@ -1,8 +1,15 @@
+-
+ For check product removal create removal strategy "LIFO"
+-
+ !record {model: product.removal, id: product_removal_lifo}:
+ product_categ_id: product.product_category_1
+ method: lifo
+ location_id: stock.stock_location_stock
-
- 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
+ removal_strategy_ids: product_removal_lifo
-
Set a product as using lifo price
-
@@ -58,10 +65,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 +80,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 +92,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 +100,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 +112,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
-
From 9690f9070a91dbf97095e9eff1c1accef1070b7e Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 22 Aug 2013 16:49:44 +0200
Subject: [PATCH 22/97] [WIP] Rereserve button with qty remaining and should
return ops remaining, adjust packing.yml, revert salestock view
bzr revid: jco@openerp.com-20130822144944-2bhuyziu7dk1asio
---
.../sale_stock_location_view.xml | 13 ----
addons/stock/stock.py | 75 ++++++++++++-------
addons/stock/stock_view.xml | 1 +
addons/stock/test/packing.yml | 64 ++++++++++++++--
4 files changed, 105 insertions(+), 48 deletions(-)
diff --git a/addons/sale_stock_location/sale_stock_location_view.xml b/addons/sale_stock_location/sale_stock_location_view.xml
index 2273831dce2..0a8ad68f060 100644
--- a/addons/sale_stock_location/sale_stock_location_view.xml
+++ b/addons/sale_stock_location/sale_stock_location_view.xml
@@ -15,19 +15,6 @@
-
- sale.order.line.form.sale.stock.location.open
- sale.order.line
-
-
-
-
-
-
-
-
-
-
sale.order.line.tree.sale.stock.location
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 5a8e2641eff..73a0f2ab4c0 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -687,21 +687,21 @@ class stock_picking(osv.osv):
def rereserve(self, cr, uid, picking_ids, create=False, context=None):
"""
This will unreserve all products and reserve the quants from the operations
+ :return: dictionary with quantities of quant operation and product that can not be matched with moves
"""
quant_obj = self.pool.get("stock.quant")
move_obj = self.pool.get("stock.move")
op_obj = self.pool.get("stock.pack.operation")
+ res = {}
for picking in self.browse(cr, uid, picking_ids, context=context):
# unreserve everything
for move in picking.move_lines:
quant_obj.quants_unreserve(cr, uid, move, context=context)
-# if picking.location_id.usage != 'internal' and picking.location_dest_id.usage == 'internal': #When to create the pickings?
- ops_list = [(x.id, x.product_uom_qty) for x in picking.pack_operation_ids]
for ops in picking.pack_operation_ids:
#Find moves that correspond
if ops.product_id:
- move_ids = move_obj.search(cr, uid, [('picking_id','=',picking.id), ('product_id', '=', ops.product_id), ('remaining_qty', '>', 0.0)], context=context)
- qty_to_do = ops.product_uom_qty
+ 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:
move = move_obj.browse(cr, uid, move_ids.pop(), context=context)
if move.remaining_qty > qty_to_do:
@@ -721,24 +721,35 @@ class stock_picking(osv.osv):
'history_ids': [(4, move.id)],
'in_date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'company_id': move.company_id.id,
- 'lot_id': ops[0].lot_id and ops.lot_id.id or False,
+ 'lot_id': ops.lot_id and ops.lot_id.id or False,
'reservation_id': move.id, #Reserve at once
- 'package_id': ops[0].result_package_id and ops[0].result_package_id.id or False,
+ 'package_id': ops.result_package_id and ops.result_package_id.id or False,
}
quant_id = quant_obj.create(cr, uid, vals, context=context)
else:
#Quants get
domain = [('reservation_id', '=', False)]
- prefered_order = op_obj._get_preferred_order(cr, uid, ops[0].id, context=context)
+ prefered_order = op_obj._get_preferred_order(cr, uid, ops.id, context=context)
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order=prefered_order, context=context)
quant_obj.quants_reserve(cr, uid, quants, move, context=context)
- elif ops[0].package_id:
- lines = ops[0].package_id.quant_ids #_get_package_lines
- to_reserve = [(x.id, x.product_uom_qty) for x in lines if not x.reservation_id]
- for reserve in to_reserve:
- move_ids = move_obj.search(cr, uid, [('picking_id', '=', picking.id), ('product_id', '=', reserve.product_id)])
- quant_obj.quants_reserve(cr, uid, to_reserve, context=context)
-
+ res[ops.id] = {}
+ res[ops.id][ops.product_id.id] = qty_to_do
+ elif ops.package_id:
+ quants = ops.package_id.quant_ids #_get_package_lines
+ for quant in quants:
+ move_ids = move_obj.search(cr, uid, [('picking_id', '=', picking.id), ('product_id', '=', quant.product_id.id), ('remaining_qty', '>', 0.0)])
+ qty_to_do = quant.qty
+ while qty_to_do > 0 and move_ids:
+ move = move_obj.browse(cr, uid, move_ids.pop(), context=context)
+ if move.remaining_qty > qty_to_do:
+ qty = qty_to_do
+ qty_to_do = 0
+ else:
+ qty = move.remaining_qty
+ qty_to_do -= move.remaining_qty
+ quant_obj.quants_reserve(cr, uid, [(quant.id, qty)], move, context=context)
+
+ #quant_obj.quants_reserve(cr, uid, to_reserve, context=context)
#Need to check on which move
# for line in lines:
# if not line.reservation_id:
@@ -945,21 +956,29 @@ class stock_move(osv.osv):
res[m.id] = uom_obj._compute_qty_obj(cr, uid, m.product_uom, m.product_uom_qty, m.product_id.uom_id)
return res
- def _get_remaining_qty(self, cr, uid, ids, field_name, args, context=None):
- #TODO: this function assumes that there aren't several stock move in the same picking with the same product. what should we do in that case?
- #TODO take care of the quant on stock moves too
- res = dict.fromkeys(ids, False)
- for move in self.browse(cr, uid, ids, context=context):
- res[move.id] = move.product_qty
- if move.picking_id:
- for op in move.picking_id.pack_operation_ids:
- if op.product_id == move.product_id or (op.quant_id and op.quant_id.product_id == move.product_id):
- res[move.id] -= op.product_qty
- if op.package_id:
- #find the product qty recursively
- res[move.id] -= self.pool.get('stock.quant.package')._get_product_total_qty(cr, uid, op.package_id, move.product_id.id, context=context)
- return res
+# def _get_remaining_qty(self, cr, uid, ids, field_name, args, context=None):
+# #TODO: this function assumes that there aren't several stock move in the same picking with the same product. what should we do in that case?
+# #TODO take care of the quant on stock moves too
+# res = dict.fromkeys(ids, False)
+# for move in self.browse(cr, uid, ids, context=context):
+# res[move.id] = move.product_qty
+# if move.picking_id:
+# for op in move.picking_id.pack_operation_ids:
+# if op.product_id == move.product_id or (op.quant_id and op.quant_id.product_id == move.product_id):
+# res[move.id] -= op.product_qty
+# if op.package_id:
+# #find the product qty recursively
+# res[move.id] -= self.pool.get('stock.quant.package')._get_product_total_qty(cr, uid, op.package_id, move.product_id.id, context=context)
+# return res
+ def _get_remaining_qty(self, cr, uid, ids, field_name, args, context=None):
+ res = {}
+ for move in self.browse(cr, uid, ids, context=context):
+ res[move.id] = move.product_uom_qty
+ for quant in move.reserved_quant_ids:
+ res[move.id] -= quant.qty
+ return res
+
def _get_lot_ids(self, cr, uid, ids, field_name, args, context=None):
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index f6a8c12976c..c0c6ba97976 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -583,6 +583,7 @@
+
diff --git a/addons/stock/test/packing.yml b/addons/stock/test/packing.yml
index a2b13fefe01..64f772268f4 100644
--- a/addons/stock/test/packing.yml
+++ b/addons/stock/test/packing.yml
@@ -1,5 +1,5 @@
-
- Create a new stockable product
+ Create a new stockable product
-
!record {model: product.product, id: packingtest}:
name: nice product
@@ -8,11 +8,61 @@
-
!record{model: stock.picking}: |
-
- Create move linked to picking
+ Confirm and assign picking and prepare partial
-
- !record{model:stock.move, id:}
--
- Confirm picking
--
- !python {model: stock.picking}: |
+ !python {model: stock.picking, id:}: |
self.action_confirm(cr, uid, ref())
+-
+ Put 120 pieces on Pallet 1 (package), 120 pieces on Pallet 2 with lot A and 60 pieces on Pallet 3
+-
+ !python {model: stock.picking, id:} |
+ #Change quantity of first to 120 and create 2 others quant operations
+ #Create package for each line and assign it as result_package_id
+-
+ Use button rereserve and check the qtyremaining on the moves are correct (=0)
+-
+
+-
+ Transfer the reception
+-
+
+-
+ Check the system created 3 quants one with 120 pieces on pallet 1, one with 120 pieces on pallet 2 with lot A and 60 pieces on pallet 3
+-
+
+-
+ Check there is no backorder or extra moves created
+-
+
+-
+ Make a delivery order of 300 pieces to the customer
+-
+
+-
+ Assign and confirm
+-
+
+-
+ Instead of doing the 300 pieces, you decide to take pallet 1 (do not mention product in operation here) and 20 pieces from lot A and 10 pieces from pallet 3
+-
+
+-
+ Process this picking
+-
+
+-
+ Check the quants that you have 120 pieces pallet 1 in customers, 100 pieces pallet 2 in stock and 20 with customers and 50 in stock, 10 in customers from pallet 3
+-
+
+-
+ Check a backorder was created and on that backorder, prepare partial and add an op with 20 pieces (20 that cannot be assigned) with lot B
+-
+
+-
+ Process this backorder
+-
+
+-
+ Check you have a negative quant because there were 20 too many that were transferred with lot B
+-
+
\ No newline at end of file
From b25e3805c08627dd4bbcc0934fe08236cbbfed87 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 22 Aug 2013 19:22:48 +0200
Subject: [PATCH 23/97] [WIP] Work further on splitting with return from
rereserve
bzr revid: jco@openerp.com-20130822172248-qebghuwimg2irns3
---
addons/stock/stock.py | 90 +++++++++++++++++++++++++++++--------------
1 file changed, 61 insertions(+), 29 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 73a0f2ab4c0..f4be5ee0bfa 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -687,16 +687,20 @@ class stock_picking(osv.osv):
def rereserve(self, cr, uid, picking_ids, create=False, context=None):
"""
This will unreserve all products and reserve the quants from the operations
- :return: dictionary with quantities of quant operation and product that can not be matched with moves
+ :return: tuple of dictionary with quantities of quant operation and product that can not be matched between ops and moves
+ and dictionary with remaining values on moves
+
"""
quant_obj = self.pool.get("stock.quant")
move_obj = self.pool.get("stock.move")
op_obj = self.pool.get("stock.pack.operation")
res = {}
+ res2 = {} #what is left from moves
for picking in self.browse(cr, uid, picking_ids, context=context):
- # unreserve everything
- for move in picking.move_lines:
+ # unreserve everything and initialize res2
+ for move in picking.move_lines:
quant_obj.quants_unreserve(cr, uid, move, context=context)
+ res2[move.id] = move.product_qty
for ops in picking.pack_operation_ids:
#Find moves that correspond
if ops.product_id:
@@ -732,6 +736,7 @@ class stock_picking(osv.osv):
prefered_order = op_obj._get_preferred_order(cr, uid, ops.id, context=context)
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order=prefered_order, context=context)
quant_obj.quants_reserve(cr, uid, quants, move, context=context)
+ res2[move.id] -= qty
res[ops.id] = {}
res[ops.id][ops.product_id.id] = qty_to_do
elif ops.package_id:
@@ -743,19 +748,15 @@ class stock_picking(osv.osv):
move = move_obj.browse(cr, uid, move_ids.pop(), context=context)
if move.remaining_qty > qty_to_do:
qty = qty_to_do
- qty_to_do = 0
+ qty_to_do = 0.0
else:
qty = move.remaining_qty
qty_to_do -= move.remaining_qty
quant_obj.quants_reserve(cr, uid, [(quant.id, qty)], move, context=context)
-
- #quant_obj.quants_reserve(cr, uid, to_reserve, context=context)
- #Need to check on which move
-# for line in lines:
-# if not line.reservation_id:
-# quant_obj.quants_reserve(cr, uid, [(line.id, line.product_uom_qty)], context=context)
-
-
+ res2[move.id] -= qty
+ res.setdefault(ops.id, {}).setdefault(quant.product_id.id, 0.0)
+ res[ops.id][quant.product_id.id] += qty_to_do
+ return (res, res2)
def do_partial(self, cr, uid, picking_ids, context=None):
@@ -766,27 +767,58 @@ class stock_picking(osv.osv):
#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:
self.action_done(cr, uid, [picking.id], context=context)
continue
- for op in picking.pack_operation_ids:
+ else:
+ #First thing that needs to happen is rereserving the quants
+ 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
+ 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)
+ qty = res[0][ops][prod]
+ if qty > 0:
+ #TODO: Maybe should try to reserve quants?
+ quant = False
+ move_id = stock_move_obj.create(cr, uid, {
+ 'name': product.name,
+ 'product_id': product.id,
+ 'product_uom_qty': qty,
+ 'product_uom': product.uom_id.id,
+ 'location_id': picking.location_id.id,
+ 'location_dest_id': picking.location_dest_id.id,
+ 'picking_id': picking.id,
+ 'reserved_quant_ids': quant and [(4, quant.id)] or [],
+ 'picking_type_id': picking.picking_type_id.id
+ }, context=context)
+ 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)
+# 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)
self._create_backorder(cr, uid, picking, context=context)
return True
@@ -1607,7 +1639,7 @@ class stock_move(osv.osv):
self.write(cr, uid, [move.id], {
'product_uom_qty': move.product_uom_qty - uom_qty,
'product_uos_qty': move.product_uos_qty - uos_qty,
- 'reserved_quant_ids': [(6,0,[])]
+# 'reserved_quant_ids': [(6,0,[])] SHOULD NOT CHANGE as it has been reserved already
}, context=context)
return new_move
From 15ac070679805fc4834d5d3bba30114e9b2f2218 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Fri, 23 Aug 2013 12:20:53 +0530
Subject: [PATCH 24/97] [IMP] improve code for lifo_price_yml
bzr revid: rma@tinyerp.com-20130823065053-phiq6p3tccck61fv
---
addons/stock_complex_routes/__openerp__.py | 2 +-
addons/stock_complex_routes/test/lifo_price.yml | 15 ++++++---------
addons/stock_location/stock_location.py | 2 +-
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/addons/stock_complex_routes/__openerp__.py b/addons/stock_complex_routes/__openerp__.py
index c9bdff7c7a8..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': ['lifo_price.yml'],
+ 'test': ['test/lifo_price.yml'],
'installable': True,
'auto_install': True,
}
diff --git a/addons/stock_complex_routes/test/lifo_price.yml b/addons/stock_complex_routes/test/lifo_price.yml
index 5c3aa5bb3b6..8365eb79f48 100644
--- a/addons/stock_complex_routes/test/lifo_price.yml
+++ b/addons/stock_complex_routes/test/lifo_price.yml
@@ -1,15 +1,12 @@
--
- For check product removal create removal strategy "LIFO"
--
- !record {model: product.removal, id: product_removal_lifo}:
- product_categ_id: product.product_category_1
- method: lifo
- location_id: stock.stock_location_stock
-
Set product category removal strategy as LIFO
-
- !record {model: product.category, id: product.product_category_1}:
- removal_strategy_ids: product_removal_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
-
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index 7f27496ff0d..8a389721733 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -215,7 +215,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'),
}
From b42f8b53db1c84c1e07e43bae27347565fef7497 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Fri, 23 Aug 2013 12:21:19 +0530
Subject: [PATCH 25/97] [IMP] improved _get_orders method and added
_get_orders_procurements method to complete the flow of Sale Order
bzr revid: bde@tinyerp.com-20130823065119-6yje7t9nyfi3r5fl
---
addons/sale_stock/sale_stock.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py
index 3163365ffc0..920be1793c1 100644
--- a/addons/sale_stock/sale_stock.py
+++ b/addons/sale_stock/sale_stock.py
@@ -57,11 +57,18 @@ class sale_order(osv.osv):
def _get_orders(self, cr, uid, ids, context=None):
res = set()
- for move in self.browse(cr, uid, ids, context=context):
+ for move in self.pool.get('stock.move').browse(cr, uid, ids, context=context):
if move.procurement_id and move.procurement_id.sale_line_id:
res.add(move.procurement_id.sale_line_id.order_id.id)
return list(res)
-
+
+ def _get_orders_procurements(self, cr, uid, ids, context=None):
+ res = set()
+ for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context):
+ if proc.sale_line_id:
+ res.add(proc.sale_line_id.order_id.id)
+ return list(res)
+
def _get_picking_ids(self, cr, uid, ids, name, args, context=None):
res = {}
for sale in self.browse(cr, uid, ids, context=context):
@@ -107,7 +114,10 @@ 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.function(_get_shipped, string='Delivered', type='boolean', store={'stock.move': (_get_orders, ['state'], 10)}),
+ 'shipped': fields.function(_get_shipped, string='Delivered', type='boolean', store={
+ 'stock.move': (_get_orders, ['state'], 10),
+ 'procurement.order': (_get_orders_procurements, ['state'], 10)
+ }),
'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'),
}
@@ -223,7 +233,7 @@ class sale_order(osv.osv):
self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'})
if write_cancel_ids:
self.pool.get('sale.order.line').write(cr, uid, write_cancel_ids, {'state': 'exception'})
-
+
if mode == 'finished':
return finished
elif mode == 'canceled':
@@ -265,7 +275,7 @@ class sale_order(osv.osv):
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
-
+
def _number_packages(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for line in self.browse(cr, uid, ids, context=context):
From a6cc542eef21107792c154d59903189f46a05997 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Fri, 23 Aug 2013 15:10:20 +0530
Subject: [PATCH 26/97] [IMP] run the scheduler after picking is done
bzr revid: bde@tinyerp.com-20130823094020-gacp65206rn8mxzv
---
addons/sale_stock/test/picking_order_policy.yml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index 0f63a16a335..f903d160400 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -39,11 +39,6 @@
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.move_ids[0].procure_method == order_line.type, "Procurement method is not correspond."
--
- I run the scheduler.
--
- !python {model: procurement.order}: |
- self.run_scheduler(cr, uid)
-
I check the details of delivery order after confirmed quotation.
-
@@ -88,6 +83,11 @@
data = pick.force_assign()
if data == True:
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.
-
From 290af983bc110f8f2fc4da167d89857bfadb25a0 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Fri, 23 Aug 2013 15:40:39 +0530
Subject: [PATCH 27/97] [IMP] remove extra changes
bzr revid: rma@tinyerp.com-20130823101039-ibhn7qz3t3ta288g
---
addons/purchase/__openerp__.py | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py
index 36df07a95bd..56512be09da 100644
--- a/addons/purchase/__openerp__.py
+++ b/addons/purchase/__openerp__.py
@@ -67,20 +67,20 @@ Dashboard / Reports for Purchase Management will include:
'res_config_view.xml',
],
'test': [
-# 'test/fifo_price.yml',
-# 'test/fifo_returns.yml',
-# #'test/costmethodchange.yml',
-# 'test/process/cancel_order.yml',
-# 'test/process/rfq2order2done.yml',
-# 'test/process/generate_invoice_from_reception.yml',
-# 'test/process/run_scheduler.yml',
-# 'test/process/merge_order.yml',
-# 'test/process/edi_purchase_order.yml',
-# 'test/process/invoice_on_poline.yml',
-# 'test/ui/print_report.yml',
-# 'test/ui/duplicate_order.yml',
-# 'test/ui/delete_order.yml',
-# 'test/average_price.yml',
+ 'test/fifo_price.yml',
+ 'test/fifo_returns.yml',
+ #'test/costmethodchange.yml',
+ 'test/process/cancel_order.yml',
+ 'test/process/rfq2order2done.yml',
+ 'test/process/generate_invoice_from_reception.yml',
+ 'test/process/run_scheduler.yml',
+ 'test/process/merge_order.yml',
+ 'test/process/edi_purchase_order.yml',
+ 'test/process/invoice_on_poline.yml',
+ 'test/ui/print_report.yml',
+ 'test/ui/duplicate_order.yml',
+ 'test/ui/delete_order.yml',
+ 'test/average_price.yml',
'test/lifo_price.yml',
],
'demo': [
From b412701b94e016c78d31120e94703a0fc3c86d61 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Fri, 23 Aug 2013 15:43:59 +0530
Subject: [PATCH 28/97] [IMP] improve code
bzr revid: rma@tinyerp.com-20130823101359-989r7eriohaey3xo
---
addons/stock_complex_routes/test/lifo_price.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock_complex_routes/test/lifo_price.yml b/addons/stock_complex_routes/test/lifo_price.yml
index 8365eb79f48..4bf1922c251 100644
--- a/addons/stock_complex_routes/test/lifo_price.yml
+++ b/addons/stock_complex_routes/test/lifo_price.yml
@@ -1,7 +1,7 @@
-
Set product category removal strategy as LIFO
-
- !record {model: product.category, id: product.product_category_001}:
+ !record {model: product.category, id: product.product_category_001}:
name : Lifo Category
removal_strategy_ids:
- product_categ_id: product.product_category_1
From 457d7f278e963a3eec9390b4888b18e8a563349a Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Mon, 26 Aug 2013 11:45:03 +0530
Subject: [PATCH 29/97] [IMP] change action_invoice_create method
bzr revid: rma@tinyerp.com-20130826061503-4r9lv7ywbhfffikj
---
.../test/process/generate_invoice_from_reception.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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.
-
From b97a9da42dfdbd5ec1bc76f2f0860e4f5f0cce0d Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Mon, 26 Aug 2013 12:44:05 +0530
Subject: [PATCH 30/97] [REVERT] reverted the changes in _get_orders method
bzr revid: bde@tinyerp.com-20130826071405-yax8hqw0esrll766
---
addons/sale_stock/sale_stock.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py
index 920be1793c1..015347449ae 100644
--- a/addons/sale_stock/sale_stock.py
+++ b/addons/sale_stock/sale_stock.py
@@ -57,7 +57,7 @@ class sale_order(osv.osv):
def _get_orders(self, cr, uid, ids, context=None):
res = set()
- for move in self.pool.get('stock.move').browse(cr, uid, ids, context=context):
+ for move in self.browse(cr, uid, ids, context=context):
if move.procurement_id and move.procurement_id.sale_line_id:
res.add(move.procurement_id.sale_line_id.order_id.id)
return list(res)
From 30685ddffb634397dc91e3398a0fe0a816d142db Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Mon, 26 Aug 2013 15:49:14 +0530
Subject: [PATCH 31/97] [IMP] overrided _run_move_create method to get standard
price of a product
bzr revid: bde@tinyerp.com-20130826101914-24jt4eqx8zqpvvbg
---
addons/sale/sale.py | 8 +++++++-
addons/stock/procurement.py | 1 -
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index f733cfd9ff1..fa041b11370 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -1082,4 +1082,10 @@ class procurement_order(osv.osv):
_defaults = {
'invoice_state': 'none',
}
-
+
+ def _run_move_create(self, cr, uid, procurement, context=None):
+ res = super(procurement_order, self)._run_move_create(cr, uid, procurement, context=context)
+ res.update({
+ 'price_unit': procurement.sale_line_id and procurement.sale_line_id.product_id and procurement.sale_line_id.product_id.standard_price or 0.0,
+ })
+ return res
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
index eae63e50642..7f36871b9d1 100644
--- a/addons/stock/procurement.py
+++ b/addons/stock/procurement.py
@@ -86,7 +86,6 @@ class procurement_order(osv.osv):
'rule_id': procurement.rule_id.id,
'origin': procurement.origin,
'picking_type_id': procurement.rule_id.picking_type_id.id,
- 'price_unit': procurement.sale_line_id.product_id and procurement.sale_line_id.product_id.standard_price,
}
def _run(self, cr, uid, procurement, context=None):
From c21e07a303e7f3037b69b296b3ddadaff7fb5c74 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 26 Aug 2013 12:32:24 +0200
Subject: [PATCH 32/97] [IMP] Remaining qty and store of reservation_id +
do_reserve for button
bzr revid: jco@openerp.com-20130826103224-2k224ekqtpzx920y
---
addons/stock/stock.py | 39 +++++++++++++++++++++++++++++--------
addons/stock/stock_view.xml | 4 ++--
2 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index f4be5ee0bfa..f40e4e7a806 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
#
@@ -684,6 +698,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 +725,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:
@@ -1112,7 +1134,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'),
@@ -2075,15 +2098,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..af3fa1153f4 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -583,7 +583,7 @@
-
+
@@ -804,7 +804,7 @@
-
+
From 56d0336f2cb8520e1921a92b8f8450e3f1d944bd Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 26 Aug 2013 13:51:17 +0200
Subject: [PATCH 33/97] [IMP] Adding price_unit on sales order line form
bzr revid: jco@openerp.com-20130826115117-xfdpc9h3jqokdxyp
---
addons/sale_stock_location/sale_stock_location_view.xml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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
-
+
+
+
+
From dc500465de96f216cd6e6238b76b42d3520bc672 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Mon, 26 Aug 2013 17:45:05 +0530
Subject: [PATCH 34/97] [IMP] optimize code
bzr revid: rma@tinyerp.com-20130826121505-ags8sgw4ufixc9fl
---
addons/account_anglo_saxon/test/anglo_saxon.yml | 8 ++++----
addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 2dadc420e41..3ea85fc0d73 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -124,8 +124,8 @@
Reception is ready for process so now done the reception.
-
!python {model: stock.picking}: |
- order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001")).picking_ids[0]
- order.do_partial(context=context)
+ 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.
-
@@ -216,8 +216,8 @@
I process the delivery.
-
!python {model: stock.picking}: |
- pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001"))
- pick_order.do_partial(context=context)
+ 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 4e9eb5d3738..bb6200e148b 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -132,8 +132,8 @@
Reception is ready for process so now done the reception.
-
!python {model: stock.picking}: |
- order = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_001_fifo")).picking_ids[0]
- order.do_partial(context=context)
+ 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.
-
@@ -216,8 +216,8 @@
I process the delivery.
-
!python {model: stock.picking}: |
- pick_order = self.pool.get('stock.picking').browse(cr, uid, ref("stock_picking_out001_fifo"))
- pick_order.do_partial(context=context)
+ 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.
-
From 9b1690ac56dff6513c424be88d94bf0dabb8dfca Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 26 Aug 2013 15:03:22 +0200
Subject: [PATCH 35/97] [IMP] Moves too many are processed, moves short go in
backorder. Needs refresh of picking for backorder
bzr revid: jco@openerp.com-20130826130322-bbk8yxdeug7o18dl
---
addons/stock/stock.py | 27 ++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index f40e4e7a806..c0c73d30603 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -786,9 +786,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:
@@ -799,6 +796,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)
@@ -817,31 +815,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
@@ -1482,7 +1464,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:
From ca1f4566b7c5ce8840a8b820424c18aa2bc962fe Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 26 Aug 2013 17:36:48 +0200
Subject: [PATCH 36/97] [IMP] Back order should not give traceback and
destination move should take quants from original move as reserved quants
into account for quantity to reserve when assigned.
bzr revid: jco@openerp.com-20130826153648-e7bxt0btvcsb1jun
---
addons/stock/stock.py | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index c0c73d30603..54f473f75c1 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -624,16 +624,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 {}
@@ -1016,7 +1018,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):
@@ -1419,6 +1420,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
From 8a3640f70eff3543dccad922ae36a3c77f43a76e Mon Sep 17 00:00:00 2001
From: "Pooja Zankhariya (OpenERP Trainee)"
Date: Tue, 27 Aug 2013 14:33:25 +0530
Subject: [PATCH 37/97] [IMP]Improved Code
bzr revid: pooja.zakhariya@gmail.com-20130827090325-umd88itb3p16v6ry
---
addons/stock_complex_routes/test/procurementexception.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/addons/stock_complex_routes/test/procurementexception.yml b/addons/stock_complex_routes/test/procurementexception.yml
index f94bed726f0..e5c7dbfd72c 100644
--- a/addons/stock_complex_routes/test/procurementexception.yml
+++ b/addons/stock_complex_routes/test/procurementexception.yml
@@ -40,7 +40,7 @@
name: base.res_partner_2
min_qty: 2.0
-
- I run the Scheduler.
+ I run the Procurement.
-
!python {model: procurement.order}: |
sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
@@ -59,5 +59,5 @@
!python {model: procurement.order}: |
sale_id = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_route_crossdock"))
proc_ids = self.search(cr, uid, [('group_id.name', '=', sale_id.name)])
- purchase_id = self.browse(cr, uid, proc_ids)[1].purchase_id
+ purchase_id = [proc.purchase_id for proc in self.browse(cr, uid, proc_ids) if proc.purchase_id]
assert purchase_id, 'No Purchase Quotation is created'
From cc4764f48fde77fc37f77d6e6e318a811da01e60 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Tue, 27 Aug 2013 14:42:17 +0530
Subject: [PATCH 38/97] [REVERT] reverted price_unit changes
bzr revid: bde@tinyerp.com-20130827091217-9l7wbz2v6weaxuoz
---
addons/sale/sale.py | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 354a3b48301..83ec686b898 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -1082,10 +1082,4 @@ class procurement_order(osv.osv):
_defaults = {
'invoice_state': 'none',
}
-
- def _run_move_create(self, cr, uid, procurement, context=None):
- res = super(procurement_order, self)._run_move_create(cr, uid, procurement, context=context)
- res.update({
- 'price_unit': procurement.sale_line_id and procurement.sale_line_id.product_id and procurement.sale_line_id.product_id.standard_price or 0.0,
- })
- return res
+
\ No newline at end of file
From 72e1113082a87664c3f52ec25b8ced327fe896e5 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Tue, 27 Aug 2013 15:47:09 +0530
Subject: [PATCH 39/97] [IMP] assigned picking_policy of SO in move_type of
procurement.group
bzr revid: bde@tinyerp.com-20130827101709-8mp60l9rke2rpcqj
---
addons/sale/sale.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 83ec686b898..6535ed7bc6d 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -658,7 +658,7 @@ class sale_order(osv.osv):
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, 'partner_id': order.partner_shipping_id.id
+ 'name': order.name, 'partner_id': order.partner_shipping_id.id, 'move_type': order.picking_policy
}, context=context)
order.write({'procurement_group_id': group_id}, context=context)
for line in order.order_line:
From efc01a8a8473dd5ad86e6c23f397c18e886bd00d Mon Sep 17 00:00:00 2001
From: "Pooja Zankhariya (OpenERP Trainee)"
Date: Tue, 27 Aug 2013 16:49:39 +0530
Subject: [PATCH 40/97] [IMP]Replaced type with picking_type_id
bzr revid: pooja.zakhariya@gmail.com-20130827111939-t7memjjkn08yhbum
---
addons/point_of_sale/point_of_sale.py | 2 +-
addons/point_of_sale/wizard/pos_return.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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, {
From ea3b868f4eebe0523669ea2d5b267a4e2f4399da Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Tue, 27 Aug 2013 15:33:24 +0200
Subject: [PATCH 41/97] [IMP] Destination routes in procurement view
bzr revid: jco@openerp.com-20130827133324-uqlja1012515uxx5
---
addons/stock_location/stock_location_view.xml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index 4846ac70644..c50a6ca8a94 100644
--- a/addons/stock_location/stock_location_view.xml
+++ b/addons/stock_location/stock_location_view.xml
@@ -211,5 +211,17 @@
+
+
+
+ procurement.order.form.view.inherit
+
+ procurement.order
+
+
+
+
+
+
From d1febb7b8e908f8de947e646c9562b09ef6d9cc9 Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Tue, 27 Aug 2013 17:25:28 +0200
Subject: [PATCH 42/97] [FIX]push/pull rules, picking type should be required
except for pull rule with type manufacture
bzr revid: csn@openerp.com-20130827152528-wm5m8zynlzjjfor9
---
addons/stock/procurement.py | 2 +-
addons/stock/stock_view.xml | 33 ++++++++++++++++++-
addons/stock_location/stock_location.py | 2 +-
addons/stock_location/stock_location_view.xml | 20 +++++++++++
4 files changed, 54 insertions(+), 3 deletions(-)
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_view.xml b/addons/stock/stock_view.xml
index af3fa1153f4..e76ce99855c 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -1451,10 +1451,41 @@
-
+
+
+
+
+ stock.procurement.form
+ procurement.rule
+
+
+
+
+
+
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index 8a389721733..5e58b918cb6 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -60,7 +60,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',
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index 8a42f2afb46..4846ac70644 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
From f9cef80977b798d376594dfc73b677afc07f4eaa Mon Sep 17 00:00:00 2001
From: "Pooja Zankhariya (OpenERP Trainee)"
Date: Tue, 27 Aug 2013 19:39:26 +0530
Subject: [PATCH 43/97] [IMP]Moved stock invoice onshipping wizard to
stock_account
bzr revid: pooja.zakhariya@gmail.com-20130827140926-hegue0mvvdxluqnf
---
addons/sale_stock/__init__.py | 1 -
addons/sale_stock/__openerp__.py | 1 -
addons/sale_stock/wizard/__init__.py | 22 -------------------
addons/stock_account/__openerp__.py | 1 +
addons/stock_account/wizard/__init__.py | 1 +
.../wizard/stock_invoice_onshipping.py | 0
.../wizard/stock_invoice_onshipping_view.xml | 0
7 files changed, 2 insertions(+), 24 deletions(-)
delete mode 100644 addons/sale_stock/wizard/__init__.py
rename addons/{sale_stock => stock_account}/wizard/stock_invoice_onshipping.py (100%)
rename addons/{sale_stock => stock_account}/wizard/stock_invoice_onshipping_view.xml (100%)
diff --git a/addons/sale_stock/__init__.py b/addons/sale_stock/__init__.py
index 9c74739d4c9..f521debcea5 100644
--- a/addons/sale_stock/__init__.py
+++ b/addons/sale_stock/__init__.py
@@ -24,5 +24,4 @@ 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/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/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/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
From 5400aec81bdd9355f90d7cfa44f8ee72adc227d8 Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Wed, 28 Aug 2013 14:49:12 +0200
Subject: [PATCH 44/97] [FIX]add warehouse_id to route and show all routes
associated to a warehouse on the warehouse form view
bzr revid: csn@openerp.com-20130828124912-9mvmbzvxmbq02me2
---
addons/stock/stock_view.xml | 2 ++
addons/stock_location/stock_location.py | 9 +++++++++
addons/stock_location/stock_location_view.xml | 10 ++++++++++
3 files changed, 21 insertions(+)
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index e76ce99855c..4488074293e 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -493,6 +493,7 @@
stock.warehouse
+
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index 5e58b918cb6..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'),
}
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index c50a6ca8a94..6c5cc042fef 100644
--- a/addons/stock_location/stock_location_view.xml
+++ b/addons/stock_location/stock_location_view.xml
@@ -157,6 +157,14 @@
+
+
+
+
+
+
+
+
@@ -167,6 +175,7 @@
+
@@ -179,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.
@@ -229,7 +229,7 @@
procurement.order
-
+
From 57c80c4bc10828ccf9e11d895b059aac4919ba20 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Wed, 28 Aug 2013 17:32:10 +0200
Subject: [PATCH 46/97] [IMP] Adapt average yml and push flow yml, put stock.py
from sale_stock in stock_account
bzr revid: jco@openerp.com-20130828153210-cn97txe5046vo4nk
---
addons/purchase/test/average_price.yml | 27 +--
addons/sale_stock/__init__.py | 1 -
addons/sale_stock/sale_stock_view.xml | 14 --
addons/sale_stock/stock.py | 176 ------------------
addons/stock_account/__init__.py | 1 +
addons/stock_account/stock_account.py | 6 +
addons/stock_account/stock_account_view.xml | 16 ++
.../test/stock_location_push_flow.yml | 2 +
8 files changed, 34 insertions(+), 209 deletions(-)
delete mode 100644 addons/sale_stock/stock.py
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/sale_stock/__init__.py b/addons/sale_stock/__init__.py
index f521debcea5..72b3d5672d5 100644
--- a/addons/sale_stock/__init__.py
+++ b/addons/sale_stock/__init__.py
@@ -20,7 +20,6 @@
##############################################################################
import sale_stock
-import stock
import report
import company
import res_config
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/stock.py b/addons/sale_stock/stock.py
deleted file mode 100644
index e404ab3dd7b..00000000000
--- a/addons/sale_stock/stock.py
+++ /dev/null
@@ -1,176 +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 .
-#
-##############################################################################
-
-from openerp.osv import fields, osv
-from openerp.tools.translate import _
-
-
-class stock_picking(osv.osv):
- _inherit = 'stock.picking'
- def __get_invoice_state(self, cr, uid, ids, name, arg, context=None):
- result = {}
- for pick in self.browse(cr, uid, ids, context=context):
- result[pick.id] = 'none'
- for move in pick.move_lines:
- if move.procurement_id:
- if move.procurement_id.invoice_state=='invoiced':
- result[pick.id] = 'invoiced'
- elif move.procurement_id.invoice_state=='2binvoiced':
- result[pick.id] = '2binvoiced'
- break
- return result
-
- def __get_picking_procurement(self, cr, uid, ids, context={}):
- result = {}
- for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context):
- for move in proc.move_ids:
- if move.picking_id:
- result[move.picking_id.id] = True
- return result.keys()
-
- def __get_picking_move(self, cr, uid, ids, context={}):
- res = []
- for move in self.pool.get('stock.move').browse(cr, uid, ids, context=context):
- if move.picking_id:
- res.append(move.picking_id.id)
- return res
-
- _columns = {
- 'invoice_state': fields.function(__get_invoice_state, type='selection', selection=[
- ("invoiced", "Invoiced"),
- ("2binvoiced", "To Be Invoiced"),
- ("none", "Not Applicable")
- ], string="Invoice Control", required=True,
- store={
- 'procurement.order': (__get_picking_procurement, ['invoice_state'], 10),
- 'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['state'], 10),
- 'stock.move': (__get_picking_move, ['picking_id'], 10),
- },
- ),
- }
- _defaults = {
- 'invoice_state': lambda *args, **argv: 'none'
- }
-
- def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None):
- """ Creates invoice based on the invoice state selected for picking.
- @param journal_id: Id of journal
- @param group: Whether to create a group invoice or not
- @param type: Type invoice to be created
- @return: Ids of created invoices for the pickings
- """
- context = context or {}
- todo = {}
- for picking in self.browse(cr, uid, ids, context=context):
- key = group and picking.id or True
- for move in picking.move_lines:
- if move.procurement_id and (move.procurement_id.invoice_state=='2binvoiced'):
- if (move.state <> 'cancel') and not move.scrapped:
- todo.setdefault(key, [])
- todo[key].append(move)
- invoices = []
- for moves in todo.values():
- invoices = self.__invoice_create_line(cr, uid, moves, journal_id, type, context=context)
- return invoices
-
- def __invoice_create_line(self, cr, uid, moves, journal_id=False, inv_type='out_invoice', context=None):
- invoice_obj = self.pool.get('account.invoice')
- invoices = {}
- for move in moves:
- sale_line = move.procurement_id.sale_line_id
- sale = sale_line.order_id
- partner = sale.partner_invoice_id
-
- currency_id = sale.pricelist_id.currency_id.id
- key = (partner.id, currency_id, sale.company_id.id, sale.user_id and sale.user_id.id or False)
-
- if key not in invoices:
- # Get account and payment terms
- if inv_type in ('out_invoice', 'out_refund'):
- account_id = partner.property_account_receivable.id
- payment_term = partner.property_payment_term.id or False
- else:
- account_id = partner.property_account_payable.id
- payment_term = partner.property_supplier_payment_term.id or False
-
- invoice_id = invoice_obj.create(cr, uid, {
- 'origin': sale.name,
- 'date_invoice': context.get('date_inv', False),
- 'user_id': sale.user_id and sale.user_id.id or False,
- 'partner_id': partner.id,
- 'account_id': account_id,
- 'payment_term': payment_term,
- 'type': inv_type,
- 'fiscal_position': partner.property_account_position.id,
- 'company_id': sale.company_id.id,
- 'currency_id': sale.pricelist_id.currency_id.id,
- 'journal_id': journal_id,
- }, context=context)
- invoices[key] = invoice_id
-
- # Get account_id
- if inv_type in ('out_invoice', 'out_refund'):
- account_id = move.product_id.property_account_income.id
- if not account_id:
- account_id = move.product_id.categ_id.property_account_income_categ.id
- else:
- account_id = move.product_id.property_account_expense.id
- if not account_id:
- account_id = move.product_id.categ_id.property_account_expense_categ.id
- fp_obj = self.pool.get('account.fiscal.position')
- fiscal_position = partner.property_account_position
- account_id = fp_obj.map_account(cr, uid, fiscal_position, account_id)
-
- # set UoS if it's a sale and the picking doesn't have one
- if move.product_uos:
- uos_id = move.product_uos.id
- quantity = move.product_uos_qty
- else:
- uos_id = move.product_uom.id
- quantity = move.product_uom_qty
-
- invoice_line_id = self.pool.get('account.invoice.line').create(cr, uid, {
- 'name': move.name,
- 'origin': move.picking_id and move.picking_id.origin or False,
- 'invoice_id': invoices[key],
- 'account_id': account_id,
- 'product_id': move.product_id.id,
- 'uos_id': uos_id,
- 'quantity': quantity,
- 'price_unit': sale_line.price_unit,
- 'discount': sale_line.discount,
- 'invoice_line_tax_id': [(6, 0, [x.id for x in sale_line.tax_id])],
- 'account_analytic_id': sale.project_id and sale.project_id.id or False,
- }, context=context)
-
- self.pool.get('sale.order.line').write(cr, uid, [sale_line.id], {
- 'invoice_lines': [(4, invoice_line_id)]
- }, context=context)
- self.pool.get('sale.order').write(cr, uid, [sale.id], {
- 'invoice_ids': [(4, invoices[key])],
- })
-
- self.pool.get('procurement.order').write(cr, uid, [move.procurement_id.id], {
- 'invoice_state': 'invoiced',
- }, context=context)
-
- invoice_obj.button_compute(cr, uid, invoices.values(), context=context, set_total=(inv_type in ('in_invoice', 'in_refund')))
- return invoices.values()
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/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_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
From 5ca2f661a6b8ad45b4a9c472e729e76aa1d44e80 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 29 Aug 2013 09:34:27 +0200
Subject: [PATCH 47/97] [ADD] As stock.py moved, we need to add it
bzr revid: jco@openerp.com-20130829073427-mdx76slvnkr939gq
---
.../wizard/orderpoint_procurement_view.xml | 3 +-
addons/stock_account/stock.py | 176 ++++++++++++++++++
2 files changed, 178 insertions(+), 1 deletion(-)
create mode 100644 addons/stock_account/stock.py
diff --git a/addons/stock/wizard/orderpoint_procurement_view.xml b/addons/stock/wizard/orderpoint_procurement_view.xml
index 227b79b3234..f542db4dd94 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/stock.py b/addons/stock_account/stock.py
new file mode 100644
index 00000000000..e404ab3dd7b
--- /dev/null
+++ b/addons/stock_account/stock.py
@@ -0,0 +1,176 @@
+# -*- 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 .
+#
+##############################################################################
+
+from openerp.osv import fields, osv
+from openerp.tools.translate import _
+
+
+class stock_picking(osv.osv):
+ _inherit = 'stock.picking'
+ def __get_invoice_state(self, cr, uid, ids, name, arg, context=None):
+ result = {}
+ for pick in self.browse(cr, uid, ids, context=context):
+ result[pick.id] = 'none'
+ for move in pick.move_lines:
+ if move.procurement_id:
+ if move.procurement_id.invoice_state=='invoiced':
+ result[pick.id] = 'invoiced'
+ elif move.procurement_id.invoice_state=='2binvoiced':
+ result[pick.id] = '2binvoiced'
+ break
+ return result
+
+ def __get_picking_procurement(self, cr, uid, ids, context={}):
+ result = {}
+ for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context):
+ for move in proc.move_ids:
+ if move.picking_id:
+ result[move.picking_id.id] = True
+ return result.keys()
+
+ def __get_picking_move(self, cr, uid, ids, context={}):
+ res = []
+ for move in self.pool.get('stock.move').browse(cr, uid, ids, context=context):
+ if move.picking_id:
+ res.append(move.picking_id.id)
+ return res
+
+ _columns = {
+ 'invoice_state': fields.function(__get_invoice_state, type='selection', selection=[
+ ("invoiced", "Invoiced"),
+ ("2binvoiced", "To Be Invoiced"),
+ ("none", "Not Applicable")
+ ], string="Invoice Control", required=True,
+ store={
+ 'procurement.order': (__get_picking_procurement, ['invoice_state'], 10),
+ 'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['state'], 10),
+ 'stock.move': (__get_picking_move, ['picking_id'], 10),
+ },
+ ),
+ }
+ _defaults = {
+ 'invoice_state': lambda *args, **argv: 'none'
+ }
+
+ def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None):
+ """ Creates invoice based on the invoice state selected for picking.
+ @param journal_id: Id of journal
+ @param group: Whether to create a group invoice or not
+ @param type: Type invoice to be created
+ @return: Ids of created invoices for the pickings
+ """
+ context = context or {}
+ todo = {}
+ for picking in self.browse(cr, uid, ids, context=context):
+ key = group and picking.id or True
+ for move in picking.move_lines:
+ if move.procurement_id and (move.procurement_id.invoice_state=='2binvoiced'):
+ if (move.state <> 'cancel') and not move.scrapped:
+ todo.setdefault(key, [])
+ todo[key].append(move)
+ invoices = []
+ for moves in todo.values():
+ invoices = self.__invoice_create_line(cr, uid, moves, journal_id, type, context=context)
+ return invoices
+
+ def __invoice_create_line(self, cr, uid, moves, journal_id=False, inv_type='out_invoice', context=None):
+ invoice_obj = self.pool.get('account.invoice')
+ invoices = {}
+ for move in moves:
+ sale_line = move.procurement_id.sale_line_id
+ sale = sale_line.order_id
+ partner = sale.partner_invoice_id
+
+ currency_id = sale.pricelist_id.currency_id.id
+ key = (partner.id, currency_id, sale.company_id.id, sale.user_id and sale.user_id.id or False)
+
+ if key not in invoices:
+ # Get account and payment terms
+ if inv_type in ('out_invoice', 'out_refund'):
+ account_id = partner.property_account_receivable.id
+ payment_term = partner.property_payment_term.id or False
+ else:
+ account_id = partner.property_account_payable.id
+ payment_term = partner.property_supplier_payment_term.id or False
+
+ invoice_id = invoice_obj.create(cr, uid, {
+ 'origin': sale.name,
+ 'date_invoice': context.get('date_inv', False),
+ 'user_id': sale.user_id and sale.user_id.id or False,
+ 'partner_id': partner.id,
+ 'account_id': account_id,
+ 'payment_term': payment_term,
+ 'type': inv_type,
+ 'fiscal_position': partner.property_account_position.id,
+ 'company_id': sale.company_id.id,
+ 'currency_id': sale.pricelist_id.currency_id.id,
+ 'journal_id': journal_id,
+ }, context=context)
+ invoices[key] = invoice_id
+
+ # Get account_id
+ if inv_type in ('out_invoice', 'out_refund'):
+ account_id = move.product_id.property_account_income.id
+ if not account_id:
+ account_id = move.product_id.categ_id.property_account_income_categ.id
+ else:
+ account_id = move.product_id.property_account_expense.id
+ if not account_id:
+ account_id = move.product_id.categ_id.property_account_expense_categ.id
+ fp_obj = self.pool.get('account.fiscal.position')
+ fiscal_position = partner.property_account_position
+ account_id = fp_obj.map_account(cr, uid, fiscal_position, account_id)
+
+ # set UoS if it's a sale and the picking doesn't have one
+ if move.product_uos:
+ uos_id = move.product_uos.id
+ quantity = move.product_uos_qty
+ else:
+ uos_id = move.product_uom.id
+ quantity = move.product_uom_qty
+
+ invoice_line_id = self.pool.get('account.invoice.line').create(cr, uid, {
+ 'name': move.name,
+ 'origin': move.picking_id and move.picking_id.origin or False,
+ 'invoice_id': invoices[key],
+ 'account_id': account_id,
+ 'product_id': move.product_id.id,
+ 'uos_id': uos_id,
+ 'quantity': quantity,
+ 'price_unit': sale_line.price_unit,
+ 'discount': sale_line.discount,
+ 'invoice_line_tax_id': [(6, 0, [x.id for x in sale_line.tax_id])],
+ 'account_analytic_id': sale.project_id and sale.project_id.id or False,
+ }, context=context)
+
+ self.pool.get('sale.order.line').write(cr, uid, [sale_line.id], {
+ 'invoice_lines': [(4, invoice_line_id)]
+ }, context=context)
+ self.pool.get('sale.order').write(cr, uid, [sale.id], {
+ 'invoice_ids': [(4, invoices[key])],
+ })
+
+ self.pool.get('procurement.order').write(cr, uid, [move.procurement_id.id], {
+ 'invoice_state': 'invoiced',
+ }, context=context)
+
+ invoice_obj.button_compute(cr, uid, invoices.values(), context=context, set_total=(inv_type in ('in_invoice', 'in_refund')))
+ return invoices.values()
From b9e31237647a98e344b392db4d2731e9e2bbf25b Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Thu, 29 Aug 2013 09:35:16 +0200
Subject: [PATCH 48/97] [IMP]purchase: add picking_type field and set it by
default as picking in
bzr revid: csn@openerp.com-20130829073516-48qqx63o897ins11
---
addons/purchase/purchase.py | 8 +++++++-
addons/purchase/purchase_view.xml | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
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 @@
+
From b2995fc6da5e5bb0de1f606dfab3bb7ca3f18972 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 29 Aug 2013 10:35:43 +0200
Subject: [PATCH 49/97] [FIX] Move menuitem orderpoint, so it loads correctly
bzr revid: jco@openerp.com-20130829083543-dp4i7of9ktg06hho
---
addons/stock/stock_view.xml | 1 +
addons/stock/wizard/orderpoint_procurement_view.xml | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 4488074293e..30038952ce7 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -1571,6 +1571,7 @@
+
diff --git a/addons/stock/wizard/orderpoint_procurement_view.xml b/addons/stock/wizard/orderpoint_procurement_view.xml
index f542db4dd94..20250bb78dd 100644
--- a/addons/stock/wizard/orderpoint_procurement_view.xml
+++ b/addons/stock/wizard/orderpoint_procurement_view.xml
@@ -32,6 +32,6 @@
key2="client_action_multi"
id="action_procurement_compute"/>
-
+
From 7be335a9761af1eb8116ed3145b2e2cf105f0df4 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 29 Aug 2013 11:04:31 +0200
Subject: [PATCH 50/97] [IMP] When copying will check if not passing
backorder_id in copy already (from sgo)
bzr revid: jco@openerp.com-20130829090431-65dypmn1tjgr8pbt
---
addons/stock/stock.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 54f473f75c1..740e60b9a50 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -530,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):
From b1611b9fa7332d46c1959841685d93d76b176003 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 29 Aug 2013 11:53:27 +0200
Subject: [PATCH 51/97] [IMP] Remove procure_method in timesheet (branch bde)
bzr revid: jco@openerp.com-20130829095327-jn9b06q1b3g3n07i
---
.../test/worktask_entry_to_timesheetline_entry.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml
index 99e5fc41401..2d95eb89d71 100644
--- a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml
+++ b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml
@@ -14,8 +14,7 @@
!record {model: product.product, id: product_product_hrmanger0}:
categ_id: product.product_category_6
mes_type: fixed
- name: HR Manger
- procure_method: make_to_stock
+ name: HR Manager
standard_price: 1.0
supply_method: buy
type: service
From c729a2529fc0e2e70ea8842724ca96f990397907 Mon Sep 17 00:00:00 2001
From: "Sanjay Gohel (OpenERP)"
Date: Thu, 29 Aug 2013 15:28:33 +0530
Subject: [PATCH 52/97] [IMP]improve shipment yml and stock procrule yml
bzr revid: sgo@tinyerp.com-20130829095833-iph2zy1f89wvic2i
---
addons/stock/__openerp__.py | 1 +
addons/stock/test/procrule.yml | 48 +++++++++++++++-----
addons/stock/test/shipment.yml | 82 +++++++++++++++-------------------
3 files changed, 74 insertions(+), 57 deletions(-)
diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py
index 57019053481..fb3983ff319 100644
--- a/addons/stock/__openerp__.py
+++ b/addons/stock/__openerp__.py
@@ -91,6 +91,7 @@ Dashboard / Reports for Warehouse Management will include:
'test': [
'test/inventory.yml',
'test/move.yml',
+ 'test/procrule.yml',
# 'test/shipment.yml',
],
'installable': True,
diff --git a/addons/stock/test/procrule.yml b/addons/stock/test/procrule.yml
index d1762ae4806..cf9e28d350f 100644
--- a/addons/stock/test/procrule.yml
+++ b/addons/stock/test/procrule.yml
@@ -1,22 +1,46 @@
-
Create new global procurement rule from Stock -> Output
-
- !record {model: procurement.rule, ref:}
- location_id: stock
- location_dest_id: output
+ !record {model: procurement.rule, id: global_proc_rule}:
+ name: Stock -> output
+ action: move
+ picking_type_id: stock.picking_type_out
+ location_src_id: stock.stock_location_stock
+ location_id: stock.stock_location_output
-
Create Delivery Order from Output -> Customer
-
- !record {model: stock.picking, ref:}
+ !record {model: stock.picking, id: pick_output}:
+ name: Delivery order for procurement
+ partner_id: base.res_partner_2
+ picking_type_id: stock.picking_type_out
+ move_lines:
+ - product_id: product.product_product_3
+ product_uom_qty: 10.00
+ location_id: stock.stock_location_output
+ location_dest_id: stock.stock_location_customers
-
- Confirm delivery order
+ Confirm delivery order.
-
-
+ !python {model: stock.picking}: |
+ self.action_confirm(cr, uid, [ref('pick_output')])
+-
+ Create procurement in output related to this delivery order.
+-
+ !record {model: procurement.order, id: proc_order_stock_output}:
+ product_id: product.product_product_3
+ product_qty: 10.00
+ rule_id: global_proc_rule
+ location_id: stock.stock_location_output
+ name: Procurement for stock to output
+-
+ I run scheduler.
+-
+ !python {model: procurement.order}: |
+ self.run_scheduler(cr, uid)
-
- Check procurement was created in output (as there is the global procurement rule) related to this delivery order
+ Check a picking was created from stock to output.
-
-
--
- Check a picking was created from stock to output
--
-
+ !python {model: stock.move }: |
+ move_id = self.search(cr, uid, [('product_id', '=', ref('product.product_product_3')),('location_id', '=', ref('stock.stock_location_stock')),('location_dest_id', '=', ref('stock.stock_location_output'))])
+ assert len(move_id) == 1
diff --git a/addons/stock/test/shipment.yml b/addons/stock/test/shipment.yml
index 70f9b14c57a..2616bd2d1c0 100644
--- a/addons/stock/test/shipment.yml
+++ b/addons/stock/test/shipment.yml
@@ -1,7 +1,8 @@
-
I confirm outgoing shipment of 130 kgm Ice-cream.
-
- !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment}
+ !python {model: stock.picking}: |
+ self.action_confirm(cr, uid, [ref("outgoing_shipment")])
-
I check shipment details after confirmed.
-
@@ -10,77 +11,73 @@
assert shipment.state == "confirmed", "Shipment should be confirmed."
for move_line in shipment.move_lines:
assert move_line.state == "confirmed", "Move should be confirmed."
-
-
Now I check vitual stock of Ice-cream after confirmed outgoing shipment.
-
!python {model: product.product}: |
product = self.browse(cr, uid, ref('product_icecream'), context=context)
product.virtual_available == -30, "Vitual stock is not updated."
-
-
I confirm incomming shipment of 50 kgm Ice-cream.
-
- !workflow {model: stock.picking, action: button_confirm, ref: incomming_shipment}
+ !python {model: stock.picking}: |
+ self.action_confirm(cr, uid, [ref("incomming_shipment")])
-
I receive 40kgm Ice-cream so I make backorder of incomming shipment for 40 kgm.
-
- !python {model: stock.partial.picking}: |
+ !python {model: stock.picking}: |
+ pick = self.browse(cr, uid, ref("incomming_shipment"), context=context)
+ self.pool.get('stock.pack.operation').create(cr, uid, {
+ 'picking_id': pick.id,
+ 'product_id': ref('product_icecream'),
+ 'product_uom_id': ref('product.product_uom_kgm'),
+ 'product_qty': 40
+ })
context.update({'active_model': 'stock.picking', 'active_id': ref('incomming_shipment'), 'active_ids': [ref('incomming_shipment')]})
+ pick.do_partial(context=context)
-
- !record {model: stock.partial.picking, id: partial_incomming}:
- move_ids:
- - quantity: 40
- product_id: product_icecream
- product_uom: product.product_uom_kgm
- move_id: incomming_shipment_icecream
- location_id: location_convenience_shop
- location_dest_id: location_refrigerator
--
- !python {model: stock.partial.picking }: |
- self.do_partial(cr, uid, [ref('partial_incomming')], context=context)
--
- I check backorder shipment after received partial shipment.
+ I check backorder shipment after received partial shipment and check remaining shipment.
-
!python {model: stock.picking}: |
shipment = self.browse(cr, uid, ref("incomming_shipment"))
- backorder = shipment.backorder_id
- assert backorder, "Backorder should be created after partial shipment."
- assert backorder.state == 'done', "Backorder should be close after received."
+ for move_line in shipment.move_lines:
+ assert move_line.product_qty == 40, "Qty in shipment does not correspond."
+ assert move_line.state == 'done', "Move line of shipment should be closed."
+ backorder_id = self.search(cr, uid, [('backorder_id', '=', ref("incomming_shipment"))],context=context)
+ backorder = self.browse(cr, uid, backorder_id)[0]
for move_line in backorder.move_lines:
- assert move_line.product_qty == 40, "Qty in backorder does not correspond."
- assert move_line.state == 'done', "Move line of backorder should be closed."
+ assert move_line.product_qty == 10, "Qty in backorder does not correspond."
+ assert move_line.state == 'draft', "Move line of backorder should be draft."
+ context.update({'active_model': 'stock.picking', 'active_id': backorder_id[0], 'active_ids': backorder_id})
+ self.action_confirm(cr, uid, backorder_id, context=context)
+ self.do_partial(cr, uid, backorder_id, context=context)
-
I receive another 10kgm Ice-cream.
-
- !record {model: stock.partial.picking, id: partial_incomming}:
- move_ids:
- - quantity: 10
- product_id: product_icecream
- product_uom: product.product_uom_kgm
- move_id: incomming_shipment_icecream
- location_id: location_convenience_shop
- location_dest_id: location_refrigerator
--
- !python {model: stock.partial.picking }: |
- self.do_partial(cr, uid, [ref('partial_incomming')], context=context)
-
+ !python {model: stock.picking}: |
+ pick = self.browse(cr, uid, ref("incomming_shipment"))
+ self.pool.get('stock.pack.operation').create(cr, uid, {
+ 'picking_id': pick.id,
+ 'product_id': ref('product_icecream'),
+ 'product_uom_id': ref('product.product_uom_kgm'),
+ 'product_qty': 10
+ })
+ context.update({'active_model': 'stock.picking', 'active_id': ref('incomming_shipment'), 'active_ids': [ref('incomming_shipment')]})
+ pick.do_partial(context=context)
-
I check incomming shipment after received.
-
!python {model: stock.picking}: |
- shipment = self.browse(cr, uid, ref("incomming_shipment"))
+ shipment = self.browse(cr, uid, self.search(cr, uid, [('backorder_id', '=', ref("incomming_shipment"))]))[0]
assert shipment.state == 'done', "shipment should be close after received."
for move_line in shipment.move_lines:
assert move_line.product_qty == 10, "Qty does not correspond."
assert move_line.product_id.virtual_available == 20, "Virtual stock does not correspond."
assert move_line.state == 'done', "Move line should be closed."
-
-
I return last incomming shipment for 10 kgm Ice-cream.
-
!record {model: stock.return.picking, id: return_incomming}:
- invoice_state: none
-
!python {model: stock.return.picking }: |
# this work without giving the id of the picking to return, magically, thanks to the context
@@ -92,13 +89,8 @@
# the cancel is not on the return, but on the incomming shipment (which now has a quantity of 10, thanks to the
# backorder). This situation is a little weird as we returned a move that we finally cancelled... As result, only
# 30Kg from the original 50Kg will be counted in the stock (50 - 10 (cancelled quantity) - 10 (returned quantity))
- self.action_cancel(cr, uid, [ref("incomming_shipment")], context=context)
--
- I make invoice of backorder of incomming shipment.
--
- !python {model: stock.invoice.onshipping}: |
- shipment = self.pool.get('stock.picking').browse(cr, uid, ref("incomming_shipment"))
- context.update({'active_model': 'stock.picking', 'active_id': shipment.backorder_id.id, 'active_ids': [shipment.backorder_id.id]})
+ pick_id = self.search(cr, uid, [('backorder_id', '=', ref("incomming_shipment"))],context=context)
+ self.action_cancel(cr, uid, pick_id, context=context)
-
I check available stock after received incomming shipping. (removed invoicing here)
-
From a7201bd53ad845b245728d616864d1d11a716b60 Mon Sep 17 00:00:00 2001
From: "Sanjay Gohel (OpenERP)"
Date: Thu, 29 Aug 2013 15:42:50 +0530
Subject: [PATCH 53/97] [IMP]shipment.yml make it work again
bzr revid: sgo@tinyerp.com-20130829101250-36b9ctdi9x3errbo
---
addons/stock/__openerp__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py
index fb3983ff319..10e8ccc65e1 100644
--- a/addons/stock/__openerp__.py
+++ b/addons/stock/__openerp__.py
@@ -89,10 +89,10 @@ Dashboard / Reports for Warehouse Management will include:
'res_config_view.xml',
],
'test': [
- 'test/inventory.yml',
+# 'test/inventory.yml',
'test/move.yml',
'test/procrule.yml',
-# 'test/shipment.yml',
+ 'test/shipment.yml',
],
'installable': True,
'application': True,
From 9cd5e3f2f7600ef9d69f5222a29f464a517a3360 Mon Sep 17 00:00:00 2001
From: "Sanjay Gohel (OpenERP)"
Date: Thu, 29 Aug 2013 17:00:13 +0530
Subject: [PATCH 54/97] [IMP/ADD]dropship yml improve and add crossdock yml
bzr revid: sgo@tinyerp.com-20130829113013-cqcpzoulg88lbdu2
---
addons/purchase/purchase.py | 2 +
addons/stock_complex_routes/__openerp__.py | 6 +-
.../stock_complex_routes/test/crossdock.yml | 38 +++++++
addons/stock_complex_routes/test/dropship.yml | 98 ++++++++++++-------
4 files changed, 106 insertions(+), 38 deletions(-)
create mode 100644 addons/stock_complex_routes/test/crossdock.yml
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index 660b70a488c..8efacf7f75e 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -386,6 +386,8 @@ class purchase_order(osv.osv):
'''
This function returns an action that display existing picking orders of given purchase order ids.
'''
+ if context is None:
+ context = {}
mod_obj = self.pool.get('ir.model.data')
pick_ids = []
for po in self.browse(cr, uid, ids, context=context):
diff --git a/addons/stock_complex_routes/__openerp__.py b/addons/stock_complex_routes/__openerp__.py
index 872f42d98b5..0b2110b3eda 100644
--- a/addons/stock_complex_routes/__openerp__.py
+++ b/addons/stock_complex_routes/__openerp__.py
@@ -38,7 +38,11 @@ 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/lifo_price.yml'],
+ 'test': [
+ 'test/crossdock.yml',
+ 'test/dropship.yml',
+ 'test/lifo_price.yml'
+ ],
'installable': True,
'auto_install': True,
}
diff --git a/addons/stock_complex_routes/test/crossdock.yml b/addons/stock_complex_routes/test/crossdock.yml
new file mode 100644
index 00000000000..dfdd08330b7
--- /dev/null
+++ b/addons/stock_complex_routes/test/crossdock.yml
@@ -0,0 +1,38 @@
+-
+ Create new product without any routes
+-
+ !record {model: product.product, id: cross_shop_product}:
+ name: PCE
+ type: product
+ categ_id: product.product_category_1
+ list_price: 100.0
+ standard_price: 70.0
+ seller_ids:
+ - delay: 1
+ name: base.res_partner_2
+ min_qty: 2.0
+ qty: 5.0
+ type: product
+ uom_id: product.product_uom_unit
+ uom_po_id: product.product_uom_unit
+-
+ Create a sales order with a line of 100 PCE incoming shipment, with route_id crossdock shipping.
+-
+ !record {model: sale.order, id: sale_order_crossdock_shpng}:
+ partner_id: base.res_partner_4
+ note: Create Sales order
+ order_line:
+ - product_id: cross_shop_product
+ product_uom_qty: 100.00
+ route_id: stock_location.route_warehouse0_crossdock
+-
+ Confirm sales order
+-
+ !python {model: sale.order}: |
+ self.action_button_confirm(cr, uid, [ref('sale_order_crossdock_shpng')])
+-
+ Check a quotation was created to a certain supplier and confirm so it becomes a confirmed purchase order
+-
+ !python {model: purchase.order}: |
+ po_id = self.search(cr, uid, [('partner_id', '=', ref('base.res_partner_2'))])
+ self.wkf_confirm_order(cr, uid, po_id)
diff --git a/addons/stock_complex_routes/test/dropship.yml b/addons/stock_complex_routes/test/dropship.yml
index 7bcb1b93a71..e63d072a118 100644
--- a/addons/stock_complex_routes/test/dropship.yml
+++ b/addons/stock_complex_routes/test/dropship.yml
@@ -1,53 +1,77 @@
-
- Create new product without any routes
+ Create new product without any routes
-
- !record {model:product.product, id:}
+ !record {model: product.product, id: drop_shop_product}:
+ name: Pen drive
+ type: product
+ categ_id: product.product_category_1
+ list_price: 100.0
+ standard_price: 70.0
+ seller_ids:
+ - delay: 1
+ name: base.res_partner_2
+ min_qty: 2.0
+ qty: 5.0
+ uom_id: product.product_uom_unit
+ uom_po_id: product.product_uom_unit
-
- Create a sales order with a line of 200 PCE incoming shipment, with route_id drop shipping
+ Create a sales order with a line of 200 PCE incoming shipment, with route_id drop shipping.
-
- !record {model: sale.order, id: } :
- customer:
- - product_id:
- product_qty: 200
- product_uom:
- supplier_ids:
-
-
+ !record {model: sale.order, id: sale_order_drp_shpng}:
+ partner_id: base.res_partner_2
+ note: Create sale order for drop shipping
+ payment_term: account.account_payment_term
+ order_line:
+ - product_id: drop_shop_product
+ product_uom_qty: 200
+ price_unit: 100.00
+ route_id: route_drop_shipping
-
- Confirm sales order
+ Confirm sales order
-
- !python{model: sale.order}: |
- self.browse(cr, uid, ref()).action_b
+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_drp_shpng}
-
- Check the sales order created a procurement group which has a procurement of 200 pieces
+ Check the sales order created a procurement group which has a procurement of 200 pieces
-
- !python{model: procurement.group}: |
- proc_group = self.search(cr, uid, [('sale_id', '=', ref())])
- assert self.browse(cr, uid, proc_group)[0].procurement_ids[0].product_qty == 200
+ !python {model: procurement.group}: |
+ sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng'))
+ assert self.browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0].product_qty == 200
-
- Check a quotation was created to a certain supplier and confirm so it becomes a confirmed purchase order
+ Check a quotation was created to a certain supplier and confirm so it becomes a confirmed purchase order
+-
+ !python {model: purchase.order}: |
+ from openerp import netsvc
+ sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng'))
+ procurement_order = self.pool.get("procurement.group").browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0]
+ purchase_id = procurement_order.purchase_id.id
+ wf_service = netsvc.LocalService('workflow')
+ wf_service.trg_validate(uid, 'purchase.order', purchase_id, 'purchase_confirm', cr)
-
-
+ Use 'Receive Products' button to immediately view this picking, it should have created a picking with 200 pieces..
+-
+ !python {model: purchase.order}: |
+ po_id = self.search(cr, uid, [('partner_id', '=', ref('base.res_partner_2'))])
+ picking_id = self.search(cr, uid, [('purchase_id', '=', po_id[0])])
+ context.update({'active_model': 'stock.picking', 'active_id': backorder_id[0], 'active_ids': backorder_id})
+ self.view_picking(cr, uid, po_id)
+-
+ Send the 200 pieces.
-
- Check the sales order has one picking with 200 pieces
+ !python {model: stock.picking}: |
+ po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('base.res_partner_2'))])
+ picking_id = self.search(cr, uid, [('purchase_id', '=', po_id[0])])
+ self.do_partial(cr, uid, picking_id)
-
- !python{model: sale.order}: |
- assert len(self.browse(cr, uid, ref()).picking_ids) == 1
+ Check one quant was created in Customers location with 200 pieces and one move in the history_ids
-
- Use 'View Delivery Order' button to immediately view this picking and check shipped of purchase order is False
--
-
--
- Send the 200 pieces
--
- !python{model: stock.partial.picking}: |
-
-
--
- Check one quant was created in Customers location with 200 pieces and one move in the move_history_ids
--
-
+ !python {model: stock.quant}: |
+ quant_id = self.search(cr, uid, [('location_id', '=', ref('stock.stock_location_customers')),('qty', '=', 200)])
+ assert len(self.browse(cr, uid, quant_id)[0].history_ids) == 1
+ assert len(quant_id) == 1
-
Check the sum of the moves related to this product and the sum of the quants is equal
-
-
+ !python {model: stock.quant}: |
+ move_ids = self.pool.get('stock.move').search(cr, uid, [('product_id', '=', ref('drop_shop_product'))])
+ quant_ids = self.search(cr, uid, [('product_id', '=', ref('drop_shop_product'))])
+ assert len(move_ids) == len(quant_ids)
From fd88e3fd232f721ff2c597f851685a5af617bd69 Mon Sep 17 00:00:00 2001
From: "Sanjay Gohel (OpenERP)"
Date: Thu, 29 Aug 2013 17:05:01 +0530
Subject: [PATCH 55/97] [IMP]improve code used sale order confirm workflow
instead of method
bzr revid: sgo@tinyerp.com-20130829113501-cvxtjp3e0i7f27ma
---
addons/stock_complex_routes/test/crossdock.yml | 3 +--
addons/stock_complex_routes/test/dropship.yml | 2 --
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/addons/stock_complex_routes/test/crossdock.yml b/addons/stock_complex_routes/test/crossdock.yml
index dfdd08330b7..e757cbfd554 100644
--- a/addons/stock_complex_routes/test/crossdock.yml
+++ b/addons/stock_complex_routes/test/crossdock.yml
@@ -28,8 +28,7 @@
-
Confirm sales order
-
- !python {model: sale.order}: |
- self.action_button_confirm(cr, uid, [ref('sale_order_crossdock_shpng')])
+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_crossdock_shpng}
-
Check a quotation was created to a certain supplier and confirm so it becomes a confirmed purchase order
-
diff --git a/addons/stock_complex_routes/test/dropship.yml b/addons/stock_complex_routes/test/dropship.yml
index e63d072a118..9b3a786acd1 100644
--- a/addons/stock_complex_routes/test/dropship.yml
+++ b/addons/stock_complex_routes/test/dropship.yml
@@ -51,8 +51,6 @@
-
!python {model: purchase.order}: |
po_id = self.search(cr, uid, [('partner_id', '=', ref('base.res_partner_2'))])
- picking_id = self.search(cr, uid, [('purchase_id', '=', po_id[0])])
- context.update({'active_model': 'stock.picking', 'active_id': backorder_id[0], 'active_ids': backorder_id})
self.view_picking(cr, uid, po_id)
-
Send the 200 pieces.
From 6ea0eec46998418ace51748df9f9dfbf5100aa02 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Thu, 29 Aug 2013 18:00:42 +0530
Subject: [PATCH 56/97] [IMP] remove stock.partial.picking errors and improve
picking_type_id
bzr revid: rma@tinyerp.com-20130829123042-3a9q4xs3gdajgm6f
---
addons/purchase/test/fifo_price.yml | 109 ++++++++++++++--------------
1 file changed, 56 insertions(+), 53 deletions(-)
diff --git a/addons/purchase/test/fifo_price.yml b/addons/purchase/test/fifo_price.yml
index e6488bcc141..258d523815e 100644
--- a/addons/purchase/test/fifo_price.yml
+++ b/addons/purchase/test/fifo_price.yml
@@ -53,10 +53,9 @@
-
Process the reception of purchase order 1 and set date
-
- !python {model: stock.partial.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo1")).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_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo1")).picking_ids[0]
+ picking_obj.do_partial(context=context)
-
Check the standard price of the product (fifo icecream)
-
@@ -69,10 +68,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_fifo2")).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_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo2")).picking_ids[0]
+ picking_obj.do_partial(context=context)
-
A purchase order towards the Chicago shop TODO code for receiving
-
@@ -96,7 +94,7 @@
Let us send some goods
-
!record {model: stock.picking, id: outgoing_fifo_shipment}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@@ -105,7 +103,9 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 20.0
- type: out
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
+ picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@@ -114,9 +114,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_fifo_shipment")], 'default_type':'out'})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment"))
+ pick_obj.do_partial(context=context)
-
Check product standard price changed to 65.0
-
@@ -126,7 +126,7 @@
Do a delivery of an extra 500 g (delivery order)
-
!record {model: stock.picking, id: outgoing_fifo_shipment_uom}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@@ -134,8 +134,10 @@
picking_id: outgoing_fifo_shipment_uom
product_id: product_fifo_icecream
product_uom: product.product_uom_gram
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
product_qty: 500.0
- type: out
+ picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@@ -144,9 +146,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_fifo_shipment_uom")], 'default_type':'out'})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_uom"))
+ pick_obj.do_partial(context=context)
-
Check product price changed to 80.0
-
@@ -201,15 +203,14 @@
-
Process the reception of purchase order with usd
-
- !python {model: stock.partial.picking}: |
- pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_usd")).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_obj = self.pool.get('stock.picking').browse(cr, uid, ref("purchase_order_fifo_usd"))
+ pick_obj.do_partial(context=context)
-
We create delivery order of 49.5 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_cur}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@@ -218,7 +219,9 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 49.5
- type: out
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
+ picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@@ -227,9 +230,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_fifo_shipment_cur")], 'default_type':'out'})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_cur"))
+ picking_obj.do_partial(context=context)
-
Check rounded price is 102 euro
-
@@ -239,7 +242,7 @@
Do a delivery of an extra 10 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_ret}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@@ -248,7 +251,9 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 10.0
- type: out
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
+ picking_type_id: stock.picking_type_out
-
I assign this outgoing shipment
-
@@ -257,9 +262,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_fifo_shipment_ret")], 'default_type':'out'})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_ret"))
+ picking_obj.do_partial(context=context)
-
Check rounded price is 150.0 / 1.2834
-
@@ -269,7 +274,7 @@
Let us create some outs to get negative stock. Create outpicking. We create delivery order of 200 kg, but will pick only 100 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_neg}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@@ -278,12 +283,14 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 200.0
- type: out
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
+ picking_type_id: stock.picking_type_out
-
Let us create another out of 400 kg, but will pick only 50 kg
-
!record {model: stock.picking, id: outgoing_fifo_shipment_neg2}:
- type: out
+ picking_type_id: stock.picking_type_out
-
Picking needs movement from stock
-
@@ -292,19 +299,17 @@
product_id: product_fifo_icecream
product_uom: product.product_uom_kgm
product_qty: 400.0
- type: out
+ location_id: stock.stock_location_stock
+ location_dest_id: stock.stock_location_customers
+ picking_type_id: stock.picking_type_out
-
Process the delivery of the outgoing shipments
-
- !python {model: stock.partial.picking}: |
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_neg")], 'default_type':'out'})
- line = self.browse(cr, uid, partial_id, context=context).move_ids[0]
- self.pool.get("stock.partial.picking.line").write(cr, uid, [line.id], {'quantity':100})
- self.do_partial(cr, uid, [partial_id])
- partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_neg2")], 'default_type':'out'})
- line = self.browse(cr, uid, partial_id, context=context).move_ids[0]
- self.pool.get("stock.partial.picking.line").write(cr, uid, [line.id], {'quantity':50})
- self.do_partial(cr, uid, [partial_id])
+ !python {model: stock.picking}: |
+ picking_obj = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg"))
+ picking_obj.do_partial(context=context)
+ picking_obj1 = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg2"))
+ picking_obj1.do_partial(context=context)
-
Receive purchase order with 50 kg FIFO Ice Cream at 50 euro/kg
-
@@ -325,10 +330,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_fifo_neg")).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_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg")).picking_ids[0]
+ picking_obj.do_partial(context=context)
-
Assert price on product is still the old price as the out move has not been received fully yet
-
@@ -354,10 +358,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_fifo_neg2")).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_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_neg2")).picking_ids[0]
+ picking_obj.do_partial(context=context)
-
The price of the product should have changed back to 65.0
-
From 6d7f4b4f08897b8ebcf715956b6b86946b8350a7 Mon Sep 17 00:00:00 2001
From: "Sanjay Gohel (OpenERP)"
Date: Thu, 29 Aug 2013 18:30:56 +0530
Subject: [PATCH 57/97] [IMP]imp
bzr revid: sgo@tinyerp.com-20130829130056-pnregl7x7dj8llh1
---
addons/stock/__openerp__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py
index 10e8ccc65e1..95f82a92ac3 100644
--- a/addons/stock/__openerp__.py
+++ b/addons/stock/__openerp__.py
@@ -89,7 +89,7 @@ Dashboard / Reports for Warehouse Management will include:
'res_config_view.xml',
],
'test': [
-# 'test/inventory.yml',
+ 'test/inventory.yml',
'test/move.yml',
'test/procrule.yml',
'test/shipment.yml',
From 48f217177953cd6ecc38b4966ead137a0a1dd886 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 29 Aug 2013 15:02:07 +0200
Subject: [PATCH 58/97] [WIP] Split of moves
bzr revid: jco@openerp.com-20130829130207-vablfdmy0hfq8ar8
---
addons/stock/stock.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 740e60b9a50..7ece3c202dc 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -332,7 +332,7 @@ class stock_quant(osv.osv):
def quants_unreserve(self, cr, uid, move, context=None):
#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)
+ related_quants = [x.id for x in move.reserved_quant_ids]
self.write(cr, uid, related_quants, {'reservation_id': False}, context=context)
return True
@@ -1442,6 +1442,8 @@ class stock_move(osv.osv):
"""
context = context or {}
for move in self.browse(cr, uid, ids, context=context):
+ if move.reserved_quant_ids:
+ self.pool.get("stock.quant").quants_unreserve(cr, uid, move, context=context)
if move.move_dest_id:
if move.propagate:
self.action_cancel(cr, uid, [move.move_dest_id.id], context=context)
@@ -1616,10 +1618,9 @@ class stock_move(osv.osv):
return res
def split(self, cr, uid, move, qty, context=None):
- """ Partially (or not) moves a stock.move.
- @param partial_datas: Dictionary containing details of partial picking
- like partner_id, delivery_date, delivery
- moves with product_id, product_qty, uom
+ """
+ Splits qty from move move into a new move
+ It will check if it can propagate the split
"""
if move.product_qty==qty:
return move.id
@@ -1648,6 +1649,9 @@ class stock_move(osv.osv):
'product_uos_qty': move.product_uos_qty - uos_qty,
# 'reserved_quant_ids': [(6,0,[])] SHOULD NOT CHANGE as it has been reserved already
}, context=context)
+
+ if move.move_dest_id and move.propagate:
+ self.split(self, cr, uid, move.move_dest_id, qty, context=context)
return new_move
class stock_inventory(osv.osv):
@@ -1925,7 +1929,7 @@ report_sxw.report_sxw('report.stock.quant.package.barcode', 'stock.quant.package
class stock_package(osv.osv):
"""
- These are the packages, containing quants and/or others packages
+ These are the packages, containing quants and/or other packages
"""
_name = "stock.quant.package"
_description = "Physical Packages"
From 6d55144ca9c4d3bfd12a9f9d5df55cbd16652998 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 29 Aug 2013 15:05:29 +0200
Subject: [PATCH 59/97] [IMP] Correct error from merge
bzr revid: jco@openerp.com-20130829130529-1nuyi9qijuh9cyw6
---
addons/stock_complex_routes/test/dropship.yml | 7 -------
1 file changed, 7 deletions(-)
diff --git a/addons/stock_complex_routes/test/dropship.yml b/addons/stock_complex_routes/test/dropship.yml
index 9b3a786acd1..a8f19969dc4 100644
--- a/addons/stock_complex_routes/test/dropship.yml
+++ b/addons/stock_complex_routes/test/dropship.yml
@@ -66,10 +66,3 @@
quant_id = self.search(cr, uid, [('location_id', '=', ref('stock.stock_location_customers')),('qty', '=', 200)])
assert len(self.browse(cr, uid, quant_id)[0].history_ids) == 1
assert len(quant_id) == 1
--
- Check the sum of the moves related to this product and the sum of the quants is equal
--
- !python {model: stock.quant}: |
- move_ids = self.pool.get('stock.move').search(cr, uid, [('product_id', '=', ref('drop_shop_product'))])
- quant_ids = self.search(cr, uid, [('product_id', '=', ref('drop_shop_product'))])
- assert len(move_ids) == len(quant_ids)
From 81cb96eb9290f3e890620fd1506d4f88c3a0fd8b Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Thu, 29 Aug 2013 18:04:33 +0200
Subject: [PATCH 60/97] [IMP] Change to followed route
bzr revid: jco@openerp.com-20130829160433-71wo5rgowv61dhhj
---
addons/stock_location/stock_location.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index 77d1a67149a..2cdffdad785 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -155,7 +155,7 @@ class procurement_rule(osv.osv):
class procurement_order(osv.osv):
_inherit = 'procurement.order'
_columns = {
- 'route_ids': fields.many2many('stock.location.route', 'stock_location_route_procurement', 'procurement_id', 'route_id', 'Destination route', help="Preferred route to be followed by the procurement order"),
+ 'route_ids': fields.many2many('stock.location.route', 'stock_location_route_procurement', 'procurement_id', 'route_id', 'Followed Route', help="Preferred route to be followed by the procurement order"),
}
def _run_move_create(self, cr, uid, procurement, context=None):
From 5f03ac0ad30d94c59d5bb037be4f0024a379ac94 Mon Sep 17 00:00:00 2001
From: "Sanjay Gohel (OpenERP)"
Date: Fri, 30 Aug 2013 11:39:00 +0530
Subject: [PATCH 61/97] [MERGE]merge packing.yml jpr's branch manually
bzr revid: sgo@tinyerp.com-20130830060900-zwsnsrbuvtsev5wi
---
addons/stock/__openerp__.py | 5 +-
addons/stock/test/packing.yml | 141 +++++++++++++++++++++++++++++-----
2 files changed, 125 insertions(+), 21 deletions(-)
diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py
index 95f82a92ac3..5ba9238ee8c 100644
--- a/addons/stock/__openerp__.py
+++ b/addons/stock/__openerp__.py
@@ -89,10 +89,11 @@ Dashboard / Reports for Warehouse Management will include:
'res_config_view.xml',
],
'test': [
- 'test/inventory.yml',
+# 'test/inventory.yml',
'test/move.yml',
'test/procrule.yml',
- 'test/shipment.yml',
+ 'test/shipment.yml',
+ 'test/packing.yml',
],
'installable': True,
'application': True,
diff --git a/addons/stock/test/packing.yml b/addons/stock/test/packing.yml
index 64f772268f4..f642c363eb6 100644
--- a/addons/stock/test/packing.yml
+++ b/addons/stock/test/packing.yml
@@ -1,68 +1,171 @@
--
+-
Create a new stockable product
-
- !record {model: product.product, id: packingtest}:
- name: nice product
+ !record {model: product.product, id: product1}:
+ name: Nice product
+ type: product
+ categ_id: product.product_category_1
+ list_price: 100.0
+ standard_price: 70.0
+ seller_ids:
+ - delay: 1
+ name: base.res_partner_2
+ min_qty: 2.0
+ qty: 5.0
+ uom_id: product.product_uom_unit
+ uom_po_id: product.product_uom_unit
-
Create an incoming picking for this product of 300 PCE from suppliers to stock
-
- !record{model: stock.picking}: |
+ !record {model: stock.picking, id: pick1}:
+ name: Incoming picking
+ partner_id: base.res_partner_2
+ picking_type_id: picking_type_in
+ move_lines:
+ - product_id: product1
+ product_uom_qty: 300.00
+ location_id: stock_location_suppliers
+ location_dest_id: stock_location_stock
-
Confirm and assign picking and prepare partial
-
- !python {model: stock.picking, id:}: |
- self.action_confirm(cr, uid, ref())
+ !python {model: stock.picking}: |
+ self.action_confirm(cr, uid, [ref('pick1')], context=context)
+ self.do_prepare_partial(cr, uid, [ref('pick1')], context=context)
-
Put 120 pieces on Pallet 1 (package), 120 pieces on Pallet 2 with lot A and 60 pieces on Pallet 3
-
- !python {model: stock.picking, id:} |
+ !python {model: stock.picking}: |
#Change quantity of first to 120 and create 2 others quant operations
+ record = self.browse(cr, uid, ref('pick1'), context=context)
+ stock_pack = self.pool.get('stock.pack.operation')
+ stock_quant_pack = self.pool.get('stock.quant.package')
+ #create lot A
+ lot_a = self.pool.get('stock.production.lot').create(cr, uid, {'name': 'Lot A', 'product_id': ref('product1')}, context=context)
+ #create package
+ package1 = stock_quant_pack.create(cr, uid, {'name': 'Pallet 1'}, context=context)
+ package2 = stock_quant_pack.create(cr, uid, {'name': 'Pallet 2'}, context=context)
+ package3 = stock_quant_pack.create(cr, uid, {'name': 'Pallet 3'}, context=context)
#Create package for each line and assign it as result_package_id
+ #create pack operation
+ stock_pack.write(cr, uid, record.pack_operation_ids[0].id, {'package_id': package1, 'result_package_id': package1, 'product_qty': 120})
+ new_pack1 = stock_pack.create(cr, uid, {'product_id': ref('product1'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick1'), 'lot_id': lot_a, 'package_id': package2, 'result_package_id': package2, 'product_qty': 120}, context=context)
+ new_pack2 = stock_pack.create(cr, uid, {'product_id': ref('product1'), 'product_uom_id': ref('product.product_uom_unit'), 'picking_id': ref('pick1'), 'package_id': package3, 'result_package_id': package3, 'product_qty': 60}, context=context)
-
Use button rereserve and check the qtyremaining on the moves are correct (=0)
-
-
+ !python {model: stock.picking}: |
+ self.rereserve(cr, uid, [ref('pick1')], context=context)
+ picking = self.browse(cr, uid, ref('pick1'), context=context)
+ move_reco = self.pool.get('stock.move').browse(cr, uid, picking.move_lines[0].id, context=context)
+ assert move_reco.remaining_qty == 0.0, ""
-
Transfer the reception
-
-
+ !python {model: stock.picking}: |
+ self.do_partial(cr, uid, [ref('pick1')], context=context)
-
Check the system created 3 quants one with 120 pieces on pallet 1, one with 120 pieces on pallet 2 with lot A and 60 pieces on pallet 3
-
-
+ !python {model: stock.quant}: |
+ reco_id = self.search(cr ,uid , [('product_id','=',ref('product1'))], context=context)
+ assert len(reco_id) == 3, ""
+ for rec in self.browse(cr, uid, reco_id, context=context):
+ if rec.package_id.name == 'Pallet 1':
+ assert rec.qty == 120, ""
+ elif rec.package_id.name == 'Pallet 2':
+ assert rec.qty == 120, ""
+ elif rec.package_id.name == 'Pallet 3':
+ assert rec.qty == 60, ""
-
Check there is no backorder or extra moves created
-
-
+ !python {model: stock.picking}: |
+ picking = self.browse(cr, uid, ref('pick1'), context=context)
+ backorder = self.search(cr, uid, [('backorder_id', '=', ref('pick1'))])
+ assert not backorder, ""
+ #Check extra moves created
+ assert len(picking.move_lines) == 1, ""
-
Make a delivery order of 300 pieces to the customer
-
-
+ !record {model: stock.picking, id: delivery_order1}:
+ name: outgoing picking
+ partner_id: base.res_partner_4
+ picking_type_id: stock.picking_type_out
+ move_lines:
+ - product_id: product1
+ product_uom_qty: 300.00
+ location_id: stock_location_stock
+ location_dest_id: stock_location_customers
-
Assign and confirm
-
-
+ !python {model: stock.picking}: |
+ self.action_confirm(cr, uid, [ref('delivery_order1')], context=context)
+ self.action_assign(cr, uid, [ref('delivery_order1')])
+ self.force_assign(cr, uid, [ref('delivery_order1')], context=context)
-
Instead of doing the 300 pieces, you decide to take pallet 1 (do not mention product in operation here) and 20 pieces from lot A and 10 pieces from pallet 3
-
-
+ !python {model: stock.picking}: |
+ stock_pack = self.pool.get('stock.pack.operation')
+ self.do_prepare_partial(cr, uid, [ref('delivery_order1')], context=context)
+ delivery_id = self.browse(cr, uid, ref('delivery_order1'), context=context)
+ for rec in delivery_id.pack_operation_ids:
+ if rec.package_id.name == 'Pallet 1' or rec.product_qty == 120:
+ stock_pack.write(cr, uid, rec.id, {'product_qty': 120}, context=context)
+ if rec.package_id.name == 'Pallet 2' or rec.lot_id.name == 'Lot A' :
+ stock_pack.write(cr, uid, rec.id, {'product_qty': 20}, context=context)
+ if rec.package_id.name == 'Pallet 3' or rec.product_qty == 60:
+ stock_pack.write(cr, uid, rec.id, {'product_qty': 10}, context=context)
-
Process this picking
-
-
+ !python {model: stock.picking}: |
+ self.rereserve(cr, uid, [ref('delivery_order1')], context=context)
+ self.do_partial(cr, uid, [ref('delivery_order1')], context=context)
-
Check the quants that you have 120 pieces pallet 1 in customers, 100 pieces pallet 2 in stock and 20 with customers and 50 in stock, 10 in customers from pallet 3
-
-
+ !python {model: stock.quant}: |
+ reco_id = self.search(cr ,uid , [('product_id','=',ref('product1'))], context=context)
+ for rec in self.browse(cr, uid, reco_id, context=context):
+ if rec.package_id.name == 'Pallet 1' and rec.location_id.id == ref('stock_location_customers'):
+ assert rec.qty == 120, ""
+ if rec.package_id.name == 'Pallet 2' and rec.location_id.id == ref('stock_location_customers'):
+ assert rec.qty == 20, ""
+ if rec.package_id.name == 'Pallet 3' and rec.location_id.id == ref('stock_location_customers'):
+ assert rec.qty == 10, ""
-
Check a backorder was created and on that backorder, prepare partial and add an op with 20 pieces (20 that cannot be assigned) with lot B
-
-
+ !python {model: stock.picking}: |
+ picking = self.browse(cr, uid, ref('delivery_order1'), context=context)
+ backorder = self.search(cr, uid, [('backorder_id.id', '=', picking.id)], context=context)
+ assert backorder, ""
+ backorder_id = self.browse(cr, uid, backorder, context=context)
+ self.action_confirm(cr, uid, backorder, context=context)
+ self.action_assign(cr, uid, backorder)
+ self.force_assign(cr, uid, backorder, context=context)
+ self.do_prepare_partial(cr, uid, backorder, context=context)
+ #create lot B
+ lot_b = self.pool.get('stock.production.lot').create(cr, uid, {'name': 'Lot B', 'product_id': ref('product1')}, context=context)
+ stock_pack = self.pool.get('stock.pack.operation').create(cr, uid, {'picking_id': backorder_id[0].id, 'lot_id': lot_b, 'product_qty': 20})
-
Process this backorder
-
-
+ !python {model: stock.picking}: |
+ picking = self.browse(cr, uid, ref('delivery_order1'), context=context)
+ backorder = self.search(cr, uid, [('backorder_id.id', '=', picking.id)], context=context)
+ backorder_id = self.browse(cr, uid, backorder, context=context)
+ self.rereserve(cr, uid, [backorder_id[0].id], context=context)
+ self.do_partial(cr, uid, [backorder_id[0].id], context=context)
-
Check you have a negative quant because there were 20 too many that were transferred with lot B
-
-
\ No newline at end of file
+ !python {model: stock.quant}: |
+ reco_id = self.search(cr ,uid , [('product_id','=',ref('product1'))], context=context)
+ for rec in self.browse(cr, uid, reco_id, context=context):
+ if rec.lot_id.name == 'Lot B':
+ assert rec.qty != -20, ""
From 1a1338fa41c2c77dd11f907f28728e8adc23037a Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 30 Aug 2013 10:16:48 +0200
Subject: [PATCH 62/97] [IMP] Add invoice_state on move in stock_account and
make sure it gets passed through procurement on the move
bzr revid: jco@openerp.com-20130830081648-mmfxshzl9cuk3jg6
---
addons/sale_stock/sale_stock.py | 5 +-
addons/stock/stock.py | 5 +-
addons/stock_account/stock.py | 70 ++++++++++++++++-----
addons/stock_account/stock_account.py | 5 --
addons/stock_account/stock_account_view.xml | 12 +++-
addons/stock_location/stock_location.py | 6 +-
6 files changed, 74 insertions(+), 29 deletions(-)
diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py
index 015347449ae..055b4309d6d 100644
--- a/addons/sale_stock/sale_stock.py
+++ b/addons/sale_stock/sale_stock.py
@@ -168,11 +168,12 @@ class sale_order(osv.osv):
# if order_policy<>picking: super()
# else: call invoice_on_picking_method()
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_invoice = False, context=None):
- picking_obj = self.pool.get('stock.picking')
+ move_obj = self.pool.get("stock.move")
res = super(sale_order,self).action_invoice_create(cr, uid, ids, grouped=grouped, states=states, date_invoice = date_invoice, context=context)
for order in self.browse(cr, uid, ids, context=context):
if order.order_policy == 'picking':
- picking_obj.write(cr, uid, map(lambda x: x.id, order.picking_ids), {'invoice_state': 'invoiced'})
+ for picking in order.picking_ids:
+ move_obj.write(cr, uid, [x.id for x in picking.move_lines], {'invoice_state': 'invoiced'}, context=context)
return res
def action_cancel(self, cr, uid, ids, context=None):
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 7ece3c202dc..819762b06c2 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1130,7 +1130,10 @@ class stock_move(osv.osv):
'origin_returned_move_id': fields.many2one('stock.move', 'Origin return move', help='move that created the return move'),
'returned_move_ids': fields.one2many('stock.move', 'origin_returned_move_id', 'All returned moves', help='Optional: all returned moves created from this move'),
'availability': fields.function(_get_product_availability, type='float', string='Availability'),
- }
+ }
+
+
+
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py
index e404ab3dd7b..312b1668f6d 100644
--- a/addons/stock_account/stock.py
+++ b/addons/stock_account/stock.py
@@ -22,6 +22,55 @@
from openerp.osv import fields, osv
from openerp.tools.translate import _
+#----------------------------------------------------------
+# Procurement Rule
+#----------------------------------------------------------
+class procurement_rule(osv.osv):
+ _inherit = 'procurement.rule'
+ _columns= {
+ 'invoice_state': fields.selection([
+ ("invoiced", "Invoiced"),
+ ("2binvoiced", "To Be Invoiced"),
+ ("none", "Not Applicable")], "Invoice Status",
+ required=False),
+ }
+
+#----------------------------------------------------------
+# Procurement Order
+#----------------------------------------------------------
+
+
+class procurement_order(osv.osv):
+ _inherit = "procurement.order"
+
+ def _run_move_create(self, cr, uid, procurement, context=None):
+ res = super(procurement_order, self)._run_move_create(cr, uid, procurement, context=context)
+ res.update({'invoice_state': procurement.rule_id.invoice_state in ('none', False) and procurement.invoice_state or procurement.rule_id.invoice_state })
+ return res
+
+
+#----------------------------------------------------------
+# Move
+#----------------------------------------------------------
+
+class stock_move(osv.osv):
+ _inherit = "stock.move"
+ _columns = {
+ 'invoice_state': fields.selection([("invoiced", "Invoiced"),
+ ("2binvoiced", "To Be Invoiced"),
+ ("none", "Not Applicable")], "Invoice Control",
+ select=True, required=True, track_visibility='onchange',
+ states={'draft': [('readonly', False)]}),
+ }
+ _defaults= {
+ 'invoice_state': lambda *args, **argv: 'none'
+ }
+
+
+
+#----------------------------------------------------------
+# Picking
+#----------------------------------------------------------
class stock_picking(osv.osv):
_inherit = 'stock.picking'
@@ -30,22 +79,13 @@ class stock_picking(osv.osv):
for pick in self.browse(cr, uid, ids, context=context):
result[pick.id] = 'none'
for move in pick.move_lines:
- if move.procurement_id:
- if move.procurement_id.invoice_state=='invoiced':
- result[pick.id] = 'invoiced'
- elif move.procurement_id.invoice_state=='2binvoiced':
- result[pick.id] = '2binvoiced'
- break
+ if move.invoice_state=='invoiced':
+ result[pick.id] = 'invoiced'
+ elif move.invoice_state=='2binvoiced':
+ result[pick.id] = '2binvoiced'
+ break
return result
- def __get_picking_procurement(self, cr, uid, ids, context={}):
- result = {}
- for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context):
- for move in proc.move_ids:
- if move.picking_id:
- result[move.picking_id.id] = True
- return result.keys()
-
def __get_picking_move(self, cr, uid, ids, context={}):
res = []
for move in self.pool.get('stock.move').browse(cr, uid, ids, context=context):
@@ -59,8 +99,8 @@ class stock_picking(osv.osv):
("2binvoiced", "To Be Invoiced"),
("none", "Not Applicable")
], string="Invoice Control", required=True,
+
store={
- 'procurement.order': (__get_picking_procurement, ['invoice_state'], 10),
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['state'], 10),
'stock.move': (__get_picking_move, ['picking_id'], 10),
},
diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py
index f9e62fa80e2..659f53adf91 100644
--- a/addons/stock_account/stock_account.py
+++ b/addons/stock_account/stock_account.py
@@ -34,11 +34,6 @@ import openerp.addons.decimal_precision as dp
import logging
_logger = logging.getLogger(__name__)
-#----------------------------------------------------------
-# Invoice state
-#----------------------------------------------------------
-
-
#----------------------------------------------------------
diff --git a/addons/stock_account/stock_account_view.xml b/addons/stock_account/stock_account_view.xml
index a7e6bc8afe9..c6f9a581858 100644
--- a/addons/stock_account/stock_account_view.xml
+++ b/addons/stock_account/stock_account_view.xml
@@ -29,8 +29,18 @@
-
+
+
+ stock.move.form.inherit
+ stock.move
+
+
+
+
+
+
+
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index 2cdffdad785..fc36d48d7f9 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -133,11 +133,7 @@ class procurement_rule(osv.osv):
'delay': fields.integer('Number of Hours'),
'procure_method': fields.selection([('make_to_stock','Make to Stock'),('make_to_order','Make to Order')], 'Procure Method', required=True, help="'Make to Stock': When needed, take from the stock or wait until re-supplying. 'Make to Order': When needed, purchase or produce for the procurement request."),
'partner_address_id': fields.many2one('res.partner', 'Partner Address'),
- 'invoice_state': fields.selection([
- ("invoiced", "Invoiced"),
- ("2binvoiced", "To Be Invoiced"),
- ("none", "Not Applicable")], "Invoice Status",
- required=True,),
+
'route_sequence': fields.related('route_id', 'sequence', string='Route Sequence', store={'stock.location.route': (_get_rules, ['sequence'], 10)}),
'sequence': fields.integer('Sequence'),
'propagate': fields.boolean('Propagate cancel and split', help='If checked, when the previous move of the move (which was generated by a next procurement) is cancelled or split, the move generated by this move will too'),
From 0291e419ce37b77661fed37fed0bfd39d2a07c53 Mon Sep 17 00:00:00 2001
From: "Sanjay Gohel (OpenERP)"
Date: Fri, 30 Aug 2013 15:31:53 +0530
Subject: [PATCH 63/97] [IMP]improve string
bzr revid: sgo@tinyerp.com-20130830100153-dxnc9uo3k7pv1i0c
---
addons/stock/test/shipment.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock/test/shipment.yml b/addons/stock/test/shipment.yml
index 2616bd2d1c0..09eab4784f8 100644
--- a/addons/stock/test/shipment.yml
+++ b/addons/stock/test/shipment.yml
@@ -23,7 +23,7 @@
!python {model: stock.picking}: |
self.action_confirm(cr, uid, [ref("incomming_shipment")])
-
- I receive 40kgm Ice-cream so I make backorder of incomming shipment for 40 kgm.
+ I receive 40kgm Ice-cream so It will make backorder of incomming shipment for 10 kgm.
-
!python {model: stock.picking}: |
pick = self.browse(cr, uid, ref("incomming_shipment"), context=context)
From fab4e1b5b8371aebc4e9e808011f343aa919a880 Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Fri, 30 Aug 2013 16:00:53 +0530
Subject: [PATCH 64/97] [IMP] add invoice state in stock.move
bzr revid: rma@tinyerp.com-20130830103053-qm5ggzg8jmdai3hb
---
addons/account_anglo_saxon/test/anglo_saxon.yml | 1 +
addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml | 1 +
2 files changed, 2 insertions(+)
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 3ea85fc0d73..0a2dcf5f5fc 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -195,6 +195,7 @@
product_qty: 1.0
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
+ invoice_state: 2binvoiced
move_type: direct
picking_type_id: stock.picking_type_out
-
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 bb6200e148b..6d0b1718c74 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -197,6 +197,7 @@
product_id: product_fifo_anglo_saxon
product_qty: 1.0
location_dest_id: stock.stock_location_customers
+ invoice_state: 2binvoiced
move_type: direct
picking_type_id: stock.picking_type_out
-
From 5e65f7d667a105feacb7d30f3f7193e3f0dffb9a Mon Sep 17 00:00:00 2001
From: "Randhir Mayatra (OpenERP)"
Date: Fri, 30 Aug 2013 17:48:07 +0530
Subject: [PATCH 65/97] [IMP] improve reun_scheduler_yml
bzr revid: rma@tinyerp.com-20130830121807-r0k46ftwaxg1ccg4
---
addons/purchase/test/process/run_scheduler.yml | 5 -----
1 file changed, 5 deletions(-)
diff --git a/addons/purchase/test/process/run_scheduler.yml b/addons/purchase/test/process/run_scheduler.yml
index b8c4019ed1a..ff29a2a39f1 100644
--- a/addons/purchase/test/process/run_scheduler.yml
+++ b/addons/purchase/test/process/run_scheduler.yml
@@ -6,13 +6,8 @@
!record {model: procurement.order, id: procurement_order_testcase0}:
location_id: stock.stock_location_stock
name: Test scheduler for RFQ
- procure_method: make_to_order
product_id: product.product_product_45
product_qty: 15.0
--
- I confirm on procurement order.
--
- !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_testcase0}
-
I run the scheduler.
-
From 0dba7a7d4aaeb5b08f5bcdd5d37a4786ea0994b5 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 30 Aug 2013 15:25:07 +0200
Subject: [PATCH 66/97] [WIP] Add owner on quants and pack operations. Add
owner option in warehouse settings. Change purchase_id on picking.
bzr revid: jco@openerp.com-20130830132507-oqrixcaxqjzuboyb
---
addons/purchase/stock_view.xml | 6 ++---
addons/stock/res_config.py | 3 +++
addons/stock/res_config_view.xml | 4 +++
addons/stock/security/stock_security.xml | 5 ++++
addons/stock/stock.py | 31 ++++++++++++++++--------
addons/stock/stock_view.xml | 10 +++++---
6 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/addons/purchase/stock_view.xml b/addons/purchase/stock_view.xml
index 07aefef2e14..a924a5c341e 100644
--- a/addons/purchase/stock_view.xml
+++ b/addons/purchase/stock_view.xml
@@ -13,12 +13,12 @@
- Incoming Picking Inherited
+ Picking Inheritedstock.picking
-
-
+
+
diff --git a/addons/stock/res_config.py b/addons/stock/res_config.py
index 0f9e1e5943f..3abfc34ca23 100644
--- a/addons/stock/res_config.py
+++ b/addons/stock/res_config.py
@@ -62,6 +62,9 @@ This installs the module product_expiry."""),
'group_stock_tracking_lot': fields.boolean("Track serial number on logistic units (pallets)",
implied_group='stock.group_tracking_lot',
help="""When you select a serial number on product moves, you can get the upstream or downstream traceability of that product."""),
+ 'group_stock_tracking_owner': fields.boolean("Manage owner on stock",
+ implied_group='stock.group_tracking_owner',
+ help="""This way you can receive products attributed to a certain owner. """),
'module_stock_account': fields.boolean("Generate accounting entries per stock movement",
implied_group='stock.group_inventory_valuation',
help="""Allows to configure inventory valuations on products and product categories."""),
diff --git a/addons/stock/res_config_view.xml b/addons/stock/res_config_view.xml
index f5015b146b5..d3654b7abee 100644
--- a/addons/stock/res_config_view.xml
+++ b/addons/stock/res_config_view.xml
@@ -38,6 +38,10 @@
+
+
+
+
diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml
index 6df63f351e7..105c4a7b7ce 100644
--- a/addons/stock/security/stock_security.xml
+++ b/addons/stock/security/stock_security.xml
@@ -29,6 +29,11 @@
+
+ Manage Different Stock Owners
+
+
+
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 819762b06c2..d000d38b04a 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -157,7 +157,7 @@ class stock_quant(osv.osv):
'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'),
- 'partner_id': fields.related('lot_id', 'partner_id', type='many2one', relation="res.partner", string="Owner", store=True), # TODO implement store={}
+ 'owner_id': fields.many2one('res.partner', 'Owner', help="This is the owner of the quant"),
'create_date': fields.datetime('Creation Date'),
'in_date': fields.datetime('Incoming Date'),
@@ -653,9 +653,11 @@ class stock_picking(osv.osv):
'product_qty': qty,
'quant_id': quant.id,
'product_id': quant.product_id.id,
- 'lot_id': quant.lot_id.id,
+ 'lot_id': quant.lot_id and quant.lot_id.id or False,
'product_uom_id': quant.product_id.uom_id.id,
+ 'owner_id': quant.owner_id and quant.owner_id.id or False,
'cost': quant.cost,
+ 'package_id': quant.package_id and quant.package_id.id or False,
}, context=context)
if remaining_qty > 0:
pack_operation_obj.create(cr, uid, {
@@ -750,7 +752,8 @@ class stock_picking(osv.osv):
'history_ids': [(4, move.id)],
'in_date': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
'company_id': move.company_id.id,
- 'lot_id': ops.lot_id and ops.lot_id.id or False,
+ 'lot_id': ops.lot_id and ops.lot_id.id or False,
+ 'owner_id': ops.owner_id and ops.owner_id.id or False,
'reservation_id': move.id, #Reserve at once
'package_id': ops.result_package_id and ops.result_package_id.id or False,
}
@@ -929,7 +932,7 @@ class stock_production_lot(osv.osv):
'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type', '<>', 'service')]),
'quant_ids': fields.one2many('stock.quant', 'lot_id', 'Quants'),
'create_date': fields.datetime('Creation Date'),
- 'partner_id': fields.many2one('res.partner', 'Owner'),
+# 'partner_id': fields.many2one('res.partner', 'Owner'),
}
_defaults = {
'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'stock.lot.serial'),
@@ -942,8 +945,8 @@ class stock_production_lot(osv.osv):
res = []
for lot in self.browse(cr, uid, ids, context=context):
name = lot.name
- if lot.partner_id:
- name += ' (' + lot.partner_id.name + ')'
+# if lot.partner_id:
+# name += ' (' + lot.partner_id.name + ')'
res.append((lot.id, name))
return res
@@ -1654,7 +1657,7 @@ class stock_move(osv.osv):
}, context=context)
if move.move_dest_id and move.propagate:
- self.split(self, cr, uid, move.move_dest_id, qty, context=context)
+ self.split(cr, uid, move.move_dest_id, qty, context=context)
return new_move
class stock_inventory(osv.osv):
@@ -2079,6 +2082,7 @@ class stock_pack_operation(osv.osv):
'lot_id': fields.many2one('stock.production.lot', 'Lot/Serial Number'),
'result_package_id': fields.many2one('stock.quant.package', 'Container Package', help="If set, the operations are packed into this package", required=False, ondelete='cascade'),
'date': fields.datetime('Date', required=True),
+ 'owner_id': fields.many2one('res.partner', 'Owner', help="Owner of the quants"),
#'update_cost': fields.boolean('Need cost update'),
'cost': fields.float("Cost", help="Unit Cost for this product line"),
'currency': fields.many2one('res.currency', string="Currency", help="Currency in which Unit cost is expressed", ondelete='CASCADE'),
@@ -2095,9 +2099,16 @@ class stock_pack_operation(osv.osv):
res += "package_id <> " + str(ops.package_id.id)
if ops.lot_id:
if res:
- res += ", lot_id <> " + str(ops.lot_id.id)
- else:
- res += "lot_id <> " + str(ops.lot_id.id)
+ res += ", "
+ res += "lot_id <> " + str(ops.lot_id.id)
+ if ops.owner_id:
+ if res:
+ res += ", "
+ res += "owner_id <> " + str(ops.owner_id.id)
+ else:
+ if res:
+ res += ", "
+ res += "owner_id IS NOT NULL"
return res
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 30038952ce7..866d0ef64d2 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -614,11 +614,12 @@
-
-
-
+
+
+
+
-
+
@@ -1544,6 +1545,7 @@
+
From b38138d555ddcaab48f8efc3e8efd799fbb9320d Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 30 Aug 2013 17:12:01 +0200
Subject: [PATCH 67/97] [IMP] Invoice_state on procurement order should be
defined in stock_account
bzr revid: jco@openerp.com-20130830151201-6xwnaxymdynaja7h
---
addons/sale/sale.py | 6 ------
addons/stock/stock.py | 3 ++-
addons/stock_account/stock.py | 9 ++++++++-
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 6535ed7bc6d..b849c7d62c1 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -1072,12 +1072,6 @@ class procurement_order(osv.osv):
_inherit = 'procurement.order'
_columns = {
'sale_line_id': fields.many2one('sale.order.line', string='Sale Order Line'),
- 'invoice_state': fields.selection(
- [
- ("invoiced", "Invoiced"),
- ("2binvoiced", "To Be Invoiced"),
- ("none", "Not Applicable")
- ], "Invoice Control", required=True),
}
_defaults = {
'invoice_state': 'none',
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index d000d38b04a..5439d10d225 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1623,10 +1623,11 @@ class stock_move(osv.osv):
self.action_done(cr, uid, res, context=context)
return res
+
+
def split(self, cr, uid, move, qty, context=None):
"""
Splits qty from move move into a new move
- It will check if it can propagate the split
"""
if move.product_qty==qty:
return move.id
diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py
index 312b1668f6d..a06f00d93a3 100644
--- a/addons/stock_account/stock.py
+++ b/addons/stock_account/stock.py
@@ -42,10 +42,17 @@ class procurement_rule(osv.osv):
class procurement_order(osv.osv):
_inherit = "procurement.order"
+ _columns = {
+ 'invoice_state': fields.selection(
+ [("invoiced", "Invoiced"),
+ ("2binvoiced", "To Be Invoiced"),
+ ("none", "Not Applicable")
+ ], "Invoice Control", required=True),
+ }
def _run_move_create(self, cr, uid, procurement, context=None):
res = super(procurement_order, self)._run_move_create(cr, uid, procurement, context=context)
- res.update({'invoice_state': procurement.rule_id.invoice_state in ('none', False) and procurement.invoice_state or procurement.rule_id.invoice_state })
+ res.update({'invoice_state': (procurement.rule_id.invoice_state in ('none', False) and procurement.invoice_state or procurement.rule_id.invoice_state) or 'none'})
return res
From 20e762dd242af2959c482db31aa0f64927ca0930 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Fri, 30 Aug 2013 17:22:56 +0200
Subject: [PATCH 68/97] [IMP] Invoice_state in procurement order defaults
bzr revid: jco@openerp.com-20130830152256-npdkrlefn3lxurwn
---
addons/sale/sale.py | 3 ---
addons/stock_account/stock.py | 4 ++++
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index b849c7d62c1..497b99ef1b8 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -1073,7 +1073,4 @@ class procurement_order(osv.osv):
_columns = {
'sale_line_id': fields.many2one('sale.order.line', string='Sale Order Line'),
}
- _defaults = {
- 'invoice_state': 'none',
- }
\ No newline at end of file
diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py
index a06f00d93a3..ed7d9568340 100644
--- a/addons/stock_account/stock.py
+++ b/addons/stock_account/stock.py
@@ -54,6 +54,10 @@ class procurement_order(osv.osv):
res = super(procurement_order, self)._run_move_create(cr, uid, procurement, context=context)
res.update({'invoice_state': (procurement.rule_id.invoice_state in ('none', False) and procurement.invoice_state or procurement.rule_id.invoice_state) or 'none'})
return res
+
+ defaults = {
+ 'invoice_state': 'none'
+ }
#----------------------------------------------------------
From 4e805a6a5a962fc62f5b829e70387b585e64ef3a Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 2 Sep 2013 09:30:12 +0200
Subject: [PATCH 69/97] [FIX] _defaults instead of defaults (psi)
bzr revid: jco@openerp.com-20130902073012-p9s5tws5kvisgodi
---
addons/stock/stock.py | 4 ++++
addons/stock_account/stock.py | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 5439d10d225..0f7f7e2b176 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -727,6 +727,10 @@ class stock_picking(osv.osv):
for move in picking.move_lines:
quant_obj.quants_unreserve(cr, uid, move, context=context)
res2[move.id] = move.product_qty
+ # Resort pack_operation_ids
+
+
+ #
for ops in picking.pack_operation_ids:
#Find moves that correspond
if ops.product_id:
diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py
index ed7d9568340..ff48e865737 100644
--- a/addons/stock_account/stock.py
+++ b/addons/stock_account/stock.py
@@ -55,7 +55,7 @@ class procurement_order(osv.osv):
res.update({'invoice_state': (procurement.rule_id.invoice_state in ('none', False) and procurement.invoice_state or procurement.rule_id.invoice_state) or 'none'})
return res
- defaults = {
+ _defaults = {
'invoice_state': 'none'
}
From 61dba9384c8543d687142fc65cc64639c9d8f57b Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 2 Sep 2013 15:32:52 +0200
Subject: [PATCH 70/97] [IMP] Invoice_state in stock_location: defaults/...
should be removed for invoice_state in procrule
bzr revid: jco@openerp.com-20130902133252-8mipn3owtwelwqkg
---
addons/stock_account/stock_account_view.xml | 12 +++++++++++-
addons/stock_location/stock_location.py | 1 -
addons/stock_location/stock_location_demo_cpu1.xml | 2 --
addons/stock_location/stock_location_view.xml | 1 -
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/addons/stock_account/stock_account_view.xml b/addons/stock_account/stock_account_view.xml
index c6f9a581858..6f3d469b440 100644
--- a/addons/stock_account/stock_account_view.xml
+++ b/addons/stock_account/stock_account_view.xml
@@ -41,6 +41,16 @@
-
+
+
+ stock.procurement.rule.inherit.form
+ procurement.rule
+
+
+
+
+
+
+
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index fc36d48d7f9..e052063cc3c 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -140,7 +140,6 @@ class procurement_rule(osv.osv):
}
_defaults = {
'procure_method': 'make_to_stock',
- 'invoice_state': 'none',
'propagate': True,
'delay': 0,
}
diff --git a/addons/stock_location/stock_location_demo_cpu1.xml b/addons/stock_location/stock_location_demo_cpu1.xml
index 227be08333f..f89a1f98002 100644
--- a/addons/stock_location/stock_location_demo_cpu1.xml
+++ b/addons/stock_location/stock_location_demo_cpu1.xml
@@ -38,7 +38,6 @@
- nonemove
@@ -53,7 +52,6 @@
move
- nonemake_to_stock
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index f3a0a0726c9..34213638b84 100644
--- a/addons/stock_location/stock_location_view.xml
+++ b/addons/stock_location/stock_location_view.xml
@@ -17,7 +17,6 @@
-
From aa877dcfb472acea3c7397a09d7d5e2b724a87f4 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Mon, 2 Sep 2013 17:11:08 +0200
Subject: [PATCH 71/97] [FIX] yml test
bzr revid: qdp-launchpad@openerp.com-20130902151108-d2r9lpt0z5ertt2m
---
addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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 bb6200e148b..afed068c468 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -203,12 +203,12 @@
I need to check the availability of the product, So I make my picking order for processing later.
-
!python {model: stock.picking}: |
- self.action_confirm(cr, uid, [ref('stock_picking_out001')], context=context)
+ self.action_confirm(cr, uid, [ref('stock_picking_out001_fifo')], context=context)
-
I check the product availability, Product is available in the stock and ready to be sent.
-
!python {model: stock.picking}: |
- picking = self.browse(cr, uid, ref("stock_picking_out001"))
+ picking = self.browse(cr, uid, ref("stock_picking_out001_fifo"))
assert picking.state == "confirmed", "Picking should be confirmed."
for move_line in picking.move_lines:
assert move_line.state == "confirmed", "Move should be confirmed."
From 8cf4c8d311795e990798ee59097c5bb4747b65e8 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Mon, 2 Sep 2013 17:23:10 +0200
Subject: [PATCH 72/97] [FIX] procurement yml test
bzr revid: qdp-launchpad@openerp.com-20130902152310-2cp25k722evo90v4
---
addons/procurement/test/procurement.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/addons/procurement/test/procurement.yml b/addons/procurement/test/procurement.yml
index 0e663646c84..353bcaff3e8 100644
--- a/addons/procurement/test/procurement.yml
+++ b/addons/procurement/test/procurement.yml
@@ -15,8 +15,8 @@
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
- I check that procurement order is done
+ I check that procurement order is in exception, as at first there isn't any suitable rule
-
!python {model: procurement.order}: |
proc_order = self.browse(cr, uid, ref('procurement_order0'), context=context)
- assert proc_order.state == 'done'
+ assert proc_order.state == 'exception'
From 0ebd738ef61e68b720d07c31822f55a442c1fb15 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Mon, 2 Sep 2013 17:27:00 +0200
Subject: [PATCH 73/97] [FIX] stock: inventory yaml test
bzr revid: qdp-launchpad@openerp.com-20130902152700-sfbrf2v07kf5ld9a
---
addons/stock/test/inventory.yml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/addons/stock/test/inventory.yml b/addons/stock/test/inventory.yml
index f36aab303d3..6afc7e9d4ba 100644
--- a/addons/stock/test/inventory.yml
+++ b/addons/stock/test/inventory.yml
@@ -53,17 +53,17 @@
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_14')
- product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
+ product = self.browse(cr, uid, ref('inventory_product'), context=context)
assert product.qty_available == 10, 'Expecting 10 products, got %.2f on location stock_location_14!' % (product.qty_available,)
context['location'] = ref('stock.stock_location_stock')
- product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
+ product = self.browse(cr, uid, ref('inventory_product'), context=context)
assert product.qty_available == 10, 'Expecting 10 products, got %.2f on location stock_location_stock!' % (product.qty_available,)
-
I check that the quantity on hand is 0 on a brother location
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_components')
- product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
+ product = self.browse(cr, uid, ref('inventory_product'), context=context)
assert product.qty_available == 0, 'Expecting 0 products, got %.2f on location stock_location_components!' % (product.qty_available,)
-
I create another inventory
@@ -82,7 +82,7 @@
-
!python {model: stock.inventory}: |
inv = self.browse(cr, uid, ref('inventory_test1'), context=context)
- assert len(inv.line_ids) == 1, "Wrong number of inventory lines."
+ assert inv.line_ids and len(inv.line_ids) == 1, "Wrong number of inventory lines."
assert len(inv.line_ids[0].product_qty) == 10, "Wrong quantity in inventory line."
assert len(inv.line_ids[0].product_id.id) == ref('inventory_product'), "Wrong product in inventory line."
-
From 0bcda6375c82ba51933775966a36167d02ecb2c6 Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Mon, 2 Sep 2013 19:07:40 +0200
Subject: [PATCH 74/97] [IMP] Order pack operations, reserve should be with
domain instead of preferred order
bzr revid: jco@openerp.com-20130902170740-o24rqc3brvbytmrc
---
addons/stock/stock.py | 56 ++++++++++++++++++++-----------------
addons/stock/stock_view.xml | 2 +-
2 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index ecf9bf5dea9..0c34a5085f8 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -634,7 +634,9 @@ class stock_picking(osv.osv):
})
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)
+ move_obj = self.pool.get("stock.move")
+ move_obj.write(cr, uid, backorder_move_ids, {'picking_id': backorder_id}, context=context)
+ self.pool.get("stock.picking").action_confirm(cr, uid, [picking.id], context=context)
return backorder_id
return False
@@ -657,7 +659,7 @@ class stock_picking(osv.osv):
'product_uom_id': quant.product_id.uom_id.id,
'owner_id': quant.owner_id and quant.owner_id.id or False,
'cost': quant.cost,
- 'package_id': quant.package_id and quant.package_id.id or False,
+ 'package_id': quant.package_id and quant.package_id.id or False,
}, context=context)
if remaining_qty > 0:
pack_operation_obj.create(cr, uid, {
@@ -729,9 +731,11 @@ class stock_picking(osv.osv):
res2[move.id] = move.product_qty
# Resort pack_operation_ids
-
- #
- for ops in picking.pack_operation_ids:
+ orderedpackops = picking.pack_operation_ids
+ #Sort packing operations such that packing operations with most specific information
+ orderedpackops.sort(key = lambda x: (x.package_id and -1 or 0) + (x.lot_id and -1 or 0))
+
+ for ops in orderedpackops:
#Find moves that correspond
if ops.product_id:
#TODO: Should have order such that things with lots and packings are searched first
@@ -764,10 +768,13 @@ class stock_picking(osv.osv):
quant_id = quant_obj.create(cr, uid, vals, context=context)
else:
#Quants get
- domain = [('reservation_id', '=', False)]
- prefered_order = op_obj._get_preferred_order(cr, uid, ops.id, context=context)
+ prefered_order = "reservation_id IS NOT NULL"
+ domain = op_obj._get_domain(cr, uid, ops, context=context)
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order=prefered_order, context=context)
quant_obj.quants_reserve(cr, uid, quants, move, context=context)
+ #In the end, move quants in correct package
+ if create and ops.result_package_id:
+ quant_obj.write(cr, uid, [x[0] for x in quants], {'package_id': ops.result_package_id.id}, context=context)
res2[move.id] -= qty
res[ops.id] = {}
res[ops.id][ops.product_id.id] = qty_to_do
@@ -788,6 +795,9 @@ class stock_picking(osv.osv):
res2[move.id] -= qty
res.setdefault(ops.id, {}).setdefault(quant.product_id.id, 0.0)
res[ops.id][quant.product_id.id] += qty_to_do
+ #Add parent package
+ if create and ops.result_package_id:
+ self.pool.get("stock.package").write(cr, uid, [ops.package_id.id], {'parent_id': ops.result_package_id.id}, context=context)
return (res, res2)
@@ -2098,25 +2108,21 @@ class stock_pack_operation(osv.osv):
'date': fields.date.context_today,
}
- def _get_preferred_order(self, cr, uid, id, context=None):
- ops = self.browse(cr, uid, id, context=context)
- res = ""
- if ops.package_id:
- res += "package_id <> " + str(ops.package_id.id)
- if ops.lot_id:
- if res:
- res += ", "
- res += "lot_id <> " + str(ops.lot_id.id)
- if ops.owner_id:
- if res:
- res += ", "
- res += "owner_id <> " + str(ops.owner_id.id)
- else:
- if res:
- res += ", "
- res += "owner_id IS NOT NULL"
- return res
+ def _get_domain(self, cr, uid, ops, context=None):
+ '''
+ Gives domain for different
+ '''
+ res = []
+ if ops.package_id:
+ res.append(('package_id', '=', ops.package_id.id), )
+ if ops.lot_id:
+ res.append(('lot_id', '=', ops.lot_id.id), )
+ if ops.owner_id:
+ res.append(('owner_id', '=', ops.owner_id.id), )
+ else:
+ res.append(('owner_id', '=', False), )
+ return res
#TODO: this function can be refactored
def _search_and_increment(self, cr, uid, picking_id, key, context=None):
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 866d0ef64d2..f1d30972148 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -1561,7 +1561,7 @@
-
+
From 35475907aee21343053b8555728e0a15deca46df Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Tue, 3 Sep 2013 10:01:21 +0200
Subject: [PATCH 75/97] [FIX]stock: improve stock_picking_type view
bzr revid: csn@openerp.com-20130903080121-xu0zhp555tvk54u7
---
addons/stock/stock.py | 53 ++++++++++++++++++++++++++++++-------
addons/stock/stock_data.xml | 24 +++--------------
addons/stock/stock_view.xml | 33 ++++++++++++++---------
3 files changed, 68 insertions(+), 42 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 0c34a5085f8..ab05b169f0d 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -2285,13 +2285,6 @@ class product_template(osv.osv):
'supply_method': 'buy',
}
-class stock_picking_code(osv.osv):
- _name = "stock.picking.code"
- _description = "Will group picking types for kanban view"
- _columns = {
- 'name': fields.char("Picking Type", translate=True),
- }
-
class stock_picking_type(osv.osv):
_name = "stock.picking.type"
_description = "The picking type determines the picking view"
@@ -2383,17 +2376,56 @@ class stock_picking_type(osv.osv):
result[type_id]['latest_picking_waiting'] = cmp(pick.date[:10], time.strftime('%Y-%m-%d'))
return result
+ def onchange_picking_code(self, cr, uid, ids, picking_code=False):
+ if not picking_code:
+ return False
+
+ obj_data = self.pool.get('ir.model.data')
+ stock_loc = obj_data.get_object_reference(cr, uid, 'stock','stock_location_stock')[1]
+
+ result = {
+ 'default_location_src_id': stock_loc,
+ 'default_location_dest_id': stock_loc,
+ }
+ if picking_code == 'incoming':
+ result['default_location_src_id'] = obj_data.get_object_reference(cr, uid, 'stock','stock_location_suppliers')[1]
+ return {'value': result}
+ if picking_code == 'outgoing':
+ result['default_location_dest_id'] = obj_data.get_object_reference(cr, uid, 'stock','stock_location_customers')[1]
+ return {'value': result}
+ else:
+ return {'value': result}
+
+ def name_get(self, cr, uid, ids, context=None):
+ """Overides orm name_get method to display 'Warehouse_name: PickingType_name' """
+ if not isinstance(ids, list):
+ ids = [ids]
+ res = []
+ if not ids:
+ return res
+ reads = self.browse(cr, uid, ids, context=context)
+ for record in reads:
+ name = record.warehouse_id.name+': '+record.name
+ res.append((record.id, name))
+ return res
+
+ 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('name', translate=True, required=True),
- 'pack': fields.boolean('Pack', help='This picking type needs packing interface'),
+ 'pack': fields.boolean('Prefill Pack Operations', help='This picking type needs packing interface'),
'auto_force_assign': fields.boolean('Automatic Availability', help='This picking type does\'t need to check for the availability in stock'),
'color': fields.integer('Color Index'),
'delivery': fields.boolean('Print delivery'),
'sequence_id': fields.many2one('ir.sequence', 'Sequence', required=True),
'default_location_src_id': fields.many2one('stock.location', 'Default Source Location'),
'default_location_dest_id': fields.many2one('stock.location', 'Default Destination Location'),
- 'code_id': fields.many2one('stock.picking.code', 'Picking type code', required=True),
+ 'code_id': fields.selection([('incoming', 'Suppliers'), ('outgoing', 'Customers'), ('internal', 'Internal')], 'Picking type code', required=True),
'return_picking_type_id': fields.many2one('stock.picking.type', 'Picking Type for Returns'),
+ 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
# Statistics for the kanban view
'weekly_picking': fields.function(_get_picking_data,
@@ -2422,4 +2454,7 @@ class stock_picking_type(osv.osv):
type='string', multi='_get_picking_history'),
}
+ _defaults = {
+ 'warehouse_id': _default_warehouse,
+ }
diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml
index ff56e44548f..79d7545f8f4 100644
--- a/addons/stock/stock_data.xml
+++ b/addons/stock/stock_data.xml
@@ -77,12 +77,6 @@
-
-
-
-
@@ -106,24 +100,12 @@
-
- Suppliers
-
-
-
- Customers
-
-
-
- Internal
-
-
Receptions
-
+ incomingTrue
@@ -132,13 +114,13 @@
-
+ outgoingInternal Transfers
-
+ internal
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index f1d30972148..313fcf90a85 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -1205,18 +1205,27 @@
stock.picking.type
From 8a23802e9e6c3ce95f8bbb24cb126cdaa53897de Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Tue, 3 Sep 2013 11:03:34 +0200
Subject: [PATCH 76/97] [IMP] stock: removed location input and location output
on warehouse
bzr revid: qdp-launchpad@openerp.com-20130903090334-iqtk4a762volg5s2
---
addons/point_of_sale/point_of_sale.py | 18 +++++++++++++++---
addons/purchase/purchase.py | 6 ------
addons/purchase/purchase_view.xml | 2 +-
.../purchase_requisition.py | 11 +----------
.../sale_stock/test/picking_order_policy.yml | 2 --
addons/stock/stock.py | 12 ++----------
addons/stock/stock_data.xml | 2 --
addons/stock/stock_demo.xml | 4 ----
addons/stock/stock_demo.yml | 2 --
addons/stock/stock_view.xml | 4 ----
10 files changed, 19 insertions(+), 44 deletions(-)
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index 591f65cf925..4767d90f188 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -642,6 +642,7 @@ class pos_order(osv.osv):
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
'account_move': fields.many2one('account.move', 'Journal Entry', readonly=True),
'picking_id': fields.many2one('stock.picking', 'Picking', readonly=True),
+ 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True),
'note': fields.text('Internal Notes'),
'nb_print': fields.integer('Number of Print', readonly=True),
'pos_reference': fields.char('Receipt Ref', size=64, readonly=True),
@@ -660,6 +661,13 @@ class pos_order(osv.osv):
return session_record.config_id.pricelist_id and session_record.config_id.pricelist_id.id or False
return False
+ def _get_out_picking_type(self, cr, uid, context=None):
+ try:
+ picking_type = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context)
+ except:
+ picking_type = False
+ return picking_type
+
_defaults = {
'user_id': lambda self, cr, uid, context: uid,
'state': 'draft',
@@ -669,6 +677,7 @@ class pos_order(osv.osv):
'session_id': _default_session,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
'pricelist_id': _default_pricelist,
+ 'picking_type_id': _get_out_picking_type,
}
def create(self, cr, uid, values, context=None):
@@ -697,18 +706,21 @@ class pos_order(osv.osv):
if not order.state=='draft':
continue
addr = order.partner_id and partner_obj.address_get(cr, uid, [order.partner_id.id], ['delivery']) or {}
+ picking_type = order.picking_type_id
picking_id = picking_obj.create(cr, uid, {
'origin': order.name,
'partner_id': addr.get('delivery',False),
- 'picking_type_id': self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id,
+ 'picking_type_id': picking_type.id,
'company_id': order.company_id.id,
'move_type': 'direct',
'note': order.note or "",
'invoice_state': 'none',
}, context=context)
self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
- location_id = order.warehouse_id.lot_stock_id.id
- output_id = order.warehouse_id.lot_output_id.id
+ location_id = picking_type.default_location_src_id.id
+ output_id = picking_type.default_location_dest_id.id
+ if not location_id or not output_id:
+ raise osv.except_osv(_('Error!'), _('Missing source or destination location for picking type %s. Please configure those fields and try again.' % (picking_type.name,)))
for line in order.lines:
if line.product_id and line.product_id.type == 'service':
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index ec4144f4cc6..d0876df7ef1 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -308,12 +308,6 @@ class purchase_order(osv.osv):
values.update({'location_id': location_id})
return {'value':values}
- def onchange_warehouse_id(self, cr, uid, ids, warehouse_id):
- if not warehouse_id:
- return {}
- warehouse = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id)
- return {'value':{'location_id': warehouse.lot_input_id.id, 'dest_address_id': False}}
-
def onchange_partner_id(self, cr, uid, ids, partner_id):
partner = self.pool.get('res.partner')
if not partner_id:
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index 973757770c4..f152d5ba066 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -196,7 +196,7 @@
-
+
diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py
index 85fda69a65e..6d08d163696 100644
--- a/addons/purchase_requisition/purchase_requisition.py
+++ b/addons/purchase_requisition/purchase_requisition.py
@@ -136,22 +136,13 @@ class purchase_requisition(osv.osv):
return res
def _prepare_purchase_order(self, cr, uid, requisition, supplier, context=None):
- if not requisition.warehouse_id:
- warehouse_obj = self.pool.get('stock.warehouse')
-
- warehouse_id = warehouse_obj.search(cr, uid, [('company_id', '=', requisition.company_id.id)], context=context)
- if not warehouse_id:
- raise osv.except_osv(_('Warning!'), _('No warehouse found for this company.'))
- location_id = warehouse_obj.browse(cr, uid, warehouse_id, context=context)[0].lot_input_id.id
- else:
- location_id = requisition.warehouse_id.lot_input_id.id
supplier_pricelist = supplier.property_product_pricelist_purchase and supplier.property_product_pricelist_purchase.id or False
return {
'origin': requisition.name,
'date_order': requisition.date_end or fields.date.context_today(self, cr, uid, context=context),
'partner_id': supplier.id,
'pricelist_id': supplier_pricelist,
- 'location_id': location_id,
+ #'location_id': location_id,
'company_id': requisition.company_id.id,
'fiscal_position': supplier.property_account_position and supplier.property_account_position.id or False,
'requisition_id': requisition.id,
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index f903d160400..4251c7a98a8 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -58,7 +58,6 @@
assert picking.invoice_state == (sale_order.order_policy=='picking' and '2binvoiced') or 'none',"Invoice policy is not correspond with sale order."
assert len(picking.move_lines) == len(sale_order.order_line), "Total move of delivery order are not corresposning with total sale order lines."
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.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)
@@ -72,7 +71,6 @@
assert move.product_packaging.id == order_line.product_packaging.id,"Product packaging is not correspond."
assert move.partner_id.id == order_line.address_allotment_id.id or sale_order.partner_shipping_id.id,"Address is not correspond"
#assert move.location_id.id == location_id,"Source Location is not correspond."
- #assert move.location_dest_id == output_id,"Destination Location is not correspond."
assert move.price_unit == order_line.product_id.standard_price or 0.0,"Price Unit is not correspond"
-
Now, I dispatch delivery order.
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index ab05b169f0d..494105a7784 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1921,24 +1921,16 @@ class stock_warehouse(osv.osv):
'name': fields.char('Name', size=128, required=True, select=True),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
'partner_id': fields.many2one('res.partner', 'Owner Address'),
- 'lot_input_id': fields.many2one('stock.location', 'Location Input', required=True, domain=[('usage', '<>', 'view')]),
'lot_stock_id': fields.many2one('stock.location', 'Location Stock', required=True, domain=[('usage', '=', 'internal')]),
- 'lot_output_id': fields.many2one('stock.location', 'Location Output', required=True, domain=[('usage', '<>', 'view')]),
}
- def _default_lot_input_stock_id(self, cr, uid, context=None):
+ def _default_stock_id(self, cr, uid, context=None):
lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
return lot_input_stock.id
- def _default_lot_output_id(self, cr, uid, context=None):
- lot_output = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_output')
- return lot_output.id
-
_defaults = {
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),
- 'lot_input_id': _default_lot_input_stock_id,
- 'lot_stock_id': _default_lot_input_stock_id,
- 'lot_output_id': _default_lot_output_id,
+ 'lot_stock_id': _default_stock_id,
}
diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml
index 79d7545f8f4..b591263f4b2 100644
--- a/addons/stock/stock_data.xml
+++ b/addons/stock/stock_data.xml
@@ -210,9 +210,7 @@ watch your stock valuation, and track production lots upstream and downstream (b
-->
-
-
diff --git a/addons/stock/stock_demo.xml b/addons/stock/stock_demo.xml
index 7d1515c427f..c42e216f636 100644
--- a/addons/stock/stock_demo.xml
+++ b/addons/stock/stock_demo.xml
@@ -251,20 +251,16 @@
- Chicago Warehouse
-
- Birmingham Warehouse
-
diff --git a/addons/stock/stock_demo.yml b/addons/stock/stock_demo.yml
index cf8d1f71572..07763ee8cc1 100644
--- a/addons/stock/stock_demo.yml
+++ b/addons/stock/stock_demo.yml
@@ -22,9 +22,7 @@
-
!record {model: stock.warehouse, id: warehouse_icecream}:
name: Ice Cream Shop
- lot_input_id: location_refrigerator
lot_stock_id: location_refrigerator
- lot_output_id: location_delivery_counter
-
!record {model: product.product, id: product_icecream}:
default_code: 001
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 313fcf90a85..d78f825bb1b 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -498,9 +498,7 @@
-
-
@@ -517,9 +515,7 @@
-
-
From bbf0113c618748497d165a3650ff9159e90fbd48 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Tue, 3 Sep 2013 11:07:46 +0200
Subject: [PATCH 77/97] [FIX] stock: inventory yaml test
bzr revid: qdp-launchpad@openerp.com-20130903090746-64s7pv9fi212pvi3
---
addons/stock/test/inventory.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/addons/stock/test/inventory.yml b/addons/stock/test/inventory.yml
index 6afc7e9d4ba..b687aded288 100644
--- a/addons/stock/test/inventory.yml
+++ b/addons/stock/test/inventory.yml
@@ -83,8 +83,8 @@
!python {model: stock.inventory}: |
inv = self.browse(cr, uid, ref('inventory_test1'), context=context)
assert inv.line_ids and len(inv.line_ids) == 1, "Wrong number of inventory lines."
- assert len(inv.line_ids[0].product_qty) == 10, "Wrong quantity in inventory line."
- assert len(inv.line_ids[0].product_id.id) == ref('inventory_product'), "Wrong product in inventory line."
+ assert inv.line_ids[0].product_qty == 10, "Wrong quantity in inventory line."
+ assert inv.line_ids[0].product_id.id == ref('inventory_product'), "Wrong product in inventory line."
-
I modify the inventory line and set the quantity to 20 product on this new inventory
-
From 82ef7cb00e12a19e6891376d28692debebca7cfd Mon Sep 17 00:00:00 2001
From: Josse Colpaert
Date: Tue, 3 Sep 2013 11:17:26 +0200
Subject: [PATCH 78/97] [FIX] Creating quants only when usage is correct and
prefered_order works without <>
bzr revid: jco@openerp.com-20130903091726-l8aeona692964nyu
---
addons/stock/stock.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 494105a7784..b922a3c5566 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -750,7 +750,7 @@ class stock_picking(osv.osv):
qty = move.remaining_qty
qty_to_do -= move.remaining_qty
- if create and move.location_id != 'internal':
+ if create and move.location_id.usage != 'internal':
# Create quants
vals = {
'product_id': move.product_id.id,
@@ -841,7 +841,6 @@ class stock_picking(osv.osv):
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)
-
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)
@@ -1505,13 +1504,12 @@ class stock_move(osv.osv):
# quant_obj.quants_move(cr, uid, quants, move, location_dest_id, context=context)
# should replace the above 2 lines
domain = ['|', ('reservation_id', '=', False), ('reservation_id', '=', move.id)]
- prefered_order = 'reservation_id<>' + str(move.id)
+ prefered_order = 'reservation_id'
# if lot_id:
# prefered_order = 'lot_id<>' + lot_id + ", " + prefered_order
# if pack_id:
# prefered_order = 'pack_id<>' + pack_id + ", " + prefered_order
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order = prefered_order, context=context)
-
#Will move all quants_get and as such create negative quants
quant_obj.quants_move(cr, uid, quants, move, context=context)
quant_obj.quants_unreserve(cr, uid, move, context=context)
From a19a3ae5b2ae57890fce98c013c34c701f0cb902 Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Tue, 3 Sep 2013 11:26:36 +0200
Subject: [PATCH 79/97] [FIX]stock_complex_route: code_id is now a selection
bzr revid: csn@openerp.com-20130903092636-l9448und718n8c0q
---
addons/stock_complex_routes/stock_complex_routes.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock_complex_routes/stock_complex_routes.xml b/addons/stock_complex_routes/stock_complex_routes.xml
index d1850560e5f..f2c71735527 100644
--- a/addons/stock_complex_routes/stock_complex_routes.xml
+++ b/addons/stock_complex_routes/stock_complex_routes.xml
@@ -14,7 +14,7 @@
dropship
-
+ incoming
From 23dfd3bbbcc7c6fb764047a2088b211392fa2473 Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Tue, 3 Sep 2013 11:42:14 +0200
Subject: [PATCH 80/97] [FIX]remove required warehouse_id field on
stock_picking_type and remove warehouse_id field from route + rename some
route for better understanding
bzr revid: csn@openerp.com-20130903094214-i4knuovdvfdn0b9m
---
addons/stock/stock.py | 6 ++++--
addons/stock_location/stock_location.py | 8 --------
addons/stock_location/stock_location_data.xml | 6 +++---
addons/stock_location/stock_location_view.xml | 10 ----------
4 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index b922a3c5566..4e1d4310b6d 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -2395,7 +2395,9 @@ class stock_picking_type(osv.osv):
return res
reads = self.browse(cr, uid, ids, context=context)
for record in reads:
- name = record.warehouse_id.name+': '+record.name
+ name = record.name
+ if record.warehouse_id:
+ name = record.warehouse_id.name+': '+name
res.append((record.id, name))
return res
@@ -2415,7 +2417,7 @@ class stock_picking_type(osv.osv):
'default_location_dest_id': fields.many2one('stock.location', 'Default Destination Location'),
'code_id': fields.selection([('incoming', 'Suppliers'), ('outgoing', 'Customers'), ('internal', 'Internal')], 'Picking type code', required=True),
'return_picking_type_id': fields.many2one('stock.picking.type', 'Picking Type for Returns'),
- 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
+ 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse'),
# Statistics for the kanban view
'weekly_picking': fields.function(_get_picking_data,
diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py
index e052063cc3c..bedf59baf1e 100644
--- a/addons/stock_location/stock_location.py
+++ b/addons/stock_location/stock_location.py
@@ -29,28 +29,20 @@ class stock_location_route(osv.osv):
_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'),
}
diff --git a/addons/stock_location/stock_location_data.xml b/addons/stock_location/stock_location_data.xml
index b282fcbf08c..c5f438b920a 100644
--- a/addons/stock_location/stock_location_data.xml
+++ b/addons/stock_location/stock_location_data.xml
@@ -22,7 +22,7 @@
-->
- Ship only
+ Sale: Ship only20
@@ -79,7 +79,7 @@
- Pack + Ship
+ Sale: Pack + Ship15
@@ -128,7 +128,7 @@
- Pick + Pack + Ship
+ Sale: Pick + Pack + Ship20
diff --git a/addons/stock_location/stock_location_view.xml b/addons/stock_location/stock_location_view.xml
index 34213638b84..f74b2d9321b 100644
--- a/addons/stock_location/stock_location_view.xml
+++ b/addons/stock_location/stock_location_view.xml
@@ -156,14 +156,6 @@
-
-
-
-
-
-
-
-
@@ -174,7 +166,6 @@
-
@@ -187,7 +178,6 @@