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

@@ -41,7 +41,6 @@
], ],
'images': [], 'images': [],
'data': [ 'data': [
'views/product_category_views.xml',
'data/ir_value_data.xml', 'data/ir_value_data.xml',
'data/ir_sequence_data.xml', 'data/ir_sequence_data.xml',
'data/base_data.xml', 'data/base_data.xml',

View File

@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*- # -*- 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)

View File

@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--目录list-->
<record id="product_category_list_view_internal_type" model="ir.ui.view">
<field name="name">product.category.list.internal_type</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_list_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='display_name']" position="before">
<field name="sequence" widget="handle"/>
<field name="id"/>
</xpath>
<xpath expr="//field[@name='display_name']" position="after">
<field name="ref"/>
<field name="total_route_ids"/>
</xpath>
</field>
</record>
<!--目录Form-->
<record id="product_category_form_view_internal_type" model="ir.ui.view">
<field name="name">product.category.form.internal_type</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='parent_id']" position="after">
<field name="ref"/>
<field name="sequence"/>
</xpath>
</field>
</record>
<!--搜索Form-->
<record id="product_category_search_view_internal_type" model="ir.ui.view">
<field name="name">product.category.search.internal_type</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_search_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="ref"/>
</xpath>
</field>
</record>
</data>
</openerp>