add product auto code

This commit is contained in:
ivan deng
2018-11-01 01:22:30 +08:00
parent 8b49c3d368
commit 4762d4b0ef
4 changed files with 0 additions and 88 deletions

View File

@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
from . import product_category

View File

@@ -1,42 +0,0 @@
# -*- coding: utf-8 -*-
# Created on 2017-11-28
# author: 广州尚鹏http://www.sunpop.cn
# email: 300883@qq.com
# resource of Sunpop
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Odoo在线中文用户手册长期更新
# http://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# http://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# http://www.sunpop.cn/odoo10_developer_document_offline/
# description:
from odoo import api, fields, models, exceptions, _
class ProductCategory(models.Model):
_inherit = 'product.category'
_order = 'sequence, ref'
ref = fields.Char(u'唯一编码', index=True)
sequence = fields.Integer(u'排序', help="Determine the display order")
# 增加目录编号唯一检查
# _sql_constraints = [
# ('uniq_ref',
# 'unique(ref)',
# 'The reference must be unique'),
# ]
# 产品目录序号器,正常全部手工录入
@api.model
def create(self, vals):
if not vals.get('ref'):
vals['ref'] = self.env['ir.sequence'].next_by_code('product.category.seq.normal')
if vals.get('ref'):
vals['ref'] = vals['ref'].upper()
return super(ProductCategory, self).create(vals)