[IMP] Solve landed costs bug + invoice_state in account_anglo_saxon.yml
This commit is contained in:
parent
aabebbbc6c
commit
df655f00a3
|
@ -198,8 +198,8 @@
|
||||||
product_uom_qty: 1.0
|
product_uom_qty: 1.0
|
||||||
product_uom: product.product_uom_unit
|
product_uom: product.product_uom_unit
|
||||||
location_dest_id: stock.stock_location_customers
|
location_dest_id: stock.stock_location_customers
|
||||||
invoice_state: 2binvoiced
|
|
||||||
move_type: direct
|
move_type: direct
|
||||||
|
invoice_state: 2binvoiced
|
||||||
picking_type_id: stock.picking_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.
|
I need to check the availability of the product, So I make my picking order for processing later.
|
||||||
|
|
|
@ -200,7 +200,7 @@
|
||||||
product_id: product_fifo_anglo_saxon
|
product_id: product_fifo_anglo_saxon
|
||||||
product_uom_qty: 1.0
|
product_uom_qty: 1.0
|
||||||
location_dest_id: stock.stock_location_customers
|
location_dest_id: stock.stock_location_customers
|
||||||
invoice_state: 2binvoiced
|
invoice_state: 2binvoiced
|
||||||
move_type: direct
|
move_type: direct
|
||||||
picking_type_id: stock.picking_type_out
|
picking_type_id: stock.picking_type_out
|
||||||
-
|
-
|
||||||
|
|
|
@ -277,6 +277,7 @@ class mrp_bom(osv.osv):
|
||||||
@return: result: List of dictionaries containing product details.
|
@return: result: List of dictionaries containing product details.
|
||||||
result2: List of dictionaries containing Work Center details.
|
result2: List of dictionaries containing Work Center details.
|
||||||
"""
|
"""
|
||||||
|
uom_obj = self.pool.get("product.uom")
|
||||||
routing_obj = self.pool.get('mrp.routing')
|
routing_obj = self.pool.get('mrp.routing')
|
||||||
all_prod = [] + (previous_products or [])
|
all_prod = [] + (previous_products or [])
|
||||||
master_bom = master_bom or bom
|
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:
|
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]))
|
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)
|
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)
|
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_id': bom_line_id.product_id.id,
|
||||||
'product_qty': quantity,
|
'product_qty': quantity,
|
||||||
'product_uom': bom_line_id.product_uom.id,
|
'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,
|
'product_uos': bom_line_id.product_uos and bom_line_id.product_uos.id or False,
|
||||||
})
|
})
|
||||||
elif bom_id:
|
elif bom_id:
|
||||||
|
all_prod.append(bom_line_id.product_id.id)
|
||||||
bom2 = self.browse(cr, uid, bom_id, context=context)
|
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)
|
properties=properties, level=level + 10, previous_products=all_prod, master_bom=master_bom, context=context)
|
||||||
result = result + res[0]
|
result = result + res[0]
|
||||||
result2 = result2 + res[1]
|
result2 = result2 + res[1]
|
||||||
|
|
|
@ -67,12 +67,13 @@ class StockMove(osv.osv):
|
||||||
move_obj = self.pool.get('stock.move')
|
move_obj = self.pool.get('stock.move')
|
||||||
prod_obj = self.pool.get("product.product")
|
prod_obj = self.pool.get("product.product")
|
||||||
proc_obj = self.pool.get("procurement.order")
|
proc_obj = self.pool.get("procurement.order")
|
||||||
|
uom_obj = self.pool.get("product.uom")
|
||||||
to_explode_again_ids = []
|
to_explode_again_ids = []
|
||||||
processed_ids = []
|
processed_ids = []
|
||||||
bis = self._check_phantom_bom(cr, uid, move, context=context)
|
bis = self._check_phantom_bom(cr, uid, move, context=context)
|
||||||
if bis:
|
if bis:
|
||||||
factor = move.product_qty
|
|
||||||
bom_point = bom_obj.browse(cr, SUPERUSER_ID, bis[0], context=context)
|
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)
|
res = bom_obj._bom_explode(cr, SUPERUSER_ID, bom_point, move.product_id, factor, [], context=context)
|
||||||
|
|
||||||
state = 'confirmed'
|
state = 'confirmed'
|
||||||
|
@ -91,7 +92,7 @@ class StockMove(osv.osv):
|
||||||
'state': state,
|
'state': state,
|
||||||
'name': line['name'],
|
'name': line['name'],
|
||||||
'procurement_id': move.procurement_id.id,
|
'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)
|
mid = move_obj.copy(cr, uid, move.id, default=valdef, context=context)
|
||||||
to_explode_again_ids.append(mid)
|
to_explode_again_ids.append(mid)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
product_uom_qty: 3.0
|
product_uom_qty: 3.0
|
||||||
product_uom: product.product_uom_unit
|
product_uom: product.product_uom_unit
|
||||||
location_dest_id: stock.stock_location_customers
|
location_dest_id: stock.stock_location_customers
|
||||||
invoice_state: 2binvoiced
|
invoice_state: 2binvoiced
|
||||||
move_type: direct
|
move_type: direct
|
||||||
picking_type_id: stock.picking_type_out
|
picking_type_id: stock.picking_type_out
|
||||||
-
|
-
|
||||||
|
|
|
@ -184,21 +184,17 @@ class stock_landed_cost(osv.osv):
|
||||||
total_weight = 0.0
|
total_weight = 0.0
|
||||||
total_volume = 0.0
|
total_volume = 0.0
|
||||||
total_line = 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)
|
||||||
vals = self.get_valuation_lines(cr, uid, [cost.id], picking_ids=picking_ids, context=context)
|
for v in vals:
|
||||||
for v in vals:
|
for line in cost.cost_lines:
|
||||||
v.update({'cost_id': cost.id, 'cost_line_id': line.id})
|
v.update({'cost_id': cost.id, 'cost_line_id': line.id})
|
||||||
self.pool.get('stock.valuation.adjustment.lines').create(cr, uid, v, context=context)
|
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)
|
||||||
total_qty += v.get('quantity', 0.0)
|
total_cost += v.get('former_cost', 0.0)
|
||||||
elif line.split_method == 'by_current_cost_price':
|
total_weight += v.get('weight', 0.0)
|
||||||
total_cost += v.get('former_cost', 0.0)
|
total_volume += v.get('volume', 0.0)
|
||||||
elif line.split_method == 'by_weight':
|
total_line += 1
|
||||||
total_weight += v.get('weight', 0.0)
|
|
||||||
elif line.split_method == 'by_volume':
|
|
||||||
total_volume += v.get('volume', 0.0)
|
|
||||||
else:
|
|
||||||
total_line += 1
|
|
||||||
for line in cost.cost_lines:
|
for line in cost.cost_lines:
|
||||||
for valuation in cost.valuation_adjustment_lines:
|
for valuation in cost.valuation_adjustment_lines:
|
||||||
value = 0.0
|
value = 0.0
|
||||||
|
|
Loading…
Reference in New Issue