[IMP] sale: force the company when creating an invoice from the SO, using context['force_company']
bzr revid: qdp-launchpad@openerp.com-20110707155920-25i3yzptikuadzj8
This commit is contained in:
parent
b4d3c937ad
commit
9f01872204
|
@ -25,6 +25,7 @@ import time
|
|||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import tools
|
||||
import decimal_precision as dp
|
||||
import netsvc
|
||||
|
||||
|
@ -474,14 +475,19 @@ class sale_order(osv.osv):
|
|||
# last day of the last month as invoice date
|
||||
if date_inv:
|
||||
context['date_inv'] = date_inv
|
||||
for o in self.browse(cr, uid, ids, context=context):
|
||||
set_company = tools.get_and_sort_by_field(cr, uid, obj=self, ids=ids, field='company_id', context=context)
|
||||
for company_id, so_ids in set_company.items():
|
||||
ctx = context.copy()
|
||||
ctx.update({'force_company': company_id})
|
||||
print "Boom invoice", company_id, so_ids
|
||||
for o in self.browse(cr, uid, ids, context=ctx):
|
||||
lines = []
|
||||
for line in o.order_line:
|
||||
if line.invoiced:
|
||||
continue
|
||||
elif (line.state in states):
|
||||
lines.append(line.id)
|
||||
created_lines = obj_sale_order_line.invoice_line_create(cr, uid, lines)
|
||||
created_lines = obj_sale_order_line.invoice_line_create(cr, uid, lines, context=context)
|
||||
if created_lines:
|
||||
invoices.setdefault(o.partner_id.id, []).append((o, created_lines))
|
||||
if not invoices:
|
||||
|
@ -914,7 +920,12 @@ class sale_order_line(osv.osv):
|
|||
|
||||
create_ids = []
|
||||
sales = {}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
set_company = tools.get_and_sort_by_field(cr, uid, obj=self, ids=ids, field='company_id', context=context)
|
||||
for company_id, sol_ids in set_company.items():
|
||||
ctx = context.copy()
|
||||
ctx.update({'force_company': company_id})
|
||||
print "Boom line", company_id, sol_ids
|
||||
for line in self.browse(cr, uid, sol_ids, context=ctx):
|
||||
if not line.invoiced:
|
||||
if line.product_id:
|
||||
a = line.product_id.product_tmpl_id.property_account_income.id
|
||||
|
|
Loading…
Reference in New Issue