diff --git a/app_product_sequence/controllers/product_sequence.xml b/app_product_sequence/controllers/product_sequence.xml new file mode 100644 index 00000000..7955665e --- /dev/null +++ b/app_product_sequence/controllers/product_sequence.xml @@ -0,0 +1,69 @@ + + + + + + + Sequence for All Products + product.product + P%(y)s%(month)s + 5 + + True + + + + Sequence for Manufactured Product + product.product + D%(y)s%(month)s + 5 + + True + + + + Sequence for Components Product + product.product + C%(y)s%(month)s + 5 + + True + + + + Sequence for Sourced Product + product.product + S%(y)s%(month)s + 5 + + True + + + + + Manufactured Product + Set prefix as "D" in link sequence + + + + Sourced Product + Set prefix as "S" in link sequence + + + + Components Product + Set prefix as "C" in link sequence + + + + + + internal_type + product.template + default + + + + + + diff --git a/app_product_type_sequence/__openerp__.py b/app_product_type_sequence/__openerp__.py index b6abe991..738e996f 100644 --- a/app_product_type_sequence/__openerp__.py +++ b/app_product_type_sequence/__openerp__.py @@ -15,7 +15,7 @@ # http://www.sunpop.cn/odoo10_developer_document_offline/ # description: { - 'name': 'App Product Internal Type,Auto Sequence, Auto Code(Variants Supported)', + 'name': 'App Product Internal Type,Auto Sequence, Auto Code(Variants Supported), Auto Attributes', 'summary': 'Auto Internal Reference.', "version": '10.0.2.2', 'category': 'Sales', @@ -30,7 +30,7 @@ 'currency': 'EUR', 'price': 98, 'description': u""" - App Product Auto Sequence, Auto Code(Variants Supported) + App Product Auto Sequence, Auto Code(Variants Supported), Auto Attributes This module allows to associate a sequence to the product reference.
The reference (default code) is unique (SQL constraint) and required.
@@ -41,7 +41,8 @@ 4.Define different product type, each product type use own rule of sequence.可自定义产品类型,不同产品类型使用不同编码规则。 5.Quick access in sale , inventory, system menu.可以在销售、库存、系统菜单中快速定义。 6.Multi language support.
多语种支持。 - 7.Setup default Auto Sequence for each product category + 7.Setup default Auto Sequence for each product category,自动设置每个产品目录使用的产品编码规则 + 8.Auto setup product attribute lik Sale/Purchase, Stockable/Consumable/Service, Stock Routes. 自动设置产品的销售/采购,可库存产品/服务/消耗品,购买/制造/按订单生成等库存路线 """, 'pre_init_hook': 'pre_init_hook', 'depends': [ diff --git a/app_product_type_sequence/hooks.py b/app_product_type_sequence/hooks.py index a4d9d2f1..4a0ea85d 100644 --- a/app_product_type_sequence/hooks.py +++ b/app_product_type_sequence/hooks.py @@ -24,7 +24,7 @@ def pre_init_hook(cr): :return: void """ cr.execute("UPDATE product_product " - "SET default_code = '!!DP!!' || id " + "SET default_code = '!!PR!!' || id " "WHERE default_code IS NULL OR default_code = 'New';") cr.execute("UPDATE product_template " diff --git a/app_product_type_sequence/models/product_product.py b/app_product_type_sequence/models/product_product.py index 43aec35b..23f820c4 100644 --- a/app_product_type_sequence/models/product_product.py +++ b/app_product_type_sequence/models/product_product.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Created on 2017-11-05 +# Created on 2017-01-09 # author: 广州尚鹏,http://www.sunpop.cn # email: 300883@qq.com # resource of Sunpop @@ -24,7 +24,6 @@ class ProductProduct(models.Model): default_code_index = fields.Integer('Internal Reference Index', readonly=True) # todo: 检查数据,要保证数据唯一性 - # 为免报错,不限制唯一性 _sql_constraints = [ ('uniq_default_code', 'unique(default_code)', @@ -63,7 +62,7 @@ class ProductProduct(models.Model): # 有属性值了,自己是第一个规格 code_index = 1 vals['default_code_index'] = code_index - vals['default_code'] = code_stored + '-%03d'%(code_index) + vals['default_code'] = code_stored + '#%03d'%(code_index) elif mylen == 1: # 已存在1个,当存在的1个有属性时,要改已存在的product值 code_index = template.product_variant_ids[:1].default_code_index @@ -71,24 +70,24 @@ class ProductProduct(models.Model): if code_index == 0: code_index = 1 template.product_variant_ids[:1].default_code_index = code_index - template.product_variant_ids[:1].default_code = code_stored + '-%03d'%(code_index) + template.product_variant_ids[:1].default_code = code_stored + '#%03d'%(code_index) # 接着改当前操作的product值 code_index = code_index + 1 vals['default_code_index'] = code_index - vals['default_code'] = code_stored + '-%03d'%(code_index) + vals['default_code'] = code_stored + '#%03d'%(code_index) elif mylen > 1: # 找到最大的序号 variant_max = max(template.product_variant_ids,key=lambda x: x['default_code_index']) code_index = variant_max['default_code_index'] + 1 vals['default_code_index'] = code_index - vals['default_code'] = code_stored + '-%03d'%(code_index) + vals['default_code'] = code_stored + '#%03d'%(code_index) else: # 当按模板 # 此条件常规不出现,但特殊项目会有 variant_max = max(template.product_variant_ids,key=lambda x: x['default_code_index']) code_index = variant_max['default_code_index'] + 1 vals['default_code_index'] = code_index - vals['default_code'] = code_stored + '-%03d'%(code_index) + vals['default_code'] = code_stored + '#%03d'%(code_index) else: # create from product_product # 默认使用制造成品的编码 diff --git a/app_product_type_sequence/static/description/index.html b/app_product_type_sequence/static/description/index.html index 4ac12cc4..ecb4de17 100644 --- a/app_product_type_sequence/static/description/index.html +++ b/app_product_type_sequence/static/description/index.html @@ -1,6 +1,6 @@
-

App Product Auto Sequence, Auto Code(Variants Supported)

+

App Product Auto Sequence, Auto Code(Variants Supported), Auto Attributes

This module allows to associate a sequence to the product reference.
@@ -26,7 +26,16 @@

  • Multi language support.
  • +
  • + Setup default Auto Sequence for each product category. +
  • +
  • + Auto setup product attribute lik Sale/Purchase, Stockable/Consumable/Service, Stock Routes. +
  • +
    + +
    @@ -49,13 +58,13 @@ Sepcial for variants. add [-00?]
    • - Products with color[red]: M20171100001-001 + Products with color[red]: M20171100001#001
    • - Products with color[blue]: M20171100001-002 + Products with color[blue]: M20171100001#002
    • - Products with color[white]: M20171100001-003 + Products with color[white]: M20171100001#003

    diff --git a/app_product_type_sequence/static/description/set0.jpg b/app_product_type_sequence/static/description/set0.jpg new file mode 100644 index 00000000..7cf34652 Binary files /dev/null and b/app_product_type_sequence/static/description/set0.jpg differ