mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add product auto code
This commit is contained in:
@@ -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',
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import product_category
|
|
||||||
|
|||||||
@@ -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)
|
|
||||||
|
|
||||||
@@ -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>
|
|
||||||
Reference in New Issue
Block a user