fix account

This commit is contained in:
ivan deng
2018-11-15 20:20:23 +08:00
parent 429e2c1475
commit 0626f8a102
14 changed files with 242 additions and 35 deletions

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from odoo.exceptions import UserError, ValidationError
from odoo import api, fields, models, _
class AccountAccount(models.Model):
_inherit = "account.account"
@api.model
def _search_new_account_code(self, company, digits, prefix):
for num in range(1, 100):
new_code = str(prefix.ljust(digits - 1, '0')) + str(num)
rec = self.search([('code', '=', new_code), ('company_id', '=', company.id)], limit=1)
if not rec:
return new_code
raise UserError(_('Cannot generate an unused account code.'))