[FIX] sale, sale_crm: propagate sales team for advance & on lines invoices
A _prepare method had to be introduced in the wizard for the lines invoicing method
This commit is contained in:
parent
dbb2a669f4
commit
1a10a11018
|
@ -26,6 +26,30 @@ from openerp import netsvc
|
|||
class sale_order_line_make_invoice(osv.osv_memory):
|
||||
_name = "sale.order.line.make.invoice"
|
||||
_description = "Sale OrderLine Make_invoice"
|
||||
|
||||
def _prepare_invoice(self, cr, uid, order, lines, context=None):
|
||||
a = order.partner_id.property_account_receivable.id
|
||||
if order.partner_id and order.partner_id.property_payment_term.id:
|
||||
pay_term = order.partner_id.property_payment_term.id
|
||||
else:
|
||||
pay_term = False
|
||||
return {
|
||||
'name': order.client_order_ref or '',
|
||||
'origin': order.name,
|
||||
'type': 'out_invoice',
|
||||
'reference': "P%dSO%d" % (order.partner_id.id, order.id),
|
||||
'account_id': a,
|
||||
'partner_id': order.partner_invoice_id.id,
|
||||
'invoice_line': [(6, 0, lines)],
|
||||
'currency_id' : order.pricelist_id.currency_id.id,
|
||||
'comment': order.note,
|
||||
'payment_term': pay_term,
|
||||
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
|
||||
'user_id': order.user_id and order.user_id.id or False,
|
||||
'company_id': order.company_id and order.company_id.id or False,
|
||||
'date_invoice': fields.date.today(),
|
||||
}
|
||||
|
||||
|
||||
def make_invoices(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
|
@ -55,27 +79,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
|
|||
@return:
|
||||
|
||||
"""
|
||||
a = order.partner_id.property_account_receivable.id
|
||||
if order.partner_id and order.partner_id.property_payment_term.id:
|
||||
pay_term = order.partner_id.property_payment_term.id
|
||||
else:
|
||||
pay_term = False
|
||||
inv = {
|
||||
'name': order.client_order_ref or '',
|
||||
'origin': order.name,
|
||||
'type': 'out_invoice',
|
||||
'reference': "P%dSO%d" % (order.partner_id.id, order.id),
|
||||
'account_id': a,
|
||||
'partner_id': order.partner_invoice_id.id,
|
||||
'invoice_line': [(6, 0, lines)],
|
||||
'currency_id' : order.pricelist_id.currency_id.id,
|
||||
'comment': order.note,
|
||||
'payment_term': pay_term,
|
||||
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
|
||||
'user_id': order.user_id and order.user_id.id or False,
|
||||
'company_id': order.company_id and order.company_id.id or False,
|
||||
'date_invoice': fields.date.today(),
|
||||
}
|
||||
inv = self._prepare_invoice(cr, uid, order, lines)
|
||||
inv_id = self.pool.get('account.invoice').create(cr, uid, inv)
|
||||
return inv_id
|
||||
|
||||
|
|
|
@ -60,6 +60,28 @@ class sale_order(osv.osv):
|
|||
return invoice_vals
|
||||
|
||||
|
||||
class sale_advance_payment_inv(osv.osv_memory):
|
||||
_inherit = 'sale.advance.payment.inv'
|
||||
|
||||
def _prepare_advance_invoice_vals(self, cr, uid, ids, context=None):
|
||||
result = super(sale_advance_payment_inv, self)._prepare_advance_invoice_vals(cr, uid, ids, context=context)
|
||||
orders = dict((order.id, order) for order in self.pool['sale.order'].browse(cr, uid, [order_id for order_id, values in result], context=context))
|
||||
for order_id, values in result:
|
||||
if orders.get(order_id) and orders[order_id].section_id:
|
||||
values['section_id'] = orders[order_id].section_id.id
|
||||
return result
|
||||
|
||||
|
||||
class sale_order_line_make_invoice(osv.osv_memory):
|
||||
_inherit = "sale.order.line.make.invoice"
|
||||
|
||||
def _prepare_invoice(self, cr, uid, order, lines, context=None):
|
||||
result = super(sale_order_line_make_invoice, self)._prepare_invoice(cr, uid, order, lines, context=None)
|
||||
if order.section_id:
|
||||
result['section_id'] = order.section_id.id
|
||||
return result
|
||||
|
||||
|
||||
class sale_crm_lead(osv.Model):
|
||||
_inherit = 'crm.lead'
|
||||
|
||||
|
|
Loading…
Reference in New Issue