[FIX] hr_timesheet_invoice: invoice timesheet of contract with no customer
If there is no partner on the contract to which are invoiced the timesheets, the error telling you to set a partner (and a pricelist) must be raised before trying to create the invoice, not before creating the lines of the invoice. In this case, this is because if you set no customer on the contract, there is no pricelist automatically filled as well, and the currency is took from the pricelist, which will be False in the case there is no pricelist on the contract, and you cannot create an invoice with no currency set. opw-647672
This commit is contained in:
parent
5fe858d7aa
commit
37a2f426a9
|
@ -273,7 +273,10 @@ class account_analytic_line(osv.osv):
|
||||||
|
|
||||||
for (key_id, company_id, currency_id), analytic_lines in invoice_grouping.items():
|
for (key_id, company_id, currency_id), analytic_lines in invoice_grouping.items():
|
||||||
# key_id is an account.analytic.account
|
# key_id is an account.analytic.account
|
||||||
partner = analytic_lines[0].account_id.partner_id # will be the same for every line
|
account = analytic_lines[0].account_id
|
||||||
|
partner = account.partner_id # will be the same for every line
|
||||||
|
if (not partner) or not (currency_id):
|
||||||
|
raise osv.except_osv(_('Error!'), _('Contract incomplete. Please fill in the Customer and Pricelist fields for %s.') % (account.name))
|
||||||
|
|
||||||
curr_invoice = self._prepare_cost_invoice(cr, uid, partner, company_id, currency_id, analytic_lines, context=context)
|
curr_invoice = self._prepare_cost_invoice(cr, uid, partner, company_id, currency_id, analytic_lines, context=context)
|
||||||
invoice_context = dict(context,
|
invoice_context = dict(context,
|
||||||
|
@ -288,8 +291,6 @@ class account_analytic_line(osv.osv):
|
||||||
invoice_lines_grouping = {}
|
invoice_lines_grouping = {}
|
||||||
for analytic_line in analytic_lines:
|
for analytic_line in analytic_lines:
|
||||||
account = analytic_line.account_id
|
account = analytic_line.account_id
|
||||||
if (not partner) or not (account.pricelist_id):
|
|
||||||
raise osv.except_osv(_('Error!'), _('Contract incomplete. Please fill in the Customer and Pricelist fields for %s.') % (account.name))
|
|
||||||
|
|
||||||
if not analytic_line.to_invoice:
|
if not analytic_line.to_invoice:
|
||||||
raise osv.except_osv(_('Error!'), _('Trying to invoice non invoiceable line for %s.') % (analytic_line.product_id.name))
|
raise osv.except_osv(_('Error!'), _('Trying to invoice non invoiceable line for %s.') % (analytic_line.product_id.name))
|
||||||
|
|
Loading…
Reference in New Issue