[IMP] purchase: add context in PO onchange_partner_id and onchange_dest_address_id
(Manual rebase of PR #913)
This commit is contained in:
parent
e7665864be
commit
7cc95f1671
|
@ -327,13 +327,13 @@ class purchase_order(osv.osv):
|
|||
return {}
|
||||
return {'value': {'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id}}
|
||||
|
||||
#Destination address is used when dropshipping
|
||||
def onchange_dest_address_id(self, cr, uid, ids, address_id):
|
||||
#Destination address is used when dropshipping
|
||||
def onchange_dest_address_id(self, cr, uid, ids, address_id, context=None):
|
||||
if not address_id:
|
||||
return {}
|
||||
address = self.pool.get('res.partner')
|
||||
values = {}
|
||||
supplier = address.browse(cr, uid, address_id)
|
||||
supplier = address.browse(cr, uid, address_id, context=context)
|
||||
if supplier:
|
||||
location_id = supplier.property_stock_customer.id
|
||||
values.update({'location_id': location_id})
|
||||
|
@ -348,15 +348,15 @@ class purchase_order(osv.osv):
|
|||
value.update({'related_location_id': picktype.default_location_dest_id and picktype.default_location_dest_id.id or False})
|
||||
return {'value': value}
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id):
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
|
||||
partner = self.pool.get('res.partner')
|
||||
if not partner_id:
|
||||
return {'value': {
|
||||
'fiscal_position': False,
|
||||
'payment_term_id': False,
|
||||
}}
|
||||
supplier_address = partner.address_get(cr, uid, [partner_id], ['default'])
|
||||
supplier = partner.browse(cr, uid, partner_id)
|
||||
supplier_address = partner.address_get(cr, uid, [partner_id], ['default'], context=context)
|
||||
supplier = partner.browse(cr, uid, partner_id, context=context)
|
||||
return {'value': {
|
||||
'pricelist_id': supplier.property_product_pricelist_purchase.id,
|
||||
'fiscal_position': supplier.property_account_position and supplier.property_account_position.id or False,
|
||||
|
|
|
@ -214,7 +214,7 @@
|
|||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)" context="{'search_default_supplier':1, 'default_supplier':1, 'default_customer':0}" domain="[('supplier','=',True)]"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" context="{'search_default_supplier':1, 'default_supplier':1, 'default_customer':0}" domain="[('supplier','=',True)]"/>
|
||||
<field name="partner_ref"/>
|
||||
<field domain="[('type','=','purchase')]" name="pricelist_id" groups="product.group_purchase_pricelist" on_change="onchange_pricelist(pricelist_id, context)"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
|
@ -226,7 +226,7 @@
|
|||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
<field name="picking_type_id" on_change="onchange_picking_type_id(picking_type_id, context)" domain="[('code','=','incoming')]" widget="selection" context="{'special_shortened_wh_name': True}" groups="stock.group_locations"/>
|
||||
<field name="related_location_id" invisible="1"/>
|
||||
<field name="dest_address_id" string="Customer Address" on_change="onchange_dest_address_id(dest_address_id)"
|
||||
<field name="dest_address_id" string="Customer Address" on_change="onchange_dest_address_id(dest_address_id, context)"
|
||||
attrs="{'invisible':['|', ('picking_type_id','=',False), ('related_location_id','!=', False)],
|
||||
'required': [('picking_type_id','!=',False), ('related_location_id','=', False)]}"
|
||||
groups="stock.group_locations"/>
|
||||
|
|
|
@ -81,13 +81,13 @@ class sale_order(osv.osv):
|
|||
|
||||
class purchase_order(osv.osv):
|
||||
_inherit = 'purchase.order'
|
||||
def onchange_partner_id(self, cr, uid, ids, part):
|
||||
def onchange_partner_id(self, cr, uid, ids, part, context=None):
|
||||
if not part:
|
||||
return {'value':{'partner_address_id': False}}
|
||||
warning = {}
|
||||
title = False
|
||||
message = False
|
||||
partner = self.pool.get('res.partner').browse(cr, uid, part)
|
||||
partner = self.pool.get('res.partner').browse(cr, uid, part, context=context)
|
||||
if partner.purchase_warn != 'no-message':
|
||||
title = _("Warning for %s") % partner.name
|
||||
message = partner.purchase_warn_msg
|
||||
|
@ -98,7 +98,7 @@ class purchase_order(osv.osv):
|
|||
if partner.purchase_warn == 'block':
|
||||
return {'value': {'partner_id': False}, 'warning': warning}
|
||||
|
||||
result = super(purchase_order, self).onchange_partner_id(cr, uid, ids, part)
|
||||
result = super(purchase_order, self).onchange_partner_id(cr, uid, ids, part, context=context)
|
||||
|
||||
if result.get('warning',False):
|
||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||
|
|
Loading…
Reference in New Issue