add sequence to support category

This commit is contained in:
ivan deng
2017-11-28 22:00:43 +08:00
parent 341ba2d82d
commit 4c3faf59a6
6 changed files with 63 additions and 1 deletions

View File

@@ -41,6 +41,7 @@
4.Define different product type, each product type use own rule of sequence.可自定义产品类型,不同产品类型使用不同编码规则。 4.Define different product type, each product type use own rule of sequence.可自定义产品类型,不同产品类型使用不同编码规则。
5.Quick access in sale , inventory, system menu.可以在销售、库存、系统菜单中快速定义。 5.Quick access in sale , inventory, system menu.可以在销售、库存、系统菜单中快速定义。
6.Multi language support.<br/>多语种支持。 6.Multi language support.<br/>多语种支持。
7.Setup default Auto Sequence for each product category
""", """,
'pre_init_hook': 'pre_init_hook', 'pre_init_hook': 'pre_init_hook',
'depends': [ 'depends': [
@@ -54,6 +55,7 @@
# "security/security.xml", # "security/security.xml",
'views/product_template_view.xml', 'views/product_template_view.xml',
'views/product_product_view.xml', 'views/product_product_view.xml',
'views/product_category_view.xml',
'views/product_internal_type_view.xml', 'views/product_internal_type_view.xml',
'data/product_sequence.xml', 'data/product_sequence.xml',
], ],

View File

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import product_template import product_template
import product_product import product_product
import product_category
import product_internal_type import product_internal_type

View File

@@ -0,0 +1,27 @@
# -*- 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 openerp import api, fields, models, exceptions, _
class ProductCategory(models.Model):
_name = "product.category"
_inherit = ['product.category']
internal_type = fields.Many2one(
'product.internal.type', 'Default Internal Type',
auto_join=True, required=False)

View File

@@ -58,3 +58,7 @@ class ProductTemplate(models.Model):
if len(self.product_variant_ids) == 1: if len(self.product_variant_ids) == 1:
self.product_variant_ids.default_code = self.default_code_stored self.product_variant_ids.default_code = self.default_code_stored
@api.onchange('categ_id')
def _onchange_cate_id(self):
if self.categ_id and self.categ_id.internal_type:
self.internal_type = self.categ_id.internal_type

View File

@@ -0,0 +1,28 @@
<?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="after">
<field name="internal_type"/>
<field name="name"/>
</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='type']" position="after">
<field name="internal_type"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@@ -18,7 +18,7 @@
<field name="model">product.template</field> <field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/> <field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='type']" position="before"> <xpath expr="//field[@name='categ_id']" position="after">
<field name="internal_type"/> <field name="internal_type"/>
</xpath> </xpath>
</field> </field>