diff --git a/app_product_sequence/__openerp__.py b/app_product_sequence/__openerp__.py
index b99ee5c3..2094e5d5 100644
--- a/app_product_sequence/__openerp__.py
+++ b/app_product_sequence/__openerp__.py
@@ -15,7 +15,7 @@
# http://www.sunpop.cn/odoo10_developer_document_offline/
# description:
{
- 'name': 'App Product Auto Sequence, Auto Code(Variants Supported)',
+ 'name': 'App Product Internal Type,Auto Sequence, Auto Code(Variants Supported)',
'summary': 'Auto Internal Reference.',
"version": '10.0.2.2',
'category': 'Sales',
@@ -46,8 +46,10 @@
'pre_init_hook': 'pre_init_hook',
'depends': [
'product',
- 'sale',
'stock',
+ 'sale',
+ 'purchase',
+ 'mrp',
],
'data': [
# 视图
diff --git a/app_product_sequence/data/product_sequence.xml b/app_product_sequence/data/product_sequence.xml
index 8c920c19..4a502df7 100644
--- a/app_product_sequence/data/product_sequence.xml
+++ b/app_product_sequence/data/product_sequence.xml
@@ -11,59 +11,99 @@
True
-
-
+
+
Sequence for Manufactured Product
product.product
- D%(y)s%(month)s
+ CP%(y)s%(month)s
5
True
-
-
- Sequence for Components Product
+
+
+ Sequence for Manufactured Components
product.product
- C%(y)s%(month)s
+ BJ%(y)s%(month)s
5
True
-
-
+
+
+ Sequence for Sourced Material
+ product.product
+ BC%(y)s%(month)s
+ 5
+
+ True
+
+
+
Sequence for Sourced Product
product.product
- S%(y)s%(month)s
+ CL%(y)s%(month)s
5
True
-
- Sourced Product
- Set prefix as "S" in link sequence
-
+
+
+
+ 制造的成品
+ cp
+ product
+ 1
+ 0
+
+ Set prefix as "CP" in link sequence
+
-
- Manufactured Product
- Set prefix as "D" in link sequence
-
+
+
+ 制造的板件
+ bj
+ product
+ 0
+ 0
+
+ Set prefix as "BJ" in link sequence
+
-
- Components Product
- Set prefix as "C" in link sequence
-
+
+
+ 制造用原材料(板材)
+ bc
+ product
+ 0
+ 1
+
+ Set prefix as "BC" in link sequence
+
+
+
+
+ 外购成品(五金等)
+ cl
+ product
+ 1
+ 1
+
+ Set prefix as "CL" in link sequence
+
-
+
+
internal_type
product.template
default
-
+
diff --git a/app_product_sequence/data/product_sequence_dp.xml b/app_product_sequence/data/product_sequence_dp.xml
new file mode 100644
index 00000000..af3e9cc1
--- /dev/null
+++ b/app_product_sequence/data/product_sequence_dp.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+ 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
+ d
+ product
+ 1
+ 0
+
+ Set prefix as "D" in link sequence
+
+
+
+ Sourced Product
+ s
+ product
+ 1
+ 1
+
+ Set prefix as "S" in link sequence
+
+
+
+ Components Product
+ c
+ product
+ 0
+ 1
+
+ Set prefix as "C" in link sequence
+
+
+
+
+
+ internal_type
+ product.template
+ default
+
+
+
+
+
+
diff --git a/app_product_sequence/data/product_sequence_felive.xml b/app_product_sequence/data/product_sequence_felive.xml
new file mode 100644
index 00000000..22f9cee0
--- /dev/null
+++ b/app_product_sequence/data/product_sequence_felive.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+ Sequence for All Products
+ product.product
+ P%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Manufactured Product
+ product.product
+ CP%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Manufactured Components
+ product.product
+ BJ%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Sourced Material
+ product.product
+ BC%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Sourced Product
+ product.product
+ CL%(y)s%(month)s
+ 5
+
+ True
+
+
+
+
+
+ 制造的成品
+ cp
+ Set prefix as "CP" in link sequence
+
+
+
+
+ 制造的板件
+ bj
+ Set prefix as "BJ" in link sequence
+
+
+
+
+ 制造用原材料(板材)
+ bc
+ Set prefix as "BC" in link sequence
+
+
+
+
+ 外购成品(五金等)
+ cl
+ Set prefix as "cl" in link sequence
+
+
+
+
+
+
+ internal_type
+ product.template
+ default
+
+
+
+
+
+
diff --git a/app_product_sequence/data/product_sequence_origin.xml b/app_product_sequence/data/product_sequence_origin.xml
new file mode 100644
index 00000000..5a990647
--- /dev/null
+++ b/app_product_sequence/data/product_sequence_origin.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+ Sequence for All Products
+ product.product
+ P%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Manufactured Product
+ product.product
+ CP%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Manufactured Components
+ product.product
+ BJ%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Sourced Material
+ product.product
+ BC%(y)s%(month)s
+ 5
+
+ True
+
+
+
+ Sequence for Sourced Product
+ product.product
+ CL%(y)s%(month)s
+ 5
+
+ True
+
+
+
+
+
+ Manufactured Product
+ cp
+ Set prefix as "CP" in link sequence
+
+
+
+
+ Manufactured Components
+ bj
+ Set prefix as "BJ" in link sequence
+
+
+
+
+ Sourced Material
+ bc
+ Set prefix as "BC" in link sequence
+
+
+
+
+ Sourced Product
+ cl
+ Set prefix as "cl" in link sequence
+
+
+
+
+
+ internal_type
+ product.template
+ default
+
+
+
+
+
+
diff --git a/app_product_sequence/i18n/en_GB.po b/app_product_sequence/i18n/en_GB.po
deleted file mode 100644
index 58278920..00000000
--- a/app_product_sequence/i18n/en_GB.po
+++ /dev/null
@@ -1,20 +0,0 @@
-# Translation of Odoo Server.
-# This file contains the translation of the following modules:
-# * product
-#
-# Translators:
-# Ivan Deng <300883@qq.com>
-msgid ""
-msgstr ""
-"Project-Id-Version: Odoo 10.0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-11-22 14:03+0000\n"
-"PO-Revision-Date: 2016-01-30 10:36+0000\n"
-"Last-Translator: Ivan Deng\n"
-"Language-Team: English (United Kingdom) (http://www.transifex.com/odoo/"
-"odoo-10/language/en_GB/)\n"
-"Language: en_GB\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
diff --git a/app_product_sequence/i18n/zh_CN.po b/app_product_sequence/i18n/zh_CN.po
index ba4208f6..239dc661 100644
--- a/app_product_sequence/i18n/zh_CN.po
+++ b/app_product_sequence/i18n/zh_CN.po
@@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 10.0+e-20171014\n"
+"Project-Id-Version: Odoo Server 10.0-20171107\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-11-05 12:11+0000\n"
-"PO-Revision-Date: 2017-11-05 12:11+0000\n"
+"POT-Creation-Date: 2017-12-18 10:50+0000\n"
+"PO-Revision-Date: 2017-12-18 10:50+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -15,6 +15,39 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
+#. module: app_product_sequence
+#: model:ir.model.fields,help:app_product_sequence.field_product_internal_type_type
+msgid "A stockable product is a product for which you manage stock. The \"Inventory\" app has to be installed.\n"
+"A consumable product, on the other hand, is a product for which stock is not managed.\n"
+"A service is a non-material product you provide.\n"
+"A digital content is a non-material product you sell online. The files attached to the products are the one that are sold on the e-commerce such as e-books, music, pictures,... The \"Digital Product\" module has to be installed."
+msgstr "A stockable product is a product for which you manage stock. The \"Inventory\" app has to be installed.\n"
+"A consumable product, on the other hand, is a product for which stock is not managed.\n"
+"A service is a non-material product you provide.\n"
+"A digital content is a non-material product you sell online. The files attached to the products are the one that are sold on the e-commerce such as e-books, music, pictures,... The \"Digital Product\" module has to be installed."
+
+#. module: app_product_sequence
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_purchase_ok
+msgid "Can be Purchased"
+msgstr "可用于采购"
+
+#. module: app_product_sequence
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_rental
+msgid "Can be Rent"
+msgstr "可用于出租"
+
+#. module: app_product_sequence
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_sale_ok
+msgid "Can be Sold"
+msgstr "可用于销售"
+
+#. module: app_product_sequence
+#: code:addons/app_product_sequence/models/product_internal_type.py:34
+#: selection:product.internal.type,type:0
+#, python-format
+msgid "Consumable"
+msgstr "可消耗"
+
#. module: app_product_sequence
#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_create_uid
msgid "Created by"
@@ -25,6 +58,21 @@ msgstr "创建人"
msgid "Created on"
msgstr "创建时间"
+#. module: app_product_sequence
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_category_internal_type
+msgid "Default Internal Type"
+msgstr "默认产品内部类型"
+
+#. module: app_product_sequence
+#: model:ir.ui.view,arch_db:app_product_sequence.product_internal_type_form_view
+msgid "Default Product value"
+msgstr "自动设置产品默认参数"
+
+#. module: app_product_sequence
+#: model:ir.model.fields,help:app_product_sequence.field_product_internal_type_route_ids
+msgid "Depending on the modules installed, this will allow you to define the route of the product: whether it will be bought, manufactured, MTO/MTS,..."
+msgstr "取决于安装的模块,它允许在产品定义路线:购买,制造,MTO/MTS,等等..."
+
#. module: app_product_sequence
#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_description
msgid "Description"
@@ -33,6 +81,7 @@ msgstr "说明"
#. module: app_product_sequence
#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_display_name
#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_name
+#: model:ir.ui.view,arch_db:app_product_sequence.product_internal_type_form_view
msgid "Display Name"
msgstr "显示名称"
@@ -56,7 +105,7 @@ msgstr "主产品编码"
#: model:ir.model.fields,field_description:app_product_sequence.field_product_product_internal_type
#: model:ir.model.fields,field_description:app_product_sequence.field_product_template_internal_type
msgid "Internal Type"
-msgstr "编码类型"
+msgstr "内部(编码)类型"
#. module: app_product_sequence
#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type___last_update
@@ -79,7 +128,7 @@ msgid "Link Sequence"
msgstr "使用的序列"
#. module: app_product_sequence
-#: code:addons/app_product_sequence/models/product_template.py:38
+#: code:addons/app_product_sequence/models/product_template.py:40
#, python-format
msgid "Please save product first before adding varients!"
msgstr "增加产品变体前,请先保存当前产品!"
@@ -94,14 +143,20 @@ msgstr "序列记录的前缀"
msgid "Product"
msgstr "产品"
+#. module: app_product_sequence
+#: model:ir.model,name:app_product_sequence.model_product_category
+msgid "Product Category"
+msgstr "产品类别"
+
#. module: app_product_sequence
#: model:ir.actions.act_window,name:app_product_sequence.internal_type_action
#: model:ir.ui.menu,name:app_product_sequence.menu_internal_type_action_sale
#: model:ir.ui.menu,name:app_product_sequence.menu_internal_type_action_stock
#: model:ir.ui.menu,name:app_product_sequence.menu_internal_type_action_sys
+#: model:ir.ui.view,arch_db:app_product_sequence.product_internal_type_form_view
#: model:ir.ui.view,arch_db:app_product_sequence.product_internal_type_tree_view
msgid "Product Internal Type"
-msgstr "产品编码类型"
+msgstr "内部类型(编码)"
#. module: app_product_sequence
#: model:ir.model,name:app_product_sequence.model_product_template
@@ -109,21 +164,56 @@ msgid "Product Template"
msgstr "产品模板"
#. module: app_product_sequence
-#: code:addons/app_product_sequence/models/product_product.py:80
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_type
+msgid "Product Type"
+msgstr "产品类型"
+
+#. module: app_product_sequence
+#: code:addons/app_product_sequence/models/product_product.py:83
#, python-format
msgid "Product varient can only create in Product view!"
msgstr "请在产品管理页面增加产品的多属性!"
#. module: app_product_sequence
-#: sql_constraint:product.internal.type:0
-msgid "The Link Sequence must be unique"
-msgstr "使用的序列不可重复!"
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_route_ids
+msgid "Routes"
+msgstr "路线"
#. module: app_product_sequence
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_sequence_prefix
+msgid "Sequence Prefix"
+msgstr "编号前缀"
+
+#. module: app_product_sequence
+#: code:addons/app_product_sequence/models/product_internal_type.py:35
+#: selection:product.internal.type,type:0
+#, python-format
+msgid "Service"
+msgstr "服务"
+
+#. module: app_product_sequence
+#: model:ir.model.fields,help:app_product_sequence.field_product_internal_type_sale_ok
+msgid "Specify if the product can be selected in a sales order line."
+msgstr "如果产品能在销售单明细在被选择,则指定。"
+
+#. module: app_product_sequence
+#: code:addons/app_product_sequence/models/product_internal_type.py:36
+#: selection:product.internal.type,type:0
+#, python-format
+msgid "Stockable Product"
+msgstr "可库存产品"
+
+#. module: app_product_sequence
+#: sql_constraint:product.internal.type:0
#: sql_constraint:product.product:0
msgid "The reference must be unique"
msgstr "产品内部编码不可重复!"
+#. module: app_product_sequence
+#: model:ir.model.fields,field_description:app_product_sequence.field_product_internal_type_ref
+msgid "Unique Code"
+msgstr "唯一编码"
+
#. module: app_product_sequence
#: model:ir.model,name:app_product_sequence.model_product_internal_type
msgid "product.internal.type"
diff --git a/app_product_sequence/models/product_internal_type.py b/app_product_sequence/models/product_internal_type.py
index abe2b70e..9eaf84de 100644
--- a/app_product_sequence/models/product_internal_type.py
+++ b/app_product_sequence/models/product_internal_type.py
@@ -21,18 +21,42 @@ from openerp import api, fields, models, _
class ProductInternalType(models.Model):
_name = "product.internal.type"
- name = fields.Char('Display Name',default='Normal')
+ name = fields.Char('Display Name', default='Normal', translate=True)
description = fields.Char('Description')
- # 因为default_code有odoo的处理方式,影响面大,故会将其另存到 default_code_stored
+ ref = fields.Char('Unique Code', required=True)
+
link_sequence = fields.Many2one(
'ir.sequence', 'Link Sequence',
auto_join=True, required=True, domain="[('code', '=', 'product.product')]")
sequence_prefix = fields.Char(u'Sequence Prefix', related='link_sequence.prefix', readonly=True, store=False)
+ # 各种默认值,填则自动录入,不填则不管
+ type = fields.Selection([
+ ('consu', _('Consumable')),
+ ('service', _('Service')),
+ ('product', _('Stockable Product'))], string='Product Type',
+ help='A stockable product is a product for which you manage stock. The "Inventory" app has to be installed.\n'
+ 'A consumable product, on the other hand, is a product for which stock is not managed.\n'
+ 'A service is a non-material product you provide.\n'
+ 'A digital content is a non-material product you sell online. The files attached to the products are the one that are sold on '
+ 'the e-commerce such as e-books, music, pictures,... The "Digital Product" module has to be installed.')
+
+ rental = fields.Boolean('Can be Rent')
+ sale_ok = fields.Boolean(
+ 'Can be Sold', default=True,
+ help="Specify if the product can be selected in a sales order line.")
+ purchase_ok = fields.Boolean('Can be Purchased', default=True)
+
+ # 使用目录的默认路线来处理,暂时不用内部类型路线
+ route_ids = fields.Many2many('stock.location.route', string='Routes',
+ domain=[('product_selectable', '=', True)],
+ help="Depending on the modules installed, this will allow you to define the route of the product: whether it will be bought, manufactured, MTO/MTS,...")
+
# company_id = fields.Many2one(
# 'res.company', 'Company',
# default=lambda self: self.env.user.company_id.id, index=1)
- # _sql_constraints = [
- # ('uniq_link_sequence',
- # 'unique(link_sequence)',
- # 'The Link Sequence must be unique'),
- # ]
\ No newline at end of file
+
+ _sql_constraints = [
+ ('uniq_ref',
+ 'unique(ref)',
+ 'The reference must be unique'),
+ ]
\ No newline at end of file
diff --git a/app_product_sequence/models/product_product.py b/app_product_sequence/models/product_product.py
index 3f32589a..60839c7b 100644
--- a/app_product_sequence/models/product_product.py
+++ b/app_product_sequence/models/product_product.py
@@ -73,7 +73,8 @@ class ProductProduct(models.Model):
else:
# create from product_product
sequence = self.env['product.internal.type'].search([('id', '=', vals['internal_type'])], limit=1)
- vals['default_code'] = sequence.link_sequence.next_by_id()
+ if sequence:
+ vals['default_code'] = sequence.link_sequence.next_by_id()
return super(ProductProduct, self).create(vals)
@api.multi
diff --git a/app_product_sequence/models/product_template.py b/app_product_sequence/models/product_template.py
index faf4be3e..d0d01cca 100644
--- a/app_product_sequence/models/product_template.py
+++ b/app_product_sequence/models/product_template.py
@@ -22,6 +22,7 @@ class ProductTemplate(models.Model):
_name = "product.template"
_inherit = ['product.template']
+ # auto_join只要搜索product.template,自动会join。如果经常用到 internal_type 效率会高。
internal_type = fields.Many2one(
'product.internal.type', 'Internal Type',
auto_join=True, required=True)
@@ -58,6 +59,17 @@ class ProductTemplate(models.Model):
if len(self.product_variant_ids) == 1:
self.product_variant_ids.default_code = self.default_code_stored
+ # 当内部类型变化时,改变产品模板的各默认值
+ @api.onchange('internal_type')
+ def _onchange_internal_type(self):
+ if self.internal_type:
+ self.type = self.internal_type.type
+ self.rental = self.internal_type.rental
+ self.sale_ok = self.internal_type.sale_ok
+ self.purchase_ok = self.internal_type.purchase_ok
+ self.route_ids = self.internal_type.route_ids
+
+ # 分类变动时,如果分类绑定了内部类型则联动
@api.onchange('categ_id')
def _onchange_cate_id(self):
if self.categ_id and self.categ_id.internal_type:
diff --git a/app_product_sequence/views/product_internal_type_view.xml b/app_product_sequence/views/product_internal_type_view.xml
index 324ef23b..3175eb85 100644
--- a/app_product_sequence/views/product_internal_type_view.xml
+++ b/app_product_sequence/views/product_internal_type_view.xml
@@ -6,19 +6,72 @@
product.internal.type.tree
product.internal.type
-
+
-
+
+
+
+
+
+
+
+
+ product.internal.type.form
+ product.internal.type
+
+
+
+
+
Product Internal Type
ir.actions.act_window
product.internal.type
- tree
+ tree,form
diff --git a/app_product_sequence/views/product_template_view.xml b/app_product_sequence/views/product_template_view.xml
index d6b1408e..ba2e4011 100644
--- a/app_product_sequence/views/product_template_view.xml
+++ b/app_product_sequence/views/product_template_view.xml
@@ -8,7 +8,7 @@
-
+
@@ -18,8 +18,11 @@
product.template
-
-
+
+
+
+
+