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.

39 lines
1.5KB

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