summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosse Colpaert <jco@odoo.com>2014-09-11 16:02:44 +0200
committerJosse Colpaert <jco@odoo.com>2014-09-12 13:50:53 +0200
commitdf655f00a3a7ad9fb3454862df3afec585ccbe3b (patch)
tree197a2f7483fc8a1dc28386296905485f7f439dad
parentaabebbbc6c80a82d533924cd05bd4e685a5285d1 (diff)
[IMP] Solve landed costs bug + invoice_state in account_anglo_saxon.yml
-rw-r--r--addons/account_anglo_saxon/test/anglo_saxon.yml2
-rw-r--r--addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml2
-rw-r--r--addons/mrp/mrp.py10
-rw-r--r--addons/mrp/stock.py5
-rw-r--r--addons/stock_invoice_directly/test/stock_invoice_directly.yml2
-rw-r--r--addons/stock_landed_costs/stock_landed_costs.py22
6 files changed, 22 insertions, 21 deletions
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index 32f5fd12dee..6733f8794a0 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -198,8 +198,8 @@
product_uom_qty: 1.0
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
- invoice_state: 2binvoiced
move_type: direct
+ invoice_state: 2binvoiced
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 daeefc09730..5762ee128d1 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -200,7 +200,7 @@
product_id: product_fifo_anglo_saxon
product_uom_qty: 1.0
location_dest_id: stock.stock_location_customers
- invoice_state: 2binvoiced
+ invoice_state: 2binvoiced
move_type: direct
picking_type_id: stock.picking_type_out
-
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 83794c2c4ba..850f8c22eda 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -277,6 +277,7 @@ class mrp_bom(osv.osv):
@return: result: List of dictionaries containing product details.
result2: List of dictionaries containing Work Center details.
"""
+ uom_obj = self.pool.get("product.uom")
routing_obj = self.pool.get('mrp.routing')
all_prod = [] + (previous_products or [])
master_bom = master_bom or bom
@@ -319,7 +320,6 @@ class mrp_bom(osv.osv):
if bom_line_id.product_id.id in all_prod:
raise osv.except_osv(_('Invalid Action!'), _('BoM "%s" contains a BoM line with a product recursion: "%s".') % (master_bom.name,bom_line_id.product_id.name_get()[0][1]))
- all_prod.append(bom_line_id.product_id.id)
quantity = _factor(bom_line_id.product_qty * factor, bom_line_id.product_efficiency, bom_line_id.product_rounding)
bom_id = self._bom_find(cr, uid, bom_line_id.product_uom.id, product_id=bom_line_id.product_id.id, properties=properties, context=context)
@@ -331,12 +331,16 @@ class mrp_bom(osv.osv):
'product_id': bom_line_id.product_id.id,
'product_qty': quantity,
'product_uom': bom_line_id.product_uom.id,
- 'product_uos_qty': bom_line_id.product_uos and bom_line_id.product_uos_qty * factor or False,
+ 'product_uos_qty': bom_line_id.product_uos and _factor(bom_line_id.product_uos_qty * factor, bom_line_id.product_efficiency, bom_line_id.product_rounding) or False,
'product_uos': bom_line_id.product_uos and bom_line_id.product_uos.id or False,
})
elif bom_id:
+ all_prod.append(bom_line_id.product_id.id)
bom2 = self.browse(cr, uid, bom_id, context=context)
- res = self._bom_explode(cr, uid, bom2, bom_line_id.product_id, quantity,
+ # We need to convert to units/UoM of chosen BoM
+ factor2 = uom_obj._compute_qty(cr, uid, bom_line_id.product_uom.id, quantity, bom2.product_uom.id)
+ quantity2 = factor2 / bom2.product_qty
+ res = self._bom_explode(cr, uid, bom2, bom_line_id.product_id, quantity2,
properties=properties, level=level + 10, previous_products=all_prod, master_bom=master_bom, context=context)
result = result + res[0]
result2 = result2 + res[1]
diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py
index f472abe4b71..e8613e7fb8e 100644
--- a/addons/mrp/stock.py
+++ b/addons/mrp/stock.py
@@ -67,12 +67,13 @@ class StockMove(osv.osv):
move_obj = self.pool.get('stock.move')
prod_obj = self.pool.get("product.product")
proc_obj = self.pool.get("procurement.order")
+ uom_obj = self.pool.get("product.uom")
to_explode_again_ids = []
processed_ids = []
bis = self._check_phantom_bom(cr, uid, move, context=context)
if bis:
- factor = move.product_qty
bom_point = bom_obj.browse(cr, SUPERUSER_ID, bis[0], context=context)
+ factor = uom_obj._compute_qty(cr, SUPERUSER_ID, move.product_uom.id, move.product_uom_qty, bom_point.product_uom.id) / bom_point.product_qty
res = bom_obj._bom_explode(cr, SUPERUSER_ID, bom_point, move.product_id, factor, [], context=context)
state = 'confirmed'
@@ -91,7 +92,7 @@ class StockMove(osv.osv):
'state': state,
'name': line['name'],
'procurement_id': move.procurement_id.id,
- 'split_from': move.id, #Needed in order to keep purchase connection, but will be removed by unlink
+ 'split_from': move.id, #Needed in order to keep sale connection, but will be removed by unlink
}
mid = move_obj.copy(cr, uid, move.id, default=valdef, context=context)
to_explode_again_ids.append(mid)
diff --git a/addons/stock_invoice_directly/test/stock_invoice_directly.yml b/addons/stock_invoice_directly/test/stock_invoice_directly.yml
index f2c79bd5e52..1e352b42462 100644
--- a/addons/stock_invoice_directly/test/stock_invoice_directly.yml
+++ b/addons/stock_invoice_directly/test/stock_invoice_directly.yml
@@ -13,7 +13,7 @@
product_uom_qty: 3.0
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
- invoice_state: 2binvoiced
+ invoice_state: 2binvoiced
move_type: direct
picking_type_id: stock.picking_type_out
-
diff --git a/addons/stock_landed_costs/stock_landed_costs.py b/addons/stock_landed_costs/stock_landed_costs.py
index b4c350a229a..1952194387c 100644
--- a/addons/stock_landed_costs/stock_landed_costs.py
+++ b/addons/stock_landed_costs/stock_landed_costs.py
@@ -184,21 +184,17 @@ class stock_landed_cost(osv.osv):
total_weight = 0.0
total_volume = 0.0
total_line = 0.0
- for line in cost.cost_lines:
- vals = self.get_valuation_lines(cr, uid, [cost.id], picking_ids=picking_ids, context=context)
- for v in vals:
+ vals = self.get_valuation_lines(cr, uid, [cost.id], picking_ids=picking_ids, context=context)
+ for v in vals:
+ for line in cost.cost_lines:
v.update({'cost_id': cost.id, 'cost_line_id': line.id})
self.pool.get('stock.valuation.adjustment.lines').create(cr, uid, v, context=context)
- if line.split_method == 'by_quantity':
- total_qty += v.get('quantity', 0.0)
- elif line.split_method == 'by_current_cost_price':
- total_cost += v.get('former_cost', 0.0)
- elif line.split_method == 'by_weight':
- total_weight += v.get('weight', 0.0)
- elif line.split_method == 'by_volume':
- total_volume += v.get('volume', 0.0)
- else:
- total_line += 1
+ total_qty += v.get('quantity', 0.0)
+ total_cost += v.get('former_cost', 0.0)
+ total_weight += v.get('weight', 0.0)
+ total_volume += v.get('volume', 0.0)
+ total_line += 1
+
for line in cost.cost_lines:
for valuation in cost.valuation_adjustment_lines:
value = 0.0