mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update app_seq
This commit is contained in:
69
app_product_sequence/controllers/product_sequence.xml
Normal file
69
app_product_sequence/controllers/product_sequence.xml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="0">
|
||||||
|
<!-- 更新序号规则 Auto Internal Reference. -->
|
||||||
|
<!-- 所有的 All Products. -->
|
||||||
|
<record id="seq_product_auto" model="ir.sequence">
|
||||||
|
<field name="name">Sequence for All Products</field>
|
||||||
|
<field name="code">product.product</field>
|
||||||
|
<field name="prefix">P%(y)s%(month)s</field>
|
||||||
|
<field name="padding">5</field>
|
||||||
|
<field name="company_id" eval="False"/>
|
||||||
|
<field name="initial">True</field>
|
||||||
|
</record>
|
||||||
|
<!-- 制造的成品 manufactured Products. -->
|
||||||
|
<record id="seq_manufacture" model="ir.sequence">
|
||||||
|
<field name="name">Sequence for Manufactured Product</field>
|
||||||
|
<field name="code">product.product</field>
|
||||||
|
<field name="prefix">D%(y)s%(month)s</field>
|
||||||
|
<field name="padding">5</field>
|
||||||
|
<field name="company_id" eval="False"/>
|
||||||
|
<field name="initial">True</field>
|
||||||
|
</record>
|
||||||
|
<!-- 制造的原料 Components.-->
|
||||||
|
<record id="seq_component" model="ir.sequence">
|
||||||
|
<field name="name">Sequence for Components Product</field>
|
||||||
|
<field name="code">product.product</field>
|
||||||
|
<field name="prefix">C%(y)s%(month)s</field>
|
||||||
|
<field name="padding">5</field>
|
||||||
|
<field name="company_id" eval="False"/>
|
||||||
|
<field name="initial">True</field>
|
||||||
|
</record>
|
||||||
|
<!-- 采购的成品 Sourced Products.-->
|
||||||
|
<record id="seq_sourced" model="ir.sequence">
|
||||||
|
<field name="name">Sequence for Sourced Product</field>
|
||||||
|
<field name="code">product.product</field>
|
||||||
|
<field name="prefix">S%(y)s%(month)s</field>
|
||||||
|
<field name="padding">5</field>
|
||||||
|
<field name="company_id" eval="False"/>
|
||||||
|
<field name="initial">True</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- internal_type 数据-->
|
||||||
|
<record id="internal_type_manufacture" model="product.internal.type">
|
||||||
|
<field name="name">Manufactured Product</field>
|
||||||
|
<field name="description">Set prefix as "D" in link sequence</field>
|
||||||
|
<field name="link_sequence" ref="seq_manufacture"/>
|
||||||
|
</record>
|
||||||
|
<record id="internal_type_sourced" model="product.internal.type">
|
||||||
|
<field name="name">Sourced Product</field>
|
||||||
|
<field name="description">Set prefix as "S" in link sequence</field>
|
||||||
|
<field name="link_sequence" ref="seq_sourced"/>
|
||||||
|
</record>
|
||||||
|
<record id="internal_type_component" model="product.internal.type">
|
||||||
|
<field name="name">Components Product</field>
|
||||||
|
<field name="description">Set prefix as "C" in link sequence</field>
|
||||||
|
<field name="link_sequence" ref="seq_component"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!--设置产品默认值为制造产品-->
|
||||||
|
<record id="product_internal_type_default" model="ir.values">
|
||||||
|
<field name="name">internal_type</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="key">default</field>
|
||||||
|
<field name="key2"></field>
|
||||||
|
<field name="company_id" ref="base.main_company"/>
|
||||||
|
<field name="value" eval="'I' + str(ref('app_product_sequence.internal_type_manufacture'))+'\n.'"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
# http://www.sunpop.cn/odoo10_developer_document_offline/
|
# http://www.sunpop.cn/odoo10_developer_document_offline/
|
||||||
# description:
|
# 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.',
|
'summary': 'Auto Internal Reference.',
|
||||||
"version": '10.0.2.2',
|
"version": '10.0.2.2',
|
||||||
'category': 'Sales',
|
'category': 'Sales',
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
'currency': 'EUR',
|
'currency': 'EUR',
|
||||||
'price': 98,
|
'price': 98,
|
||||||
'description': u"""
|
'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.<br/>
|
This module allows to associate a sequence to the product reference.<br/>
|
||||||
The reference (default code) is unique (SQL constraint) and required.<br/>
|
The reference (default code) is unique (SQL constraint) and required.<br/>
|
||||||
@@ -41,7 +41,8 @@
|
|||||||
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
|
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',
|
'pre_init_hook': 'pre_init_hook',
|
||||||
'depends': [
|
'depends': [
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ def pre_init_hook(cr):
|
|||||||
:return: void
|
:return: void
|
||||||
"""
|
"""
|
||||||
cr.execute("UPDATE product_product "
|
cr.execute("UPDATE product_product "
|
||||||
"SET default_code = '!!DP!!' || id "
|
"SET default_code = '!!PR!!' || id "
|
||||||
"WHERE default_code IS NULL OR default_code = 'New';")
|
"WHERE default_code IS NULL OR default_code = 'New';")
|
||||||
|
|
||||||
cr.execute("UPDATE product_template "
|
cr.execute("UPDATE product_template "
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Created on 2017-11-05
|
# Created on 2017-01-09
|
||||||
# author: 广州尚鹏,http://www.sunpop.cn
|
# author: 广州尚鹏,http://www.sunpop.cn
|
||||||
# email: 300883@qq.com
|
# email: 300883@qq.com
|
||||||
# resource of Sunpop
|
# resource of Sunpop
|
||||||
@@ -24,7 +24,6 @@ class ProductProduct(models.Model):
|
|||||||
default_code_index = fields.Integer('Internal Reference Index', readonly=True)
|
default_code_index = fields.Integer('Internal Reference Index', readonly=True)
|
||||||
|
|
||||||
# todo: 检查数据,要保证数据唯一性
|
# todo: 检查数据,要保证数据唯一性
|
||||||
# 为免报错,不限制唯一性
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('uniq_default_code',
|
('uniq_default_code',
|
||||||
'unique(default_code)',
|
'unique(default_code)',
|
||||||
@@ -63,7 +62,7 @@ class ProductProduct(models.Model):
|
|||||||
# 有属性值了,自己是第一个规格
|
# 有属性值了,自己是第一个规格
|
||||||
code_index = 1
|
code_index = 1
|
||||||
vals['default_code_index'] = code_index
|
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:
|
elif mylen == 1:
|
||||||
# 已存在1个,当存在的1个有属性时,要改已存在的product值
|
# 已存在1个,当存在的1个有属性时,要改已存在的product值
|
||||||
code_index = template.product_variant_ids[:1].default_code_index
|
code_index = template.product_variant_ids[:1].default_code_index
|
||||||
@@ -71,24 +70,24 @@ class ProductProduct(models.Model):
|
|||||||
if code_index == 0:
|
if code_index == 0:
|
||||||
code_index = 1
|
code_index = 1
|
||||||
template.product_variant_ids[:1].default_code_index = code_index
|
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值
|
# 接着改当前操作的product值
|
||||||
code_index = code_index + 1
|
code_index = code_index + 1
|
||||||
vals['default_code_index'] = code_index
|
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:
|
elif mylen > 1:
|
||||||
# 找到最大的序号
|
# 找到最大的序号
|
||||||
variant_max = max(template.product_variant_ids,key=lambda x: x['default_code_index'])
|
variant_max = max(template.product_variant_ids,key=lambda x: x['default_code_index'])
|
||||||
code_index = variant_max['default_code_index'] + 1
|
code_index = variant_max['default_code_index'] + 1
|
||||||
vals['default_code_index'] = code_index
|
vals['default_code_index'] = code_index
|
||||||
vals['default_code'] = code_stored + '-%03d'%(code_index)
|
vals['default_code'] = code_stored + '#%03d'%(code_index)
|
||||||
else:
|
else:
|
||||||
# 当按模板
|
# 当按模板
|
||||||
# 此条件常规不出现,但特殊项目会有
|
# 此条件常规不出现,但特殊项目会有
|
||||||
variant_max = max(template.product_variant_ids,key=lambda x: x['default_code_index'])
|
variant_max = max(template.product_variant_ids,key=lambda x: x['default_code_index'])
|
||||||
code_index = variant_max['default_code_index'] + 1
|
code_index = variant_max['default_code_index'] + 1
|
||||||
vals['default_code_index'] = code_index
|
vals['default_code_index'] = code_index
|
||||||
vals['default_code'] = code_stored + '-%03d'%(code_index)
|
vals['default_code'] = code_stored + '#%03d'%(code_index)
|
||||||
else:
|
else:
|
||||||
# create from product_product
|
# create from product_product
|
||||||
# 默认使用制造成品的编码
|
# 默认使用制造成品的编码
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<section class="oe_container oe_dark">
|
<section class="oe_container oe_dark">
|
||||||
<div class="oe_row oe_padded">
|
<div class="oe_row oe_padded">
|
||||||
<h2 class="oe_slogan" style="color:#875A7B;">App Product Auto Sequence, Auto Code(Variants Supported)</h2>
|
<h2 class="oe_slogan" style="color:#875A7B;"> App Product Auto Sequence, Auto Code(Variants Supported), Auto Attributes</h2>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
This module allows to associate a sequence to the product reference.<br/>
|
This module allows to associate a sequence to the product reference.<br/>
|
||||||
@@ -26,7 +26,16 @@
|
|||||||
<li>
|
<li>
|
||||||
Multi language support.
|
Multi language support.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
Setup default Auto Sequence for each product category.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Auto setup product attribute lik Sale/Purchase, Stockable/Consumable/Service, Stock Routes.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div>
|
||||||
|
<img class="oe_picture oe_screenshot" src="set0.jpg">
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<img class="oe_picture oe_screenshot" src="set1.jpg">
|
<img class="oe_picture oe_screenshot" src="set1.jpg">
|
||||||
</div>
|
</div>
|
||||||
@@ -49,13 +58,13 @@
|
|||||||
Sepcial for variants. add [-00?]<br/>
|
Sepcial for variants. add [-00?]<br/>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
Products with color[red]: M20171100001-001
|
Products with color[red]: M20171100001#001
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Products with color[blue]: M20171100001-002
|
Products with color[blue]: M20171100001#002
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Products with color[white]: M20171100001-003
|
Products with color[white]: M20171100001#003
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
BIN
app_product_type_sequence/static/description/set0.jpg
Normal file
BIN
app_product_type_sequence/static/description/set0.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Reference in New Issue
Block a user