GoodERP
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

41 lines
1.6KB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 上海开阖软件有限公司 (http://www.osbzr.com)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from odoo import _
  5. from odoo import api, fields, models
  6. from odoo.exceptions import ValidationError, UserError
  7. class GoodsClass(models.Model):
  8. _name = "goods.class"
  9. _inherit = ['mail.thread']
  10. _description = "商品分类"
  11. _order = "sequence, name"
  12. @api.constrains('parent_id')
  13. def _check_category_recursion(self):
  14. if not self._check_recursion():
  15. raise ValidationError(_('错误 ! 您不能创建循环分类'))
  16. name = fields.Char(required=True, string='名字')
  17. parent_id = fields.Many2one('goods.class', string='上级分类', index=True)
  18. child_id = fields.One2many('goods.class', 'parent_id', string='子分类')
  19. sequence = fields.Integer('顺序')
  20. type = fields.Selection(
  21. [('view', '节点'),
  22. ('normal', '常规')],
  23. '类型',
  24. required=True,
  25. default='normal',
  26. help='商品分类的类型,分为节点和常规,只有节点的分类才可以建下级商品分类,常规分类不可作为上级商品分类')
  27. note = fields.Text('备注')
  28. image = fields.Binary(attachment=True)
  29. image_medium = fields.Binary(string="Medium-sized image", attachment=True)
  30. image_small = fields.Binary(string="Small-sized image", attachment=True)
  31. tax_rate = fields.Float('税率(%)', help='商品分类上的税率')
  32. _sql_constraints = [
  33. ('name_uniq', 'unique(name)', '分类名称不能重复'),
  34. ]
上海开阖软件有限公司 沪ICP备12045867号-1