Cut name_get() of invoice if too long (which screws-up the invoice form view because of the ariane thread at the top)
This commit is contained in:
@@ -43,7 +43,6 @@ class AccountInvoice(models.Model):
|
|||||||
compute='_compute_has_attachment',
|
compute='_compute_has_attachment',
|
||||||
search='_search_has_attachment', readonly=True)
|
search='_search_has_attachment', readonly=True)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_has_discount(self):
|
def _compute_has_discount(self):
|
||||||
prec = self.env['decimal.precision'].precision_get('Discount')
|
prec = self.env['decimal.precision'].precision_get('Discount')
|
||||||
for inv in self:
|
for inv in self:
|
||||||
@@ -78,6 +77,25 @@ class AccountInvoice(models.Model):
|
|||||||
res = [('id', value and 'in' or 'not in', att_inv_ids.keys())]
|
res = [('id', value and 'in' or 'not in', att_inv_ids.keys())]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# when you have an invoice created from a lot of sale orders, the 'name'
|
||||||
|
# field is very large, which makes the name_get() of that invoice very big
|
||||||
|
# which screws-up the form view of that invoice because of the link at the
|
||||||
|
# top of the screen
|
||||||
|
# That's why we have to cut the name_get() when it's too long
|
||||||
|
def name_get(self):
|
||||||
|
old_res = super(AccountInvoice, self).name_get()
|
||||||
|
res = []
|
||||||
|
for old_re in old_res:
|
||||||
|
name = old_re[1]
|
||||||
|
if name and len(name) > 100:
|
||||||
|
# nice cut
|
||||||
|
name = u'%s ...' % ', '.join(name.split(', ')[:3])
|
||||||
|
# if not enough, hard cut
|
||||||
|
if len(name) > 120:
|
||||||
|
name = u'%s ...' old_re[1][:120]
|
||||||
|
res.append((old_re[0], name))
|
||||||
|
return res
|
||||||
|
|
||||||
# I really hate to see a "/" in the 'name' field of the account.move.line
|
# I really hate to see a "/" in the 'name' field of the account.move.line
|
||||||
# generated from customer invoices linked to the partners' account because:
|
# generated from customer invoices linked to the partners' account because:
|
||||||
# 1) the label of an account move line is an important field, we can't
|
# 1) the label of an account move line is an important field, we can't
|
||||||
|
|||||||
Reference in New Issue
Block a user