[MERGE] merged from lp:~openerp/openobject-addons/trunk/
bzr revid: hmo@tinyerp.com-20100326103716-8dgskmgnp62l4vda
This commit is contained in:
@@ -147,8 +147,9 @@ class account_analytic_line(osv.osv):
|
||||
|
||||
# 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)
|
||||
# Take the company currency as the reference one
|
||||
context['currency_id']=company_obj.browse(cr,uid,company_id).currency_id.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),
|
||||
|
||||
@@ -278,7 +278,7 @@ class account_move_line(osv.osv):
|
||||
data['amount_currency'] = v
|
||||
return data
|
||||
|
||||
def _on_create_write(self, cr, uid, id, context={}):
|
||||
def on_create_write(self, cr, uid, id, context={}):
|
||||
ml = self.browse(cr, uid, id, context)
|
||||
return map(lambda x: x.id, ml.move_id.line_id)
|
||||
|
||||
@@ -733,7 +733,7 @@ class account_move_line(osv.osv):
|
||||
state = ' colors="red:state==\'draft\'"'
|
||||
|
||||
#xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5"%s>\n\t''' % (title, state)
|
||||
xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="_on_create_write"%s>\n\t''' % (title, state)
|
||||
xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write"%s>\n\t''' % (title, state)
|
||||
fields = []
|
||||
|
||||
widths = {
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_account_form" model="ir.actions.act_window">
|
||||
<field name="name">List of Accounts</field>
|
||||
<field name="res_model">account.account</field>
|
||||
@@ -681,7 +681,7 @@
|
||||
<field name="type">tree</field>
|
||||
<field eval="4" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Account Entry Line" editable="top" on_write="_on_create_write">
|
||||
<tree string="Account Entry Line" editable="top" on_write="on_create_write">
|
||||
<field name="date"/>
|
||||
<field name="period_id"/>
|
||||
<field name="move_id"/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,7 +15,7 @@
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
@@ -70,7 +70,7 @@ class account_invoice_line(osv.osv):
|
||||
res[field]['states'][key] = value
|
||||
return res
|
||||
|
||||
def _onchange_invoice_line_view(self, cr, uid, id, type, context={}, *args):
|
||||
def onchange_invoice_line_view(self, cr, uid, id, type, context={}, *args):
|
||||
|
||||
if (not type):
|
||||
return {}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page/field[@name='name']" position="before">
|
||||
<field name="state" select="1" on_change="_onchange_invoice_line_view(state)" />
|
||||
<field name="state" select="1" on_change="onchange_invoice_line_view(state)" />
|
||||
<field name="sequence"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
"security/ir.model.access.csv",
|
||||
"wizard/hr_evaluation_mail_view.xml",
|
||||
"hr_evaluation_view.xml",
|
||||
"hr_evaluation_demo.xml",
|
||||
"report/hr_evaluation_report_view.xml"],
|
||||
"active": False,
|
||||
"installable": True
|
||||
|
||||
@@ -220,6 +220,7 @@ class hr_expense_line(osv.osv):
|
||||
|
||||
# Compute based on pricetype of employee company
|
||||
pricetype_id = self.pool.get('hr.employee').browse(cr,uid,employee_id).user_id.company_id.property_valuation_price_type.id
|
||||
context['currency_id']=self.pool.get('hr.employee').browse(cr,uid,employee_id).user_id.company_id.currency_id.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,pricetype_id)
|
||||
amount_unit=product.price_get(pricetype.field, context)[product.id]
|
||||
|
||||
|
||||
@@ -36,16 +36,6 @@ class res_company(osv.osv):
|
||||
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_price_type.currency_id.id:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_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()
|
||||
|
||||
|
||||
@@ -533,7 +533,6 @@ class product_product(osv.osv):
|
||||
def price_get(self, cr, uid, ids, ptype='list_price', context={}):
|
||||
res = {}
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
|
||||
for product in self.browse(cr, uid, ids, context=context):
|
||||
res[product.id] = product[ptype] or 0.0
|
||||
if ptype == 'list_price':
|
||||
@@ -543,6 +542,16 @@ class product_product(osv.osv):
|
||||
uom = product.uos_id or product.uom_id
|
||||
res[product.id] = product_uom_obj._compute_price(cr, uid,
|
||||
uom.id, res[product.id], context['uom'])
|
||||
# Convert from price_type currency to asked one
|
||||
if 'currency_id' in context:
|
||||
pricetype_obj = self.pool.get('product.price.type')
|
||||
# Take the price_type currency from the product field
|
||||
# This is right cause a field cannot be in more than one currency
|
||||
price_type_id = pricetype_obj.search(cr,ui,['field','=',ptype])[0]
|
||||
price_type_currency_id = pricetype_obj.browse(cr,uid,price_type_id).currency_id.id
|
||||
res[product.id] = self.pool.get('res.currency').compute(cr, uid, price_type_currency_id,
|
||||
context['currency_id'], res[product.id],context=context)
|
||||
|
||||
return res
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
||||
+13
-5
@@ -122,8 +122,13 @@ class stock_location(osv.osv):
|
||||
for r in result:
|
||||
c = (context or {}).copy()
|
||||
c['location'] = id
|
||||
product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read, pricetype.field], context=c)
|
||||
final_value += (product[field_to_read] * product[pricetype.field])
|
||||
product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read], context=c)
|
||||
# Compute the amount_unit in right currency
|
||||
|
||||
context['currency_id']=self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id
|
||||
amount_unit=self.pool.get('product.product').browse(cr,uid,r['product_id']).price_get(pricetype.field, context)[r['product_id']]
|
||||
|
||||
final_value += (product[field_to_read] * amount_unit)
|
||||
return final_value
|
||||
|
||||
def _product_value(self, cr, uid, ids, field_names, arg, context={}):
|
||||
@@ -223,6 +228,7 @@ class stock_location(osv.osv):
|
||||
# Take the user company and pricetype
|
||||
price_type_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
|
||||
context['currency_id']=self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id
|
||||
|
||||
if not product_ids:
|
||||
product_ids = product_obj.search(cr, uid, [])
|
||||
@@ -669,7 +675,9 @@ class stock_picking(osv.osv):
|
||||
if type in ('in_invoice', 'in_refund'):
|
||||
# Take the user company and pricetype
|
||||
price_type_id=self.pool.get('res.users').browse(cr,users,users).company_id.property_valuation_price_type.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
|
||||
context['currency_id']=move_line.company_id.currency_id.id
|
||||
|
||||
amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id]
|
||||
return amount_unit
|
||||
else:
|
||||
@@ -900,7 +908,7 @@ class stock_picking(osv.osv):
|
||||
if (pick.type == 'in') and (move.product_id.cost_method == 'average'):
|
||||
product = product_obj.browse(cr, uid, move.product_id.id)
|
||||
user = users_obj.browse(cr, uid, uid)
|
||||
|
||||
context['currency_id'] = move.company_id.currency_id.id
|
||||
qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id)
|
||||
pricetype = False
|
||||
if user.company_id.property_valuation_price_type:
|
||||
@@ -1548,7 +1556,7 @@ class stock_move(osv.osv):
|
||||
# Base computation on valuation price type
|
||||
else:
|
||||
company_id=move.company_id.id
|
||||
|
||||
context['currency_id']=move.company_id.currency_id.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(pricetype.field, context)[move.product_id.id]
|
||||
amount=amount_unit * q or 1.0
|
||||
|
||||
Reference in New Issue
Block a user