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_category_view.xml',
|
||||
'views/product_internal_type_view.xml',
|
||||
'data/product_sequence.xml',
|
||||
'data/product_sequence_dp.xml',
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
<data noupdate="1">
|
||||
<!-- 更新序号规则 Auto Internal Reference. -->
|
||||
<!-- 所有的 All Products. -->
|
||||
<record id="seq_product_auto" model="ir.sequence">
|
||||
@@ -38,7 +38,8 @@
|
||||
<field name="company_id" eval="False"/>
|
||||
<field name="initial">True</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
<data noupdate="0">
|
||||
<!-- internal_type 数据-->
|
||||
<record id="internal_type_mrp_product" model="product.internal.type">
|
||||
<field name="name">Manufactured Product</field>
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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
|
||||
@@ -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 = ''
|
||||
|
||||
@@ -71,6 +71,9 @@
|
||||
<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"/>
|
||||
|
||||
<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"
|
||||
parent="stock.menu_product_in_config_stock" sequence="3" groups="base.group_no_one"/>
|
||||
</data>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="internal_type"/>
|
||||
<field name="id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='type']" position="before">
|
||||
<field name="internal_type"/>
|
||||
<field name="id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -20,11 +21,35 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='options']" position="before">
|
||||
<div>
|
||||
<label for="internal_type"/>
|
||||
<field name="internal_type" options="{'no_create': True,'no_open': True}"/>
|
||||
<h4>
|
||||
<label class="oe_edit_only" for="internal_type"/>
|
||||
<field name="internal_type" options="{'no_create': True,'no_open': True}"/>
|
||||
</h4>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</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>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user