From d342adbee8c533a53b32ad16bf207fb509321f8b Mon Sep 17 00:00:00 2001
From: Cedric Snauwaert
Date: Wed, 7 Aug 2013 11:58:11 +0200
Subject: [PATCH 01/30] [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/30] [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 038aee2d06f89d97b075d825f9f862b3aabf3dfd Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Wed, 21 Aug 2013 15:07:42 +0530
Subject: [PATCH 03/30] [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 95c6b17bdef105c13627986809247bc899e2fe97 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Thu, 22 Aug 2013 15:59:52 +0530
Subject: [PATCH 04/30] [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 79d4ed0b8fd8058ee990ccc2aeefa03de140e1fd Mon Sep 17 00:00:00 2001
From: "Pooja Zankhariya (OpenERP Trainee)"
Date: Thu, 22 Aug 2013 18:02:05 +0530
Subject: [PATCH 05/30] [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 b42f8b53db1c84c1e07e43bae27347565fef7497 Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Fri, 23 Aug 2013 12:21:19 +0530
Subject: [PATCH 06/30] [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 b97a9da42dfdbd5ec1bc76f2f0860e4f5f0cce0d Mon Sep 17 00:00:00 2001
From: "Bharat R. Devnani (OpenERP)"
Date: Mon, 26 Aug 2013 12:44:05 +0530
Subject: [PATCH 07/30] [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 08/30] [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 8a3640f70eff3543dccad922ae36a3c77f43a76e Mon Sep 17 00:00:00 2001
From: "Pooja Zankhariya (OpenERP Trainee)"
Date: Tue, 27 Aug 2013 14:33:25 +0530
Subject: [PATCH 09/30] [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 10/30] [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 11/30] [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 12/30] [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 13/30] [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 14/30] [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 15/30] [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 16/30] [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 18/30] [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 19/30] [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 20/30] [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 21/30] [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 22/30] [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 23/30] [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 8794b51ec0e693262e59e96eb4d368b9bab870d9 Mon Sep 17 00:00:00 2001
From: "Turkesh Patel (Open ERP)"
Date: Thu, 29 Aug 2013 16:58:27 +0530
Subject: [PATCH 24/30] [IMP] remove fill inventory wizard and improved view.
bzr revid: tpa@tinyerp.com-20130829112827-ywcklnhz0p6fxi4a
---
addons/stock/__openerp__.py | 1 -
addons/stock/stock.py | 6 +-
addons/stock/stock_view.xml | 59 ++++++++-----------
addons/stock/wizard/__init__.py | 1 -
addons/stock/wizard/stock_fill_inventory.py | 51 ----------------
.../wizard/stock_fill_inventory_view.xml | 33 -----------
6 files changed, 26 insertions(+), 125 deletions(-)
delete mode 100644 addons/stock/wizard/stock_fill_inventory.py
delete mode 100644 addons/stock/wizard/stock_fill_inventory_view.xml
diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py
index 57019053481..15d072be6e0 100644
--- a/addons/stock/__openerp__.py
+++ b/addons/stock/__openerp__.py
@@ -69,7 +69,6 @@ Dashboard / Reports for Warehouse Management will include:
'stock_data.xml',
'wizard/stock_move_view.xml',
'wizard/stock_change_product_qty_view.xml',
- 'wizard/stock_fill_inventory_view.xml',
'wizard/stock_inventory_merge_view.xml',
'wizard/stock_location_product_view.xml',
'wizard/stock_inventory_line_split_view.xml',
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 642bd060976..0ce0a448c17 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1784,7 +1784,7 @@ class stock_inventory(osv.osv):
#TODO test
self.action_cancel_draft(cr, uid, ids, context=context)
- def _prepare_inventory(self, cr, uid, ids, full_of_zeros=False, context=None):
+ def prepare_inventory(self, cr, uid, ids, context=None):
inventory_line_obj = self.pool.get('stock.inventory.line')
for inventory in self.browse(cr, uid, ids, context=context):
#clean the existing inventory lines before redoing an inventory proposal
@@ -1793,8 +1793,6 @@ class stock_inventory(osv.osv):
#compute the inventory lines and create them
vals = self._get_inventory_lines(cr, uid, inventory, context=context)
for product_line in vals:
- if full_of_zeros:
- product_line['product_qty'] = 0
inventory_line_obj.create(cr, uid, product_line, context=context)
return self.write(cr, uid, ids, {'state': 'confirm'})
@@ -1843,7 +1841,7 @@ class stock_inventory_line(osv.osv):
'company_id': fields.related('inventory_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, select=True, readonly=True),
'prod_lot_id': fields.many2one('stock.production.lot', 'Serial Number', domain="[('product_id','=',product_id)]"),
'state': fields.related('inventory_id', 'state', type='char', string='Status', readonly=True),
- 'real_qty':fields.related('product_id','qty_available', type='float', string='Real Quantity', store=True),
+ 'real_qty':fields.related('product_id','qty_available', type='float', string='Real Quantity'),
}
def _resolve_inventory_line(self, cr, uid, inventory_line, theorical_lines, context=None):
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index c79b91d35f3..e274eb28758 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -101,16 +101,13 @@