openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #02118
lp:~camptocamp/openerp-product-attributes/7.0-product_sequence-migr into lp:openerp-product-attributes
Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/openerp-product-attributes/7.0-product_sequence-migr into lp:openerp-product-attributes.
Commit message:
[MIGR] migration of product_sequence to openerp 7.0
Requested reviews:
Product Core Editors (product-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-product_sequence-migr/+merge/145627
Migration of product_sequence to openerp 7.0
* updated manifest (version, 'data' key, installable)
* formatting and pep8
* removed some useless lines (initialization of a context not used, ...)
* removed a mutable in a keyword argument
* updated the override of the 'default_code' field from the 'product' addon: added a 'select=True' argument
--
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-product_sequence-migr/+merge/145627
Your team OpenERP Community is subscribed to branch lp:openerp-product-attributes.
=== modified file 'product_sequence/__openerp__.py'
--- product_sequence/__openerp__.py 2013-01-21 06:49:06 +0000
+++ product_sequence/__openerp__.py 2013-01-30 15:12:36 +0000
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
@@ -22,7 +22,7 @@
{
'name' : 'Product Sequence',
- 'version' : '6.1.0',
+ 'version' : '7.0',
"author": "Zikzakmedia SL",
"website": "http://www.zikzakmedia.com",
"license" : "AGPL-3",
@@ -35,11 +35,9 @@
'depends' : [
'product',
],
- "init_xml" : [
+ "data" : [
'product_sequence.xml',
],
- "update_xml" : [
- ],
- 'installable': False,
+ 'installable': True,
'active': False,
}
=== modified file 'product_sequence/product_product.py'
--- product_sequence/product_product.py 2012-09-26 15:54:15 +0000
+++ product_sequence/product_product.py 2013-01-30 15:12:36 +0000
@@ -19,47 +19,64 @@
#
##############################################################################
-from openerp.osv.orm import Model
-from openerp.osv import fields
+from openerp.osv import orm, fields
from openerp.tools.translate import _
-class product_product(Model):
+
+class product_product(orm.Model):
_inherit = 'product.product'
+
_columns = {
- 'default_code' : fields.char('Reference', size=64, required=True),
+ 'default_code': fields.char('Reference',
+ size=64,
+ select=True,
+ required=True),
}
+
_sql_constraints = [
- ('uniq_default_code', 'unique(default_code)', "The reference must be unique"),
- ]
+ ('uniq_default_code',
+ 'unique(default_code)',
+ 'The reference must be unique'),
+ ]
+
_defaults = {
- 'default_code': lambda * a: '/',
+ 'default_code': '/',
}
def create(self, cr, uid, vals, context=None):
- if context is None:
- context = {}
if not 'default_code' in vals or vals['default_code'] == '/':
- vals['default_code'] = self.pool.get('ir.sequence').get(cr, uid, 'product.product')
+ vals['default_code'] = self.pool.get('ir.sequence').get(
+ cr, uid, 'product.product')
return super(product_product, self).create(cr, uid, vals, context)
def write(self, cr, uid, ids, vals, context=None):
if not hasattr(ids, '__iter__'):
ids = [ids]
- if context is None:
- context = {}
- products_without_code = self.search(cr, uid, [('default_code', 'in', [False, '/']),('id', 'in', ids)], context=context)
+ products_without_code = self.search(
+ cr, uid,
+ [('default_code', 'in', [False, '/']),
+ ('id', 'in', ids)],
+ context=context)
direct_write_ids = set(ids) - set(products_without_code)
- super(product_product, self).write(cr, uid, list(direct_write_ids), vals, context)
+ super(product_product, self).write(cr, uid,
+ list(direct_write_ids),
+ vals, context=context)
for product_id in products_without_code:
- vals['default_code'] = self.pool.get('ir.sequence').get(cr, uid, 'product.product')
- super(product_product, self).write(cr, uid, product_id, vals, context)
+ vals['default_code'] = self.pool.get('ir.sequence').get(
+ cr, uid, 'product.product')
+ super(product_product, self).write(cr, uid,
+ product_id,
+ vals,
+ context=context)
return True
- def copy(self, cr, uid, id, default={}, context=None):
+ def copy(self, cr, uid, id, default=None, context=None):
+ if default is None:
+ default = {}
product = self.read(cr, uid, id, ['default_code'], context=context)
- if product['default_code']:
+ if product['default_code']:
default.update({
- 'default_code': product['default_code']+ _('-copy'),
+ 'default_code': product['default_code'] + _('-copy'),
})
return super(product_product, self).copy(cr, uid, id, default, context)
=== modified file 'product_sequence/product_sequence.xml'
--- product_sequence/product_sequence.xml 2012-08-02 10:43:21 +0000
+++ product_sequence/product_sequence.xml 2013-01-30 15:12:36 +0000
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<openerp>
<data noupdate="1">
+
<record id="seq_product_auto_type" model="ir.sequence.type">
<field name="name">Product</field>
<field name="code">product.product</field>
</record>
-
+
<record id="seq_product_auto" model="ir.sequence">
<field name="name">Product</field>
<field name="code">product.product</field>
Follow ups