[FIX] sale, account: fixed the invoicing flow for the following use case 'i make a SO for "joel@c2c", at the confirmation the invoice is sent to "accounting department@c2c" and finally the journal items created are for "c2c"'
bzr revid: qdp-launchpad@openerp.com-20121126092658-g981dg91gcjp1tvl
This commit is contained in:
parent
4980a1b0fc
commit
02f55a72f7
|
@ -958,9 +958,14 @@ class account_invoice(osv.osv):
|
|||
})
|
||||
|
||||
date = inv.date_invoice or time.strftime('%Y-%m-%d')
|
||||
part = inv.partner_id.id
|
||||
|
||||
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context=ctx)),iml)
|
||||
#if the chosen partner is not a company and has a parent company, use the parent for the journal entries
|
||||
#because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait'
|
||||
part = inv.partner_id
|
||||
if part.parent_id and not part.is_company:
|
||||
part = part.parent_id
|
||||
|
||||
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part.id, date, context=ctx)),iml)
|
||||
|
||||
line = self.group_lines(cr, uid, iml, line, inv)
|
||||
|
||||
|
|
|
@ -295,12 +295,16 @@ class sale_order(osv.osv):
|
|||
}
|
||||
return {'warning': warning, 'value': value}
|
||||
|
||||
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_invoice_id': False, 'partner_shipping_id': False, 'payment_term': False, 'fiscal_position': False}}
|
||||
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery', 'invoice', 'contact'])
|
||||
part = self.pool.get('res.partner').browse(cr, uid, part)
|
||||
part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
|
||||
#if the chosen partner is not a company and has a parent company, use the parent to choose the delivery, the
|
||||
#invoicing addresses and all the fields related to the partner.
|
||||
if part.parent_id and not part.is_company:
|
||||
part = part.parent_id
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
|
||||
pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
|
||||
payment_term = part.property_payment_term and part.property_payment_term.id or False
|
||||
fiscal_position = part.property_account_position and part.property_account_position.id or False
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
</h1>
|
||||
<group>
|
||||
<group>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
|
||||
<field name="partner_invoice_id" groups="sale.group_delivery_invoice_address" context="{'default_type':'invoice'}"/>
|
||||
<field name="partner_shipping_id" groups="sale.group_delivery_invoice_address" context="{'default_type':'delivery'}"/>
|
||||
<field name="project_id" context="{'partner_id':partner_id, 'pricelist_id':pricelist_id, 'default_name':name}" groups="sale.group_analytic_accounting" domain="[('type','in',['view','normal','contract'])]"/>
|
||||
|
|
Loading…
Reference in New Issue