mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix internal_type_product 跳号bug
This commit is contained in:
@@ -59,7 +59,7 @@
|
|||||||
'views/product_product_view.xml',
|
'views/product_product_view.xml',
|
||||||
'views/product_category_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_dp.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data noupdate="0">
|
<data noupdate="1">
|
||||||
<!-- 更新序号规则 Auto Internal Reference. -->
|
<!-- 更新序号规则 Auto Internal Reference. -->
|
||||||
<!-- 所有的 All Products. -->
|
<!-- 所有的 All Products. -->
|
||||||
<record id="seq_product_auto" model="ir.sequence">
|
<record id="seq_product_auto" model="ir.sequence">
|
||||||
@@ -38,7 +38,8 @@
|
|||||||
<field name="company_id" eval="False"/>
|
<field name="company_id" eval="False"/>
|
||||||
<field name="initial">True</field>
|
<field name="initial">True</field>
|
||||||
</record>
|
</record>
|
||||||
|
</data>
|
||||||
|
<data noupdate="0">
|
||||||
<!-- internal_type 数据-->
|
<!-- internal_type 数据-->
|
||||||
<record id="internal_type_mrp_product" model="product.internal.type">
|
<record id="internal_type_mrp_product" model="product.internal.type">
|
||||||
<field name="name">Manufactured Product</field>
|
<field name="name">Manufactured Product</field>
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
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"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2017-12-18 19:02+0000\n"
|
"POT-Creation-Date: 2017-12-19 13:34+0000\n"
|
||||||
"PO-Revision-Date: 2017-12-18 19:02+0000\n"
|
"PO-Revision-Date: 2017-12-19 13:34+0000\n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\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 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."
|
"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
|
#. module: app_product_type_sequence
|
||||||
#: model:ir.model.fields,field_description:app_product_type_sequence.field_product_internal_type_purchase_ok
|
#: model:ir.model.fields,field_description:app_product_type_sequence.field_product_internal_type_purchase_ok
|
||||||
msgid "Can be Purchased"
|
msgid "Can be Purchased"
|
||||||
@@ -41,6 +46,11 @@ msgstr "可用于出租"
|
|||||||
msgid "Can be Sold"
|
msgid "Can be Sold"
|
||||||
msgstr "可用于销售"
|
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
|
#. module: app_product_type_sequence
|
||||||
#: code:addons/app_product_type_sequence/models/product_internal_type.py:34
|
#: code:addons/app_product_type_sequence/models/product_internal_type.py:34
|
||||||
#: selection:product.internal.type,type:0
|
#: selection:product.internal.type,type:0
|
||||||
@@ -63,11 +73,6 @@ msgstr "创建时间"
|
|||||||
msgid "Default Internal Type"
|
msgid "Default Internal Type"
|
||||||
msgstr "默认产品内部类型"
|
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
|
#. module: app_product_type_sequence
|
||||||
#: model:ir.model.fields,help:app_product_type_sequence.field_product_internal_type_route_ids
|
#: 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,..."
|
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_product_internal_type
|
||||||
#: model:ir.model.fields,field_description:app_product_type_sequence.field_product_template_internal_type
|
#: model:ir.model.fields,field_description:app_product_type_sequence.field_product_template_internal_type
|
||||||
msgid "Internal Type"
|
msgid "Internal Type"
|
||||||
msgstr "内部(编码)类型"
|
msgstr "内部类型"
|
||||||
|
|
||||||
#. module: app_product_type_sequence
|
#. module: app_product_type_sequence
|
||||||
#: model:ir.model.fields,field_description:app_product_type_sequence.field_product_internal_type___last_update
|
#: model:ir.model.fields,field_description:app_product_type_sequence.field_product_internal_type___last_update
|
||||||
@@ -127,6 +132,18 @@ msgstr "最后更新时间"
|
|||||||
msgid "Link Sequence"
|
msgid "Link Sequence"
|
||||||
msgstr "使用的序列"
|
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
|
#. module: app_product_type_sequence
|
||||||
#: code:addons/app_product_type_sequence/models/product_template.py:41
|
#: code:addons/app_product_type_sequence/models/product_template.py:41
|
||||||
#, python-format
|
#, python-format
|
||||||
@@ -150,13 +167,14 @@ msgstr "产品类别"
|
|||||||
|
|
||||||
#. module: app_product_type_sequence
|
#. module: app_product_type_sequence
|
||||||
#: model:ir.actions.act_window,name:app_product_type_sequence.internal_type_action
|
#: 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_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_stock
|
||||||
#: model:ir.ui.menu,name:app_product_type_sequence.menu_internal_type_action_sys
|
#: 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_form_view
|
||||||
#: model:ir.ui.view,arch_db:app_product_type_sequence.product_internal_type_tree_view
|
#: model:ir.ui.view,arch_db:app_product_type_sequence.product_internal_type_tree_view
|
||||||
msgid "Product Internal Type"
|
msgid "Product Internal Type"
|
||||||
msgstr "产品内部(编码)类型"
|
msgstr "产品编码类型"
|
||||||
|
|
||||||
#. module: app_product_type_sequence
|
#. module: app_product_type_sequence
|
||||||
#: model:ir.model,name:app_product_type_sequence.model_product_template
|
#: model:ir.model,name:app_product_type_sequence.model_product_template
|
||||||
@@ -191,6 +209,11 @@ msgstr "编号前缀"
|
|||||||
msgid "Service"
|
msgid "Service"
|
||||||
msgstr "服务"
|
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
|
#. module: app_product_type_sequence
|
||||||
#: model:ir.model.fields,help:app_product_type_sequence.field_product_internal_type_sale_ok
|
#: 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."
|
msgid "Specify if the product can be selected in a sales order line."
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from openerp import models, fields, api, exceptions, _
|
|||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
_inherit = 'product.product'
|
_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)
|
default_code_index = fields.Integer('Internal Reference Index', readonly=True)
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
@@ -31,15 +31,15 @@ class ProductProduct(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
# todo: but 先建空白产品后,编辑给2个以上变体,序号会少个 -1
|
# todo: but 先建空白产品后,编辑2个以上变体,序号会少个 -1
|
||||||
# code_index: 当没有变体现时,值为0,有变体时,为该变体序号
|
# 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
|
code_index = 0
|
||||||
if 'product_tmpl_id' in vals:
|
if 'product_tmpl_id' in vals:
|
||||||
template = self.env['product.template'].search([('id', '=', vals['product_tmpl_id'])], limit=1)
|
template = self.env['product.template'].search([('id', '=', vals['product_tmpl_id'])], limit=1)
|
||||||
mylen = len(template.product_variant_ids)
|
mylen = len(template.product_variant_ids)
|
||||||
# created from product_template
|
|
||||||
if 'product_tmpl_id' in vals:
|
if 'product_tmpl_id' in vals:
|
||||||
|
# created from product_template
|
||||||
template = self.env['product.template'].search([('id', '=', vals['product_tmpl_id'])], limit=1)
|
template = self.env['product.template'].search([('id', '=', vals['product_tmpl_id'])], limit=1)
|
||||||
attr = vals['attribute_value_ids'][0][2]
|
attr = vals['attribute_value_ids'][0][2]
|
||||||
if not(attr):
|
if not(attr):
|
||||||
@@ -75,6 +75,10 @@ class ProductProduct(models.Model):
|
|||||||
sequence = self.env['product.internal.type'].search([('id', '=', vals['internal_type'])], limit=1)
|
sequence = self.env['product.internal.type'].search([('id', '=', vals['internal_type'])], limit=1)
|
||||||
if sequence:
|
if sequence:
|
||||||
vals['default_code'] = sequence.link_sequence.next_by_id()
|
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)
|
return super(ProductProduct, self).create(vals)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -82,3 +86,19 @@ class ProductProduct(models.Model):
|
|||||||
if len(self.product_tmpl_id.product_variant_ids)>1 :
|
if len(self.product_tmpl_id.product_variant_ids)>1 :
|
||||||
raise exceptions.ValidationError(_('Product varient can only create in Product view!'))
|
raise exceptions.ValidationError(_('Product varient can only create in Product view!'))
|
||||||
return super(ProductProduct, self).copy(default=None)
|
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
|
||||||
@@ -28,21 +28,26 @@ class ProductTemplate(models.Model):
|
|||||||
auto_join=True, required=True)
|
auto_join=True, required=True)
|
||||||
|
|
||||||
default_code = fields.Char(
|
default_code = fields.Char(
|
||||||
'Internal Reference', compute='_compute_default_code',
|
'Internal Reference',
|
||||||
inverse='_set_default_code', store=True, readonly=True,
|
compute='_compute_default_code',
|
||||||
default='New', copy=False)
|
inverse='_set_default_code',
|
||||||
|
store=True,
|
||||||
|
default=lambda self: _('New'), copy=False)
|
||||||
# 因为default_code有odoo的处理方式,影响面大,故会将其另存到 default_code_stored
|
# 因为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
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
if 'attribute_line_ids' in vals:
|
if 'attribute_line_ids' in vals:
|
||||||
if len(vals['attribute_line_ids'])>0:
|
if len(vals['attribute_line_ids'])>0:
|
||||||
raise exceptions.ValidationError(_('Please save product first before adding varients!'))
|
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)
|
if not (self.env.context.get('create_product_product')):
|
||||||
vals['default_code'] = sequence.link_sequence.next_by_id()
|
# 当从产品模板界面建立时(如果从产品界面建立,则已经生成了编码,不需要再处理)
|
||||||
vals['default_code_stored'] = vals['default_code']
|
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)
|
return super(ProductTemplate, self).create(vals)
|
||||||
|
|
||||||
@api.depends('product_variant_ids', 'product_variant_ids.default_code')
|
@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)
|
unique_variants = self.filtered(lambda template: len(template.product_variant_ids) == 1)
|
||||||
for template in unique_variants:
|
for template in unique_variants:
|
||||||
template.default_code = template.product_variant_ids.default_code
|
template.default_code = template.product_variant_ids.default_code
|
||||||
|
template.default_code_store = template.default_code
|
||||||
for template in (self):
|
for template in (self):
|
||||||
if len(template.product_variant_ids)>1:
|
if len(template.product_variant_ids)>1:
|
||||||
template.default_code = ''
|
template.default_code = ''
|
||||||
|
|||||||
@@ -71,6 +71,9 @@
|
|||||||
<menuitem action="app_product_type_sequence.internal_type_action" id="menu_internal_type_action_sale"
|
<menuitem action="app_product_type_sequence.internal_type_action" id="menu_internal_type_action_sale"
|
||||||
parent="sale.prod_config_main" sequence="6" groups="base.group_no_one"/>
|
parent="sale.prod_config_main" sequence="6" groups="base.group_no_one"/>
|
||||||
|
|
||||||
|
<menuitem action="app_product_type_sequence.internal_type_action" id="menu_internal_type_action_purchase"
|
||||||
|
parent="purchase.menu_product_in_config_purchase" sequence="3" groups="base.group_no_one"/>
|
||||||
|
|
||||||
<menuitem action="app_product_type_sequence.internal_type_action" id="menu_internal_type_action_stock"
|
<menuitem action="app_product_type_sequence.internal_type_action" id="menu_internal_type_action_stock"
|
||||||
parent="stock.menu_product_in_config_stock" sequence="3" groups="base.group_no_one"/>
|
parent="stock.menu_product_in_config_stock" sequence="3" groups="base.group_no_one"/>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='name']" position="after">
|
<xpath expr="//field[@name='name']" position="after">
|
||||||
<field name="internal_type"/>
|
<field name="internal_type"/>
|
||||||
|
<field name="id"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='type']" position="before">
|
<xpath expr="//field[@name='type']" position="before">
|
||||||
<field name="internal_type"/>
|
<field name="internal_type"/>
|
||||||
|
<field name="id"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -20,11 +21,35 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//div[@name='options']" position="before">
|
<xpath expr="//div[@name='options']" position="before">
|
||||||
<div>
|
<div>
|
||||||
<label for="internal_type"/>
|
<h4>
|
||||||
<field name="internal_type" options="{'no_create': True,'no_open': True}"/>
|
<label class="oe_edit_only" for="internal_type"/>
|
||||||
|
<field name="internal_type" options="{'no_create': True,'no_open': True}"/>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
<!--改产品默认视图为tree-->
|
||||||
|
<record id="product.product_template_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Products</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">product.template</field>
|
||||||
|
<field name="view_mode">tree,kanban,form</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_id" ref="product.product_template_kanban_view"/>
|
||||||
|
<field name="context">{"search_default_filter_to_sell":1}</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="oe_view_nocontent_create">
|
||||||
|
Click to define a new product.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
You must define a product for everything you sell, whether it's a physical product, a consumable or a service you offer to customers.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The product form contains information to simplify the sale process: price, notes in the quotation, accounting data, procurement methods,
|
||||||
|
etc.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|||||||
Reference in New Issue
Block a user