diff --git a/app_product_type_sequence/__openerp__.py b/app_product_type_sequence/__openerp__.py index 2094e5d5..b9ad70f3 100644 --- a/app_product_type_sequence/__openerp__.py +++ b/app_product_type_sequence/__openerp__.py @@ -59,7 +59,7 @@ 'views/product_product_view.xml', 'views/product_category_view.xml', 'views/product_internal_type_view.xml', - 'data/product_sequence.xml', + 'data/product_sequence_dp.xml', ], 'demo': [ ], diff --git a/app_product_type_sequence/data/product_sequence_dp.xml b/app_product_type_sequence/data/product_sequence_dp.xml index ae13b86c..d8a23aae 100644 --- a/app_product_type_sequence/data/product_sequence_dp.xml +++ b/app_product_type_sequence/data/product_sequence_dp.xml @@ -1,6 +1,6 @@ - + @@ -38,7 +38,8 @@ True - + + Manufactured Product diff --git a/app_product_type_sequence/i18n/zh_CN.po b/app_product_type_sequence/i18n/zh_CN.po index 47a020b7..09729dce 100644 --- a/app_product_type_sequence/i18n/zh_CN.po +++ b/app_product_type_sequence/i18n/zh_CN.po @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0-20171107\n" +"Project-Id-Version: Odoo Server 10.0+e-20171107\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-12-18 19:02+0000\n" -"PO-Revision-Date: 2017-12-18 19:02+0000\n" +"POT-Creation-Date: 2017-12-19 13:34+0000\n" +"PO-Revision-Date: 2017-12-19 13:34+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -26,6 +26,11 @@ msgstr "A stockable product is a product for which you manage stock. The \"Inven "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_type_sequence +#: model:ir.ui.view,arch_db:app_product_type_sequence.product_internal_type_form_view +msgid "Auto Set Product's Value To:" +msgstr "自动设置产品默认参数为:" + #. module: app_product_type_sequence #: model:ir.model.fields,field_description:app_product_type_sequence.field_product_internal_type_purchase_ok msgid "Can be Purchased" @@ -41,6 +46,11 @@ msgstr "可用于出租" msgid "Can be Sold" msgstr "可用于销售" +#. module: app_product_type_sequence +#: model:product.internal.type,name:app_product_type_sequence.internal_type_sourced_material +msgid "Components Product" +msgstr "原材料" + #. module: app_product_type_sequence #: code:addons/app_product_type_sequence/models/product_internal_type.py:34 #: selection:product.internal.type,type:0 @@ -63,11 +73,6 @@ msgstr "创建时间" msgid "Default Internal Type" msgstr "默认产品内部类型" -#. module: app_product_type_sequence -#: model:ir.ui.view,arch_db:app_product_type_sequence.product_internal_type_form_view -msgid "Auto Set Product's Value To:" -msgstr "自动设置产品默认参数为:" - #. module: app_product_type_sequence #: model:ir.model.fields,help:app_product_type_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,..." @@ -105,7 +110,7 @@ msgstr "主产品编码" #: model:ir.model.fields,field_description:app_product_type_sequence.field_product_product_internal_type #: model:ir.model.fields,field_description:app_product_type_sequence.field_product_template_internal_type msgid "Internal Type" -msgstr "内部(编码)类型" +msgstr "内部类型" #. module: app_product_type_sequence #: model:ir.model.fields,field_description:app_product_type_sequence.field_product_internal_type___last_update @@ -127,6 +132,18 @@ msgstr "最后更新时间" msgid "Link Sequence" msgstr "使用的序列" +#. module: app_product_type_sequence +#: model:product.internal.type,name:app_product_type_sequence.internal_type_mrp_product +msgid "Manufactured Product" +msgstr "制造成品" + +#. module: app_product_type_sequence +#: code:addons/app_product_type_sequence/models/product_product.py:23 +#: code:addons/app_product_type_sequence/models/product_template.py:33 +#, python-format +msgid "New" +msgstr "新建" + #. module: app_product_type_sequence #: code:addons/app_product_type_sequence/models/product_template.py:41 #, python-format @@ -150,13 +167,14 @@ msgstr "产品类别" #. module: app_product_type_sequence #: model:ir.actions.act_window,name:app_product_type_sequence.internal_type_action +#: model:ir.ui.menu,name:app_product_type_sequence.menu_internal_type_action_purchase #: model:ir.ui.menu,name:app_product_type_sequence.menu_internal_type_action_sale #: model:ir.ui.menu,name:app_product_type_sequence.menu_internal_type_action_stock #: model:ir.ui.menu,name:app_product_type_sequence.menu_internal_type_action_sys #: model:ir.ui.view,arch_db:app_product_type_sequence.product_internal_type_form_view #: model:ir.ui.view,arch_db:app_product_type_sequence.product_internal_type_tree_view msgid "Product Internal Type" -msgstr "产品内部(编码)类型" +msgstr "产品编码类型" #. module: app_product_type_sequence #: model:ir.model,name:app_product_type_sequence.model_product_template @@ -191,6 +209,11 @@ msgstr "编号前缀" msgid "Service" msgstr "服务" +#. module: app_product_type_sequence +#: model:product.internal.type,name:app_product_type_sequence.internal_type_sourced_product +msgid "Sourced Product" +msgstr "外购成品" + #. module: app_product_type_sequence #: model:ir.model.fields,help:app_product_type_sequence.field_product_internal_type_sale_ok msgid "Specify if the product can be selected in a sales order line." diff --git a/app_product_type_sequence/models/product_product.py b/app_product_type_sequence/models/product_product.py index 99b49892..7ea3fd3f 100644 --- a/app_product_type_sequence/models/product_product.py +++ b/app_product_type_sequence/models/product_product.py @@ -20,7 +20,7 @@ from openerp import models, fields, api, exceptions, _ class ProductProduct(models.Model): _inherit = 'product.product' - default_code = fields.Char('Internal Reference', index=True, readonly=True, default=lambda self: _('New'), copy=False) + default_code = fields.Char('Internal Reference', index=True, default=lambda self: _('New'), copy=False) default_code_index = fields.Integer('Internal Reference Index', readonly=True) _sql_constraints = [ @@ -31,15 +31,15 @@ class ProductProduct(models.Model): @api.model def create(self, vals): - # todo: but 先建空白产品后,编辑给2个以上变体,序号会少个 -1 + # todo: but 先建空白产品后,编辑2个以上变体,序号会少个 -1 # code_index: 当没有变体现时,值为0,有变体时,为该变体序号 - if 'default_code' not in vals or vals['default_code'] == 'New': + if 'default_code' not in vals or vals['default_code'] == _('New'): code_index = 0 if 'product_tmpl_id' in vals: template = self.env['product.template'].search([('id', '=', vals['product_tmpl_id'])], limit=1) mylen = len(template.product_variant_ids) - # created from product_template if 'product_tmpl_id' in vals: + # created from product_template template = self.env['product.template'].search([('id', '=', vals['product_tmpl_id'])], limit=1) attr = vals['attribute_value_ids'][0][2] if not(attr): @@ -75,6 +75,10 @@ class ProductProduct(models.Model): sequence = self.env['product.internal.type'].search([('id', '=', vals['internal_type'])], limit=1) if sequence: vals['default_code'] = sequence.link_sequence.next_by_id() + else: + sequence = self.env['product.internal.type'].search([('id', '=', vals['internal_type'])], limit=1) + if sequence: + vals['default_code'] = sequence.link_sequence.next_by_id() return super(ProductProduct, self).create(vals) @api.multi @@ -82,3 +86,19 @@ class ProductProduct(models.Model): if len(self.product_tmpl_id.product_variant_ids)>1 : raise exceptions.ValidationError(_('Product varient can only create in Product view!')) return super(ProductProduct, self).copy(default=None) + + # 当内部类型变化时,改变产品模板的各默认值 + @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: + self.internal_type = self.categ_id.internal_type \ No newline at end of file diff --git a/app_product_type_sequence/models/product_template.py b/app_product_type_sequence/models/product_template.py index d0d01cca..f6f3325d 100644 --- a/app_product_type_sequence/models/product_template.py +++ b/app_product_type_sequence/models/product_template.py @@ -28,21 +28,26 @@ class ProductTemplate(models.Model): auto_join=True, required=True) default_code = fields.Char( - 'Internal Reference', compute='_compute_default_code', - inverse='_set_default_code', store=True, readonly=True, - default='New', copy=False) + 'Internal Reference', + compute='_compute_default_code', + inverse='_set_default_code', + store=True, + default=lambda self: _('New'), copy=False) # 因为default_code有odoo的处理方式,影响面大,故会将其另存到 default_code_stored - default_code_stored = fields.Char('Internal Reference Stored',default='New') + default_code_stored = fields.Char('Internal Reference Stored',default=lambda self: _('New')) @api.model def create(self, vals): if 'attribute_line_ids' in vals: if len(vals['attribute_line_ids'])>0: raise exceptions.ValidationError(_('Please save product first before adding varients!')) - if 'default_code' not in vals or vals['default_code'] == 'New': - sequence = self.env['product.internal.type'].search([('id', '=', vals['internal_type'])], limit=1) - vals['default_code'] = sequence.link_sequence.next_by_id() - vals['default_code_stored'] = vals['default_code'] + + if not (self.env.context.get('create_product_product')): + # 当从产品模板界面建立时(如果从产品界面建立,则已经生成了编码,不需要再处理) + if 'default_code' not in vals or vals['default_code'] == _('New'): + sequence = self.env['product.internal.type'].search([('id', '=', vals['internal_type'])], limit=1) + vals['default_code'] = sequence.link_sequence.next_by_id() + vals['default_code_stored'] = vals['default_code'] return super(ProductTemplate, self).create(vals) @api.depends('product_variant_ids', 'product_variant_ids.default_code') @@ -50,6 +55,7 @@ class ProductTemplate(models.Model): unique_variants = self.filtered(lambda template: len(template.product_variant_ids) == 1) for template in unique_variants: template.default_code = template.product_variant_ids.default_code + template.default_code_store = template.default_code for template in (self): if len(template.product_variant_ids)>1: template.default_code = '' diff --git a/app_product_type_sequence/views/product_internal_type_view.xml b/app_product_type_sequence/views/product_internal_type_view.xml index 36107c92..1edac2ce 100644 --- a/app_product_type_sequence/views/product_internal_type_view.xml +++ b/app_product_type_sequence/views/product_internal_type_view.xml @@ -71,6 +71,9 @@ + + diff --git a/app_product_type_sequence/views/product_product_view.xml b/app_product_type_sequence/views/product_product_view.xml index 834bb3ef..542e2a9b 100644 --- a/app_product_type_sequence/views/product_product_view.xml +++ b/app_product_type_sequence/views/product_product_view.xml @@ -9,6 +9,7 @@ + diff --git a/app_product_type_sequence/views/product_template_view.xml b/app_product_type_sequence/views/product_template_view.xml index 94a811ad..45ed4a3b 100644 --- a/app_product_type_sequence/views/product_template_view.xml +++ b/app_product_type_sequence/views/product_template_view.xml @@ -9,6 +9,7 @@ + @@ -20,11 +21,35 @@
-
+ + + Products + ir.actions.act_window + product.template + tree,kanban,form + form + + {"search_default_filter_to_sell":1} + +

+ Click to define a new product. +

+

+ You must define a product for everything you sell, whether it's a physical product, a consumable or a service you offer to customers. +

+

+ The product form contains information to simplify the sale process: price, notes in the quotation, accounting data, procurement methods, + etc. +

+
+