中国本土应用
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

44 rindas
1.6KB

  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, fields, models, _
  4. from odoo.exceptions import ValidationError
  5. from odoo.osv import expression
  6. try:
  7. from cn2an import an2cn
  8. except ImportError:
  9. an2cn = None
  10. class AccountMove(models.Model):
  11. _inherit = 'account.move'
  12. fapiao = fields.Char(string='Fapiao Number', size=8, copy=False, tracking=True)
  13. @api.constrains('fapiao')
  14. def _check_fapiao(self):
  15. for record in self:
  16. if record.fapiao and (len(record.fapiao) != 8 or not record.fapiao.isdecimal()):
  17. raise ValidationError(_("Fapiao number is an 8-digit number. Please enter a correct one."))
  18. @api.model
  19. def check_cn2an(self):
  20. return an2cn
  21. @api.model
  22. def _convert_to_amount_in_word(self, number):
  23. """Convert number to ``amount in words`` for Chinese financial usage."""
  24. if not self.check_cn2an():
  25. return None
  26. return an2cn(number, 'rmb')
  27. def _count_attachments(self):
  28. domains = [[('res_model', '=', 'account.move'), ('res_id', '=', self.id)]]
  29. statement_ids = self.line_ids.mapped('statement_id')
  30. payment_ids = self.line_ids.mapped('payment_id')
  31. if statement_ids:
  32. domains.append([('res_model', '=', 'account.bank.statement'), ('res_id', 'in', statement_ids)])
  33. if payment_ids:
  34. domains.append([('res_model', '=', 'account.payment'), ('res_id', 'in', payment_ids)])
  35. return self.env['ir.attachment'].search_count(expression.OR(domains))
上海开阖软件有限公司 沪ICP备12045867号-1