bzr revid: mra@tinyerp.com-20090120060407-6csy4rd8xammgmub
This commit is contained in:
mra (Open ERP) 2009-01-20 11:34:07 +05:30
parent 982d69d89d
commit 804b2e3888
4 changed files with 14 additions and 11 deletions

View File

@ -301,7 +301,8 @@ class purchase_order(osv.osv):
raise osv.except_osv(_('Error !'), _('There is no expense account defined for this product: "%s" (id:%d)') % (ol.product_id.name, ol.product_id.id,))
else:
a = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category')
a = self.pool.get('account.fiscal.position').map_account(cr, uid, o.partner_id, a)
fpos = o.fiscal_position or False
a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, a)
il.append(self.inv_line_create(a,ol))
a = o.partner_id.property_account_payable.id
@ -445,7 +446,7 @@ class purchase_order_line(osv.osv):
return super(purchase_order_line, self).copy(cr, uid, id, default, context)
def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order=False):
partner_id, date_order=False, fiscal_position=False):
if not pricelist:
raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist in the purchase form !\nPlease set one before choosing a product.'))
if not product:
@ -488,7 +489,8 @@ class purchase_order_line(osv.osv):
partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
taxes = self.pool.get('account.tax').browse(cr, uid,map(lambda x: x.id, prod.supplier_taxes_id))
res['value']['taxes_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, taxes)
fpos = fiscal_position and self.pool.get('account.fiscal.position').browse(cr, uid, fiscal_position) or False
res['value']['taxes_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
res2 = self.pool.get('product.uom').read(cr, uid, [uom], ['category_id'])
res3 = prod.uom_id.category_id.id

View File

@ -172,7 +172,7 @@
<form string="Purchase Order Line">
<notebook>
<page string="Order Line">
<field colspan="4" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order)"/>
<field colspan="4" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order, parent.fiscal_position)"/>
<field name="product_qty"/>
<field name="product_uom" on_change="product_uom_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order)"/>
<field colspan="4" name="name"/>

View File

@ -785,7 +785,8 @@ class sale_order_line(osv.osv):
if uosqty:
pu = round(line.price_unit * line.product_uom_qty / uosqty,
int(config['price_accuracy']))
a = self.pool.get('account.fiscal.position').map_account(cr, uid, line.order_id.partner_id, a)
fpos = line.order_id.fiscal_position or False
a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, a)
inv_id = self.pool.get('account.invoice.line').create(cr, uid, {
'name': line.name,
'origin':line.order_id.name,
@ -849,7 +850,7 @@ class sale_order_line(osv.osv):
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, update_tax=True, date_order=False, packaging=False):
lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False):
warning={}
product_uom_obj = self.pool.get('product.uom')
partner_obj = self.pool.get('res.partner')
@ -905,11 +906,11 @@ class sale_order_line(osv.osv):
result .update({'type': product_obj.procure_method})
if product_obj.description_sale:
result['notes'] = product_obj.description_sale
fpos = fiscal_position and self.pool.get('account.fiscal.position').browse(cr, uid, fiscal_position) or False
if update_tax: #The quantity only have changed
result['delay'] = (product_obj.sale_delay or 0.0)
partner = partner_obj.browse(cr, uid, partner_id)
result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, product_obj.taxes_id)
result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, product_obj.taxes_id)
result['name'] = product_obj.partner_ref
domain = {}

View File

@ -118,19 +118,19 @@
<field colspan="4"
context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
name="product_id"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], True, parent.date_order, product_packaging)"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], True, parent.date_order, product_packaging, parent.fiscal_position)"
select="1"/>
<field
context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
name="product_uom_qty"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging)"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging, parent.fiscal_position)"
select="1"/>
<field name="product_uom"
on_change="product_uom_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order)"/>
<field
name="product_packaging"
context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging)"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging, parent.fiscal_position)"
domain="[('product_id','=',product_id)]"
groups="base.group_extended"/>
<separator colspan="4" string="Manual Description"/>