[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
|
@ -328,12 +328,12 @@ class purchase_order(osv.osv):
|
||||||
return {'value': {'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id}}
|
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
|
#Destination address is used when dropshipping
|
||||||
def onchange_dest_address_id(self, cr, uid, ids, address_id):
|
def onchange_dest_address_id(self, cr, uid, ids, address_id, context=None):
|
||||||
if not address_id:
|
if not address_id:
|
||||||
return {}
|
return {}
|
||||||
address = self.pool.get('res.partner')
|
address = self.pool.get('res.partner')
|
||||||
values = {}
|
values = {}
|
||||||
supplier = address.browse(cr, uid, address_id)
|
supplier = address.browse(cr, uid, address_id, context=context)
|
||||||
if supplier:
|
if supplier:
|
||||||
location_id = supplier.property_stock_customer.id
|
location_id = supplier.property_stock_customer.id
|
||||||
values.update({'location_id': location_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})
|
value.update({'related_location_id': picktype.default_location_dest_id and picktype.default_location_dest_id.id or False})
|
||||||
return {'value': value}
|
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')
|
partner = self.pool.get('res.partner')
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
return {'value': {
|
return {'value': {
|
||||||
'fiscal_position': False,
|
'fiscal_position': False,
|
||||||
'payment_term_id': False,
|
'payment_term_id': False,
|
||||||
}}
|
}}
|
||||||
supplier_address = partner.address_get(cr, uid, [partner_id], ['default'])
|
supplier_address = partner.address_get(cr, uid, [partner_id], ['default'], context=context)
|
||||||
supplier = partner.browse(cr, uid, partner_id)
|
supplier = partner.browse(cr, uid, partner_id, context=context)
|
||||||
return {'value': {
|
return {'value': {
|
||||||
'pricelist_id': supplier.property_product_pricelist_purchase.id,
|
'pricelist_id': supplier.property_product_pricelist_purchase.id,
|
||||||
'fiscal_position': supplier.property_account_position and supplier.property_account_position.id or False,
|
'fiscal_position': supplier.property_account_position and supplier.property_account_position.id or False,
|
||||||
|
|
|
@ -214,7 +214,7 @@
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<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 name="partner_ref"/>
|
||||||
<field domain="[('type','=','purchase')]" name="pricelist_id" groups="product.group_purchase_pricelist" on_change="onchange_pricelist(pricelist_id, context)"/>
|
<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"/>
|
<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="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="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="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)],
|
attrs="{'invisible':['|', ('picking_type_id','=',False), ('related_location_id','!=', False)],
|
||||||
'required': [('picking_type_id','!=',False), ('related_location_id','=', False)]}"
|
'required': [('picking_type_id','!=',False), ('related_location_id','=', False)]}"
|
||||||
groups="stock.group_locations"/>
|
groups="stock.group_locations"/>
|
||||||
|
|
|
@ -81,13 +81,13 @@ class sale_order(osv.osv):
|
||||||
|
|
||||||
class purchase_order(osv.osv):
|
class purchase_order(osv.osv):
|
||||||
_inherit = 'purchase.order'
|
_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:
|
if not part:
|
||||||
return {'value':{'partner_address_id': False}}
|
return {'value':{'partner_address_id': False}}
|
||||||
warning = {}
|
warning = {}
|
||||||
title = False
|
title = False
|
||||||
message = 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':
|
if partner.purchase_warn != 'no-message':
|
||||||
title = _("Warning for %s") % partner.name
|
title = _("Warning for %s") % partner.name
|
||||||
message = partner.purchase_warn_msg
|
message = partner.purchase_warn_msg
|
||||||
|
@ -98,7 +98,7 @@ class purchase_order(osv.osv):
|
||||||
if partner.purchase_warn == 'block':
|
if partner.purchase_warn == 'block':
|
||||||
return {'value': {'partner_id': False}, 'warning': warning}
|
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):
|
if result.get('warning',False):
|
||||||
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
|
||||||
|
|
Loading…
Reference in New Issue