account_usability: improve name of account.move.line generated from invoices for customer/supplier account

Don't always prefix name of account.move.line generated from invoices
with invoice number, only for that when name is '/'
This commit is contained in:
Alexis de Lattre
2021-03-08 15:18:24 +01:00
parent 4f4d3323d4
commit ff69a23e17

View File

@@ -98,20 +98,18 @@ class AccountInvoice(models.Model):
return res 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 # the label of an account move line is an important field, we can't
# write a rubbish '/' in it ! # write a rubbish '/' in it !
# 2) the 'name' field of the account.move.line is used in the overdue # On a related topic, you should also consider to use this PR:
# letter, and '/' is not meaningful for our customer ! # https://github.com/OCA/account-invoicing/pull/882
@api.multi @api.multi
def action_move_create(self): def action_move_create(self):
res = super(AccountInvoice, self).action_move_create() res = super(AccountInvoice, self).action_move_create()
for inv in self: for inv in self:
self._cr.execute( self._cr.execute(
"UPDATE account_move_line SET name= " "UPDATE account_move_line SET name=%s "
"CASE WHEN name='/' THEN %s " "WHERE move_id=%s AND name='/'", (inv.number, inv.move_id.id))
"ELSE %s||' - '||name END "
"WHERE move_id=%s", (inv.number, inv.number, inv.move_id.id))
self.invalidate_cache() self.invalidate_cache()
return res return res