ACCOUNT,PURCHASE,SALE: use partner lang for description
bzr revid: ced-b10e0d798c2c4612a31585ad90e504c7d8b3676dmaster
parent
15fe85f663
commit
152cea8074
|
@ -44,7 +44,7 @@
|
|||
<page string="Line">
|
||||
<field name="name" select="1"/>
|
||||
<field name="account_id" on_change="onchange_account_id(parent.partner_id,account_id)" />
|
||||
<field name="product_id" select="1" on_change="product_id_change(product_id, uos_id, quantity, name)"/>
|
||||
<field name="product_id" select="1" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id)"/>
|
||||
<field name="uos_id"/>
|
||||
<field name="quantity" select="1"/>
|
||||
<field name="price_unit" select="1"/>
|
||||
|
|
|
@ -500,10 +500,15 @@ class account_invoice_line(osv.osv):
|
|||
'quantity': lambda *a: 1,
|
||||
'discount': lambda *a: 0.0
|
||||
}
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice'):
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=None):
|
||||
if not product:
|
||||
return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}}
|
||||
res = self.pool.get('product.product').browse(cr, uid, product)
|
||||
lang=False
|
||||
if partner_id:
|
||||
lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang']
|
||||
context={'lang': lang}
|
||||
print context
|
||||
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
|
||||
result = {'price_unit': res.list_price, 'invoice_line_tax_id':map(lambda x: x.id, res.taxes_id)}
|
||||
if not name:
|
||||
result['name'] = res.name
|
||||
|
|
|
@ -311,10 +311,14 @@ class purchase_order_line(osv.osv):
|
|||
raise osv.except_osv('No Pricelist !', 'You have to select a pricelist in the sale 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
|
||||
if partner_id:
|
||||
lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang']
|
||||
context={'lang':lang}
|
||||
price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], product, qty or 1.0, partner_id, {'uom': uom})[pricelist]
|
||||
prod = self.pool.get('product.product').read(cr, uid, [product], ['taxes_id','name','seller_delay','uom_po_id','description_purchase'])[0]
|
||||
dt = (DateTime.now() + DateTime.RelativeDateTime(days=prod['seller_delay'] or 0.0)).strftime('%Y-%m-%d')
|
||||
prod_name = self.pool.get('product.product').name_get(cr, uid, [product])[0][1]
|
||||
prod_name = self.pool.get('product.product').name_get(cr, uid, [product], context=context)[0][1]
|
||||
res = {'value': {'price_unit': price, 'name':prod_name, 'taxes_id':prod['taxes_id'], 'date_planned': dt,'notes':prod['description_purchase']}}
|
||||
domain = {}
|
||||
if not uom:
|
||||
|
|
|
@ -588,6 +588,8 @@ class sale_order_line(osv.osv):
|
|||
return super(sale_order_line, self).copy(cr, uid, id, default, context)
|
||||
|
||||
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False):
|
||||
if partner_id:
|
||||
lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang']
|
||||
context = {'lang':lang}
|
||||
if not product:
|
||||
return {'value': {'price_unit': 0.0, 'notes':'', 'weight' : 0}, 'domain':{'product_uom':[]}}
|
||||
|
|
Loading…
Reference in New Issue