diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py
index 34a422579fe..0abe79f01c6 100644
--- a/addons/account/account_analytic_line.py
+++ b/addons/account/account_analytic_line.py
@@ -83,7 +83,6 @@ class account_analytic_line(osv.osv):
'account.analytic.account': (_get_account_line, ['company_id'], 50),
'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10),
},
- # multi='all',
help="The related account currency if not equal to the company one."),
'company_id': fields.many2one('res.company','Company',required=True),
'amount_currency': fields.function(_amount_currency, method=True, digits=(16, int(config['price_accuracy'])), string='Amount currency',
@@ -91,7 +90,6 @@ class account_analytic_line(osv.osv):
'account.analytic.account': (_get_account_line, ['company_id'], 50),
'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10),
},
- # multi='all',
help="The amount expressed in the related account currency if not equal to the company one."),
'ref': fields.char('Reference', size=32),
}
@@ -124,13 +122,15 @@ class account_analytic_line(osv.osv):
# (_check_company, 'You can not create analytic line that is not in the same company than the account line', ['account_id'])
]
- # Compute the cost based on the valuation pricelist define into company
- # property_product_pricelist property
+ # Compute the cost based on the price type define into company
+ # property_valuation_price_type property
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id,
date,unit=False, context=None):
+ if context==None:
+ context={}
uom_obj = self.pool.get('product.uom')
product_obj = self.pool.get('product.product')
-# if unit_amount and prod_id:
+ company_obj=self.pool.get('res.company')
if prod_id:
prod = product_obj.browse(cr, uid, prod_id)
a = prod.product_tmpl_id.property_account_expense.id
@@ -141,16 +141,13 @@ class account_analytic_line(osv.osv):
_('There is no expense account defined ' \
'for this product: "%s" (id:%d)') % \
(prod.name, prod.id,))
- if company_id:
- company_obj = self.pool.get('res.company')
- else:
- company_id=self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context)
- pricelist_id=company_obj.browse(cr,uid,company_id).property_valuation_pricelist.id
- amount_unit = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist_id],
- prod_id, unit_amount or 1.0, None, {
- 'uom': unit,
- 'date': date,
- })[pricelist_id]
+ if not company_id:
+ company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context)
+
+ # Compute based on pricetype
+ pricetype=self.pool.get('product.price.type').browse(cr,uid,company_obj.browse(cr,uid,company_id).property_valuation_price_type.id)
+ amount_unit=prod.price_get(pricetype.field, context)[prod.id]
+
amount=amount_unit*unit_amount or 1.0
return {'value': {
'amount': - round(amount, 2),
diff --git a/addons/hr_timesheet/wizard/sign_in_out.py b/addons/hr_timesheet/wizard/sign_in_out.py
index 69be06a4b88..ac2f9d3d5c4 100644
--- a/addons/hr_timesheet/wizard/sign_in_out.py
+++ b/addons/hr_timesheet/wizard/sign_in_out.py
@@ -106,7 +106,7 @@ def _write(self, cr, uid, data, emp_id, context):
res = timesheet_obj.default_get(cr, uid, ['product_id','product_uom_id'])
if not res['product_uom_id']:
raise wizard.except_wizard(_('UserError'), _('No cost unit defined for this employee !'))
- up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour, res['product_uom_id'])['value']
+ up = timesheet_obj.on_change_unit_amount(cr, uid, False, res['product_id'], hour, data['form']['date'], res['product_uom_id'])['value']
res['name'] = data['form']['info']
res['account_id'] = data['form']['account_id']
res['unit_amount'] = hour
diff --git a/addons/multi_company/__init__.py b/addons/multi_company/__init__.py
index 0d29405d526..537dbb62253 100644
--- a/addons/multi_company/__init__.py
+++ b/addons/multi_company/__init__.py
@@ -18,6 +18,7 @@
# along with this program. If not, see .
#
##############################################################################
+import product
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/multi_company/__terp__.py b/addons/multi_company/__terp__.py
index 83d6afa777f..d541c91cf4a 100644
--- a/addons/multi_company/__terp__.py
+++ b/addons/multi_company/__terp__.py
@@ -32,10 +32,12 @@
'depends': [
'base',
'sale',
- 'project'
+ 'project',
+ 'product',
],
'init_xml': [],
'update_xml': [
+ "multi_company_view.xml",
#'security/ir.model.access.csv',
],
'demo_xml': [
diff --git a/addons/multi_company/multi_company_demo.xml b/addons/multi_company/multi_company_demo.xml
index 292cae0a0b5..f550d133b28 100644
--- a/addons/multi_company/multi_company_demo.xml
+++ b/addons/multi_company/multi_company_demo.xml
@@ -3,21 +3,13 @@
-
-
- Valuation Pricelist USD
- valuation
+
+
+ Cost Price USD
+ standard_price_usd
-
-
- Default Valuation Pricelist Version USD
-
-
-
-
- Default Valuation Pricelist Line USD
-
+
@@ -54,7 +46,7 @@
OpenERP US
-
+
diff --git a/addons/product/company.py b/addons/product/company.py
index 32c4f3bccd2..f23d010b600 100644
--- a/addons/product/company.py
+++ b/addons/product/company.py
@@ -25,26 +25,26 @@ from osv import fields, osv
class res_company(osv.osv):
_inherit = 'res.company'
_columns = {
- 'property_valuation_pricelist': fields.property(
- 'product.pricelist',
+ 'property_valuation_price_type': fields.property(
+ 'product.price.type',
type='many2one',
- relation='product.pricelist',
- domain=[('type','=','valuation')],
- string="Valuation Pricelist",
+ relation='product.price.type',
+ domain=[],
+ string="Valuation Price Type",
method=True,
view_load=True,
- help="This pricelist will be used, instead of the default one, \
- for valuation to the current company"),
+ help="The price type field in the selected price type will be used, instead of the default one, \
+ for valuation of product in the current company"),
}
def _check_currency(self, cr, uid, ids):
for rec in self.browse(cr, uid, ids):
- if rec.currency_id.id <> rec.property_valuation_pricelist.currency_id.id:
+ if rec.currency_id.id <> rec.property_valuation_price_type.currency_id.id:
return False
return True
_constraints = [
- (_check_currency, 'Error! You can not chooes a pricelist in a different currency than your company.', ['property_valuation_pricelist'])
+ (_check_currency, 'Error! You can not chooes a pricetype in a different currency than your company (Not supported now).', ['property_valuation_price_type'])
]
res_company()
diff --git a/addons/product/company_view.xml b/addons/product/company_view.xml
index 5ccd5982de4..eb0294e2daa 100644
--- a/addons/product/company_view.xml
+++ b/addons/product/company_view.xml
@@ -9,7 +9,7 @@
-
+
diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py
index 0849ee85dcd..857cdc9b89b 100644
--- a/addons/product/pricelist.py
+++ b/addons/product/pricelist.py
@@ -62,6 +62,7 @@ class price_type(osv.osv):
"active": lambda *args: True,
"currency_id": _get_currency
}
+
price_type()
#----------------------------------------------------------
diff --git a/addons/product/product_data.xml b/addons/product/product_data.xml
index 452253f0c96..8037453101e 100644
--- a/addons/product/product_data.xml
+++ b/addons/product/product_data.xml
@@ -81,10 +81,6 @@ parameter) will see those record just disappear.
sale
-
- Valuation Pricelist
- valuation
-
@@ -127,10 +108,10 @@ parameter) will see those record just disappear.
-
- property_valuation_pricelist
-
-
+
+ property_valuation_price_type
+
+
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 00db75ce0f5..afe2ff47ee3 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1328,14 +1328,13 @@ class stock_move(osv.osv):
q = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
if move.product_id.cost_method == 'average' and move.price_unit:
amount = q * move.price_unit
- # Base computation on valuation pricelist
+ # Base computation on valuation price type
else:
company_id=move.company_id.id
- pricelist_id = self.pool.get('res.company').browse(cr,uid,company_id).property_valuation_pricelist.id
- amount_unit = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist_id],
- move.product_id.id, q or 1.0, None, {
- 'date': date,
- })[pricelist_id]
+
+ pricetype=self.pool.get('product.price.type').browse(cr,uid,move.company_id.property_valuation_price_type.id)
+ amount_unit=move.product_id.price_get(cr, uid, ids, pricetype.field, context)
+
amount=amount_unit * q or 1.0
# amount = q * move.product_id.standard_price
diff --git a/addons/stock/wizard/wizard_partial_picking.py b/addons/stock/wizard/wizard_partial_picking.py
index 416558735ff..52714f45eb6 100644
--- a/addons/stock/wizard/wizard_partial_picking.py
+++ b/addons/stock/wizard/wizard_partial_picking.py
@@ -131,7 +131,7 @@ def _do_split(self, cr, uid, data, context):
currency = data['form']['currency%s' % move.id]
qty = uom_obj._compute_qty(cr, uid, uom, qty, product.uom_id.id)
-
+ pricetype=pool.get('product.price.type').browse(cr,uid,user.company_id.property_valuation_price_type.id)
if (qty > 0):
new_price = currency_obj.compute(cr, uid, currency,
user.company_id.currency_id.id, price)
@@ -140,11 +140,14 @@ def _do_split(self, cr, uid, data, context):
if product.qty_available<=0:
new_std_price = new_price
else:
- new_std_price = ((product.standard_price * product.qty_available)\
+ # Get the standard price
+ amount_unit=product.price_get(pricetype.field, context)[product.id]
+ new_std_price = ((amount_unit * product.qty_available)\
+ (new_price * qty))/(product.qty_available + qty)
-
+
+ # Write the field according to price type field
product_obj.write(cr, uid, [product.id],
- {'standard_price': new_std_price})
+ {pricetype.field: new_std_price})
move_obj.write(cr, uid, [move.id], {'price_unit': new_price})
for move in too_few: