Pricelist and pricetype using currency of the company

Terminology improvment

bzr revid: fp@tinyerp.com-00139f1a0259133dc05e768114558ae2feac9661
This commit is contained in:
Fabien Pinckaers 2007-10-23 19:02:01 +00:00
parent 50a405a64c
commit fd2b1840e8
5 changed files with 20 additions and 8 deletions

View File

@ -42,6 +42,13 @@ class price_type(osv.osv):
def _price_field_get(self, cr, uid, context={}):
cr.execute('select name, field_description from ir_model_fields where model in (%s,%s) and ttype=%s', ('product.product', 'product.template', 'float'))
return cr.fetchall()
def _get_currency(self, cr, uid, ctx):
comp = self.pool.get('res.users').browse(cr,uid,uid).company_id
if not comp:
comp_id = self.pool.get('res.company').search(cr, uid, [])[0]
comp = self.pool.get('res.company').browse(cr, uid, comp_id)
return comp.currency_id.id
_name = "product.price.type"
_description = "Price type"
_columns = {
@ -51,7 +58,8 @@ class price_type(osv.osv):
"currency_id" : fields.many2one('res.currency', "Currency", required=True),
}
_defaults = {
"active": lambda *args: True ,
"active": lambda *args: True,
"currency_id": _get_currency
}
price_type()
@ -82,8 +90,16 @@ class product_pricelist(osv.osv):
'version_id': fields.one2many('product.pricelist.version', 'pricelist_id', 'Pricelist Versions'),
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
}
def _get_currency(self, cr, uid, ctx):
comp = self.pool.get('res.users').browse(cr,uid,uid).company_id
if not comp:
comp_id = self.pool.get('res.company').search(cr, uid, [])[0]
comp = self.pool.get('res.company').browse(cr, uid, comp_id)
return comp.currency_id.id
_defaults = {
'active': lambda *a: 1,
"currency_id": _get_currency
}
def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None):

View File

@ -48,12 +48,10 @@ parameter) will see those record just disappear.
<record model="product.price.type" id="list_price">
<field name="name">List Price</field>
<field name="field">list_price</field>
<field name="currency_id" ref="base.EUR"/>
</record>
<record model="product.price.type" id="standard_price">
<field name="name">Cost Price</field>
<field name="field">standard_price</field>
<field name="currency_id" ref="base.EUR"/>
</record>
</data>
</terp>

View File

@ -106,7 +106,7 @@ class purchase_order(osv.osv):
'picking_ids': fields.one2many('stock.picking', 'purchase_id', 'Picking List', readonly=True, help="This is the list of picking list that have been generated for this purchase"),
'shipped':fields.boolean('Received', readonly=True, select=True),
'invoiced':fields.boolean('Invoiced & Paid', readonly=True, select=True),
'invoice_method': fields.selection([('manual','Manual'),('order','From order'),('picking','From picking')], 'Invoicing method', required=True),
'invoice_method': fields.selection([('manual','Manual'),('order','From order'),('picking','From picking')], 'Invoicing Control', required=True),
'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount'),
'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'),
@ -192,7 +192,7 @@ class purchase_order(osv.osv):
if not a:
a = ol.product_id.categ_id.property_account_expense_categ.id
if not a:
raise osv.except_osv('Error !', 'There is no income account defined for this product: "%s" (id:%d)' % (line.product_id.name, line.product_id.id,))
raise osv.except_osv('Error !', 'There is no expense account defined for this product: "%s" (id:%d)' % (line.product_id.name, line.product_id.id,))
else:
a = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category')
il.append((0, False, {
@ -326,7 +326,7 @@ class purchase_order_line(osv.osv):
def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order=False):
if not pricelist:
raise osv.except_osv('No Pricelist !', 'You have to select a pricelist in the sale form !\n Please set one before choosing a product.')
raise osv.except_osv('No Pricelist !', 'You have to select a pricelist in the purchase form !\n Please set one before choosing a product.')
if not product:
return {'value': {'price_unit': 0.0, 'name':'','notes':''}, 'domain':{'product_uom':[]}}
lang=False

View File

@ -19,7 +19,6 @@
<record model="product.pricelist" id="list0">
<field name="name">Default Purchase Pricelist</field>
<field name="type">purchase</field>
<field name="currency_id" ref="base.EUR"/>
</record>
<record model="product.pricelist.version" id="ver0">
<field name="pricelist_id" ref="list0"/>

View File

@ -31,7 +31,6 @@
<record model="product.pricelist" id="list0">
<field name="name">Default Sale Pricelist</field>
<field name="type">sale</field>
<field name="currency_id" ref="base.EUR" />
</record>
<record model="product.pricelist.version" id="ver0">
<field name="pricelist_id" ref="list0"/>