savoirfairelinux-openerp team mailing list archive
-
savoirfairelinux-openerp team
-
Mailing list archive
-
Message #00013
lp:~extra-addons-commiter/product-extra-addons/oerp6.1-cleanning into lp:product-extra-addons/oerp6.1-stable
Sébastien BEAU - http://www.akretion.com has proposed merging lp:~extra-addons-commiter/product-extra-addons/oerp6.1-cleanning into lp:product-extra-addons/oerp6.1-stable.
Requested reviews:
extra-addons-commiter (extra-addons-commiter)
For more details, see:
https://code.launchpad.net/~extra-addons-commiter/product-extra-addons/oerp6.1-cleanning/+merge/135019
--
https://code.launchpad.net/~extra-addons-commiter/product-extra-addons/oerp6.1-cleanning/+merge/135019
Your team extra-addons-commiter is requested to review the proposed merge of lp:~extra-addons-commiter/product-extra-addons/oerp6.1-cleanning into lp:product-extra-addons/oerp6.1-stable.
=== modified file 'product_brand/product_brand.py'
--- product_brand/product_brand.py 2012-03-27 12:50:22 +0000
+++ product_brand/product_brand.py 2012-11-19 23:44:28 +0000
@@ -21,11 +21,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
#################################################################################
-from osv import osv, fields
-import os
+from openerp.osv.orm import Model
+from openerp.osv import fields
-class product_brand(osv.osv):
- _name = 'product.brand'
+class product_brand(Model):
+ _name = 'product.brand'
_columns = {
'name': fields.char('Brand Name',size=32),
'description': fields.text('Description',translate=True),
@@ -33,13 +33,11 @@
'logo': fields.binary('Logo File')
}
-product_brand()
-class product_template(osv.osv):
+class product_template(Model):
_name = 'product.template'
_inherit = 'product.template'
_columns = {
'product_brand_id' : fields.many2one('product.brand','Brand', help='Select a brand for this product'),
}
-product_template()
=== modified file 'product_custom_attributes/__openerp__.py'
--- product_custom_attributes/__openerp__.py 2012-08-18 16:32:28 +0000
+++ product_custom_attributes/__openerp__.py 2012-11-19 23:44:28 +0000
@@ -30,14 +30,14 @@
This module add the posibility to create easily custom field on product.
Each product can be link to an attributes set (like camera, fridge...)
And each attributs have custom fields (for example you don't need the same field for a frigde and a camera)
-
+
Need to install the lib unicode2ascii, http://github.com/akretion/unicode2ascii.git
""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
- 'depends': ['product','stock'],
+ 'depends': ['product','stock'],
'init_xml': [],
- 'update_xml': [
+ 'update_xml': [
'ir_model_view.xml',
'product_attribute_view.xml',
'product_view.xml',
=== modified file 'product_custom_attributes/ir_model.py'
--- product_custom_attributes/ir_model.py 2012-08-09 10:01:01 +0000
+++ product_custom_attributes/ir_model.py 2012-11-19 23:44:28 +0000
@@ -19,23 +19,16 @@
# #
###############################################################################
-from osv import osv, fields
-import netsvc
-
-
-class ir_model_fields(osv.osv):
-
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class ir_model_fields(Model):
+
_inherit = "ir.model.fields"
-
-
_columns = {
'field_description': fields.char('Field Label', required=True, size=256, translate=True),
}
-
- _defaults = {
-
- }
-
_sql_constraints = [
('name_model_uniq', 'unique (name, model_id)', 'The name of the field has to be uniq for a given model !'),
]
=== modified file 'product_custom_attributes/product.py'
--- product_custom_attributes/product.py 2012-08-28 22:35:57 +0000
+++ product_custom_attributes/product.py 2012-11-19 23:44:28 +0000
@@ -19,12 +19,13 @@
# #
###############################################################################
-from osv import osv, fields
-import netsvc
+from openerp.osv.orm import Model
+from openerp.osv import fields
+from openerp.osv.osv import except_osv
from lxml import etree
from tools.translate import _
-class product_template(osv.osv):
+class product_template(Model):
_inherit = "product.template"
@@ -32,7 +33,7 @@
'attribute_custom_tmpl': fields.serialized('Custom Template Attributes'),
}
-class product_product(osv.osv):
+class product_product(Model):
_inherit = "product.product"
@@ -41,6 +42,11 @@
'attribute_custom_variant': fields.serialized('Custom Variant Attributes'),
}
+ def _fix_size_bug(self, cr, uid, result, context=None):
+ for field in result['fields']:
+ if result['fields'][field]['type'] == 'text':
+ if 'size' in result['fields'][field]: del result['fields'][field]['size']
+ return result
def open_attributes(self, cr, uid, ids, context=None):
ir_model_data_obj = self.pool.get('ir.model.data')
@@ -50,7 +56,7 @@
set_id = self.read(cr, uid, ids, fields=['attribute_set_id'], context=context)[0]['attribute_set_id']
if not set_id:
- raise osv.except_osv(_('User Error'), _('Please choose an attribute set before opening the product attributes'))
+ raise except_osv(_('User Error'), _('Please choose an attribute set before opening the product attributes'))
return {
'name': 'Product Attributes',
@@ -73,14 +79,14 @@
kwargs = {'name': "%s" % attribute.name}
if attribute.ttype == 'many2many':
parent = etree.SubElement(page, 'group', colspan="2", col="4")
- sep = etree.SubElement(parent, 'separator',
+ sep = etree.SubElement(parent, 'separator',
string="%s" % attribute.field_description, colspan="4")
kwargs['nolabel'] = "1"
if attribute.ttype in ['many2one', 'many2many']:
kwargs['domain'] = "[('attribute_id', '=', %s)]" % attribute.attribute_id.id
field = etree.SubElement(parent, 'field', **kwargs)
return parent
-
+
def _build_attributes_notebook(self, cr, uid, set_id, context=None):
attribute_set = self.pool.get('attribute.set').browse(cr, uid, set_id, context=context)
notebook = etree.Element('notebook', name="attributes_notebook", colspan="4")
@@ -114,4 +120,5 @@
info_page = eview.xpath("//page[@string='Information']")[0]
info_page.addnext(main_page)
result['arch'] = etree.tostring(eview, pretty_print=True)
+ result = self._fix_size_bug(cr, uid, result, context=context)
return result
=== modified file 'product_custom_attributes/product_attribute.py'
--- product_custom_attributes/product_attribute.py 2012-09-05 08:41:29 +0000
+++ product_custom_attributes/product_attribute.py 2012-11-19 23:44:28 +0000
@@ -19,12 +19,20 @@
# #
###############################################################################
+<<<<<<< TREE
from osv import osv, fields
import netsvc
from unidecode import unidecode # Debian package python-unidecode
from tools.translate import _
+=======
+from openerp.osv.orm import Model
+from openerp.osv import fields
+from openerp.osv.osv import except_osv
+from openerp.tools.translate import _
+from unidecode import unidecode # Debian package python-unidecode
+>>>>>>> MERGE-SOURCE
-class attribute_option(osv.osv):
+class attribute_option(Model):
_name = "attribute.option"
_description = "Attribute Option"
_order="sequence"
@@ -35,25 +43,37 @@
'sequence': fields.integer('Sequence'),
}
-class product_attribute(osv.osv):
+class product_attribute(Model):
_name = "product.attribute"
_description = "Product Attribute"
-
_inherits = {'ir.model.fields': 'field_id'}
-
_columns = {
'field_id': fields.many2one('ir.model.fields', 'Ir Model Fields', required=True, ondelete="cascade"),
- 'attribute_type': fields.selection([('char','Char'),('text','Text'),('select','Select'),('multiselect','Multiselect'),('boolean','Boolean'),('integer','Integer'),('date','Date'),('datetime','Datetime'),('binary','Binary'),('float','Float')],'Type', required=True),
- 'serialized': fields.boolean('Field serialized', help="If serialized, the field will be stocked in the serialized field : attribute_custom_tmpl or attribute_custom_variant depending on the field based_on"),
- 'based_on': fields.selection([('product_template','Product Template'),('product_product','Product Variant')],'Based on', required=True),
+ 'attribute_type': fields.selection([('char','Char'),
+ ('text','Text'),
+ ('select','Select'),
+ ('multiselect','Multiselect'),
+ ('boolean','Boolean'),
+ ('integer','Integer'),
+ ('date','Date'),
+ ('datetime','Datetime'),
+ ('binary','Binary'),
+ ('float','Float')],
+ 'Type', required=True),
+ 'serialized': fields.boolean('Field serialized',
+ help="If serialized, the field will be stocked in the serialized field: "
+ "attribute_custom_tmpl or attribute_custom_variant depending on the field based_on"),
+ 'based_on': fields.selection([('product_template','Product Template'),
+ ('product_product','Product Variant')],
+ 'Based on', required=True),
'option_ids': fields.one2many('attribute.option', 'attribute_id', 'Attribute Option'),
'create_date': fields.datetime('Created date', readonly=True),
- }
+ }
def create(self, cr, uid, vals, context=None):
if vals.get('based_on') == 'product_template':
- vals['model_id'] = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'product.template')],context=context)[0]
+ vals['model_id'] = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'product.template')], context=context)[0]
serial_name = 'attribute_custom_tmpl'
else:
vals['model_id'] = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'product.product')], context=context)[0]
@@ -67,7 +87,7 @@
vals['ttype'] = 'many2many'
vals['relation'] = 'attribute.option'
if not vals.get('serialized'):
- raise osv.except_osv(_('Create Error'), _("The field serialized should be ticked for a multiselect field !"))
+ raise except_osv(_('Create Error'), _("The field serialized should be ticked for a multiselect field !"))
else:
vals['ttype'] = vals['attribute_type']
vals['state'] = 'manual'
@@ -78,24 +98,26 @@
if field_description:
name = unidecode('x_%s' % field_description.replace(' ', '_').lower())
return {'value' : {'name' : name}}
-
-class attribute_location(osv.osv):
-
+
+ def onchange_name(self, cr, uid, ids, name, context=None):
+ if name[:2] != 'x_':
+ name = 'x_%s' % name
+ return {'value' : {'name' : unidecode(name)}}
+
+class attribute_location(Model):
_name = "attribute.location"
_description = "Attribute Location"
_order="sequence"
-
_inherits = {'product.attribute': 'attribute_id'}
-
_columns = {
'attribute_id': fields.many2one('product.attribute', 'Product Attribute', required=True, ondelete="cascade"),
'attribute_set_id': fields.related('attribute_group_id', 'attribute_set_id', type='many2one', relation='attribute.set', string='Attribute Set', store=True, readonly=True),
'attribute_group_id': fields.many2one('attribute.group', 'Attribute Group', required=True),
'sequence': fields.integer('Sequence'),
- }
-
-class attribute_group(osv.osv):
-
+ }
+
+
+class attribute_group(Model):
_name= "attribute.group"
_description = "Attribute Group"
_order="sequence"
@@ -107,13 +129,27 @@
'sequence': fields.integer('Sequence'),
}
+<<<<<<< TREE
class attribute_set(osv.osv):
+=======
+ def create(self, cr, uid, vals, context=None):
+ for attribute in vals['attribute_ids']:
+ if attribute[2] and not attribute[2].get('attribute_set_id'):
+ attribute[2]['attribute_set_id'] = vals['attribute_set_id']
+ return super(attribute_group, self).create(cr, uid, vals, context)
+
+class attribute_set(Model):
+>>>>>>> MERGE-SOURCE
_name = "attribute.set"
_description = "Attribute Set"
-
_columns = {
'name': fields.char('Name', size=128, required=True),
'attribute_group_ids': fields.one2many('attribute.group', 'attribute_set_id', 'Attribute Groups'),
+<<<<<<< TREE
}
+=======
+ }
+
+>>>>>>> MERGE-SOURCE
=== modified file 'product_custom_attributes/product_attribute_view.xml'
--- product_custom_attributes/product_attribute_view.xml 2012-09-04 08:39:59 +0000
+++ product_custom_attributes/product_attribute_view.xml 2012-11-19 23:44:28 +0000
@@ -86,7 +86,7 @@
<field name="arch" type="xml">
<form string="Product Attribute" col="8">
<field name="field_description" colspan="1" on_change="onchange_field_description(field_description, context)"/>
- <field name="name" colspan="1" attrs="{'readonly':[('create_date', '!=', False)]}"/>
+ <field name="name" colspan="1" attrs="{'readonly':[('create_date', '!=', False)]}" on_change="onchange_name(name, context)"/>
<field name="attribute_type" colspan="1"/>
<field name="based_on" colspan="1"/>
<field name="serialized" colspan="1"/>
=== modified file 'product_custom_attributes/wizard/open_product_by_attribute_set.py'
--- product_custom_attributes/wizard/open_product_by_attribute_set.py 2012-08-03 14:33:51 +0000
+++ product_custom_attributes/wizard/open_product_by_attribute_set.py 2012-11-19 23:44:28 +0000
@@ -19,11 +19,11 @@
# #
###############################################################################
-from osv import osv, fields
-import netsvc
-
-
-class open_product_by_attribute_set(osv.osv_memory):
+from openerp.osv.orm import TransientModel
+from osv import fields
+
+
+class open_product_by_attribute_set(TransientModel):
_name = 'open.product.by.attribute.set'
_description = 'Wizard to open product by attributes set'
@@ -44,9 +44,9 @@
if context is None:
context = {}
attribute_set = self.browse(cr, uid, ids[0], context=context).attribute_set_id
- data = self.read(cr, uid, ids, [], context=context)[0]
+ data = self.read(cr, uid, ids, [], context=context)[0] # XXX used?
result = mod_obj.get_object_reference(cr, uid, 'product', 'product_normal_action')
- id = result and result[1] or False
+ id = result[1] if result else False
result = act_obj.read(cr, uid, [id], context=context)[0]
result['context'] = "{'set_id': %s, 'open_product_by_attribute_set': %s}"%(attribute_set.id, True)
result['domain'] = "[('attribute_set_id', '=', %s)]" % attribute_set.id
=== modified file 'product_gift/__openerp__.py'
--- product_gift/__openerp__.py 2012-05-17 09:54:58 +0000
+++ product_gift/__openerp__.py 2012-11-19 23:44:28 +0000
@@ -28,7 +28,7 @@
'description': """This modules add the feature of gift_wrap and give the posibility to add present message on the order or the order line""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
- 'depends': ['sale','product', 'stock'],
+ 'depends': ['sale','product', 'stock'],
'init_xml': [],
'update_xml': [
'stock_view.xml',
=== modified file 'product_gift/product.py'
--- product_gift/product.py 2011-12-01 13:34:58 +0000
+++ product_gift/product.py 2012-11-19 23:44:28 +0000
@@ -19,18 +19,15 @@
# #
#################################################################################
-from osv import osv, fields
-
-
-class product_product(osv.osv):
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class product_product(Model):
_inherit = "product.product"
-
_columns = {
'allow_gift_wrap': fields.boolean('Allow Gift Wrap', help="Determine if the product can have the option gift wrap on the sale order line"),
- }
-
+ }
_defaults = {
'allow_gift_wrap': True,
- }
-
-product_product()
+ }
=== modified file 'product_gift/sale.py'
--- product_gift/sale.py 2012-01-09 13:05:41 +0000
+++ product_gift/sale.py 2012-11-19 23:44:28 +0000
@@ -20,38 +20,31 @@
# #
#################################################################################
-from osv import osv, fields
-
-
-class sale_order(osv.osv):
-
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class sale_order(Model):
_inherit = "sale.order"
-
_columns = {
'gift_message': fields.text('Gift Message'),
- }
+ }
def _prepare_order_picking(self, cr, uid, order, *args, **kwargs):
values = super(sale_order, self)._prepare_order_picking(cr, uid, order, *args, **kwargs)
values.update({'gift_message' : order.gift_message})
return values
-sale_order()
-
-
-class sale_order_line(osv.osv):
-
+
+class sale_order_line(Model):
_inherit = "sale.order.line"
-
_columns = {
'gift_message': fields.text('Gift Message'),
'need_gift_wrap': fields.boolean('Add Gift Wrap'),
- }
+ }
def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, *args, **kwargs):
values = super(sale_order_line, self)._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args, **kwargs)
values.update({'gift_message': line.gift_message,
'need_gift_wrap': line.need_gift_wrap})
return values
-
-sale_order_line()
=== modified file 'product_gift/stock.py'
--- product_gift/stock.py 2011-12-03 12:02:32 +0000
+++ product_gift/stock.py 2012-11-19 23:44:28 +0000
@@ -19,30 +19,25 @@
# #
#################################################################################
-from osv import osv, fields
-
-
-class stock_picking(osv.osv):
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class stock_picking(Model):
_inherit = "stock.picking"
-
_columns = {
'gift_message': fields.text('Gift Message'),
- }
-
-stock_picking()
-
-
-class stock_move(osv.osv):
+ }
+
+
+class stock_move(Model):
_inherit = "stock.move"
-
_columns = {
'gift_message': fields.text('Gift Message'),
'need_gift_wrap': fields.boolean('Need Gift Wrap'),
- }
+ }
def _prepare_chained_picking(self, cr, uid, pick_name, picking, ptype, move, context=None):
res = super(stock_move, self)._prepare_chained_picking(cr, uid, pick_name, picking, ptype, move, context=context)
res['gift_message'] = picking.gift_message
return res
-
-stock_move()
=== modified file 'product_images_olbs/__openerp__.py'
--- product_images_olbs/__openerp__.py 2012-05-17 12:00:14 +0000
+++ product_images_olbs/__openerp__.py 2012-11-19 23:44:28 +0000
@@ -25,7 +25,7 @@
"description": """
This Module implements an Image Gallery for products.
You can add images against every product.
-
+
This module is generic but built for Magento ERP connector and
the upcoming e-commerce system for Open ERP by Open Labs
""",
=== modified file 'product_images_olbs/company.py'
--- product_images_olbs/company.py 2012-03-08 18:41:21 +0000
+++ product_images_olbs/company.py 2012-11-19 23:44:28 +0000
@@ -18,24 +18,22 @@
#
##############################################################################
-from osv import fields, osv
-from tools.translate import _
+from openerp.osv.orm import Model
+from openerp.osv import fields
-class ResCompany(osv.osv):
+class ResCompany(Model):
"""Override company to add images configuration"""
_inherit = "res.company"
- _columns = {
+ _columns = {
'local_media_repository':fields.char(
- 'Images Repository Path',
+ 'Images Repository Path',
size=256,
help='Local mounted path on OpenERP server where all your images are stored.'
- ),
- }
-
+ ),
+ }
+
def get_local_media_repository(self, cr, uid, id=None, context=None):
if id:
return self.browse(cr, uid, id, context=context).local_media_repository
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.company_id.local_media_repository
-
-ResCompany()
=== modified file 'product_images_olbs/product.py'
--- product_images_olbs/product.py 2012-06-27 10:30:03 +0000
+++ product_images_olbs/product.py 2012-11-19 23:44:28 +0000
@@ -19,13 +19,12 @@
import os
import shutil
import logging
-import unicodedata
import base64, urllib
-from osv import osv,fields
-from tools.translate import _
+from openerp.osv.orm import Model
+from openerp.osv import fields
-class product_product(osv.osv):
+class product_product(Model):
_inherit = "product.product"
def copy(self, cr, uid, id, default=None, context=None):
@@ -108,6 +107,3 @@
}
new_image_id = self.pool.get('product.images').create(cr, uid, data, context=context)
return True
-
-
-product_product()
=== modified file 'product_images_olbs/product_images.py'
--- product_images_olbs/product_images.py 2012-06-27 10:30:03 +0000
+++ product_images_olbs/product_images.py 2012-11-19 23:44:28 +0000
@@ -16,7 +16,9 @@
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-from osv import osv, fields
+from openerp.osv.orm import Model
+from openerp.osv import fields
+from openerp.osv.osv import except_osv
import base64, urllib
from tools.translate import _
import os
@@ -27,7 +29,7 @@
#TODO find a good solution in order to roll back changed done on file system
#TODO add the posibility to move from a store system to an other (example : moving existing image on database to file system)
-class product_images(osv.osv):
+class product_images(Model):
"Products Image gallery"
_name = "product.images"
_description = __doc__
@@ -134,7 +136,7 @@
if not os.path.exists(dir_path):
os.makedirs(dir_path)
except OSError, e:
- raise osv.except_osv(_('Error'), _('The image filestore can not be created, %s'%e))
+ raise except_osv(_('Error'), _('The image filestore can not be created, %s'%e))
return True
def _save_file(self, path, b64_file):
@@ -160,13 +162,10 @@
'url':fields.char('File Location', size=250),
'comments':fields.text('Comments'),
'product_id':fields.many2one('product.product', 'Product')
- }
-
+ }
_defaults = {
'link': lambda *a: False,
- }
-
+ }
_sql_constraints = [('uniq_name_product_id', 'UNIQUE(product_id, name)',
- _('A product can have only one image with the same name'))]
+ _('A product can have only one image with the same name'))]
-product_images()
=== modified file 'product_m2mcategories/product.py'
--- product_m2mcategories/product.py 2009-09-20 23:10:21 +0000
+++ product_m2mcategories/product.py 2012-11-19 23:44:28 +0000
@@ -14,12 +14,12 @@
#You should have received a copy of the GNU General Public License #
#along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-from osv import osv,fields
+from openerp.osv.orm import Model
+from openerp.osv import fields
-class product_product(osv.osv):
+class product_product(Model):
_inherit = "product.template"
_columns = {
'categ_id': fields.many2one('product.category','Pricing/Primary Category', required=True, change_default=True),
'categ_ids': fields.many2many('product.category','product_categ_rel','product_id','categ_id','Product Categories')
- }
-product_product()
+ }
=== modified file 'product_multi_price/__openerp__.py'
--- product_multi_price/__openerp__.py 2012-07-18 07:57:14 +0000
+++ product_multi_price/__openerp__.py 2012-11-19 23:44:28 +0000
@@ -28,9 +28,9 @@
'description': """empty""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
- 'depends': ['product','account', 'sale','product_prices_on_variant'],
+ 'depends': ['product','account', 'sale','product_prices_on_variant'],
'init_xml': [],
- 'update_xml': [
+ 'update_xml': [
'product_price_fields_view.xml',
'product_view.xml',
'product_price_field_config.xml',
=== modified file 'product_multi_price/account.py'
--- product_multi_price/account.py 2012-07-06 09:26:51 +0000
+++ product_multi_price/account.py 2012-11-19 23:44:28 +0000
@@ -19,17 +19,14 @@
# #
###############################################################################
-from osv import osv, fields
-import netsvc
-
-class account_tax(osv.osv):
-
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+class account_tax(Model):
_inherit = 'account.tax'
-
_columns = {
'related_inc_tax_id': fields.many2one('account.tax', 'Related Included Tax'),
- }
-
+ }
# overload def compute all but add a choice for the decimal precision
def compute_all_with_precision(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None, force_excluded=False, precision=None):
@@ -68,4 +65,4 @@
'total': totalex,
'total_included': totalin,
'taxes': tin + tex
- }
+ }
=== modified file 'product_multi_price/product.py'
--- product_multi_price/product.py 2012-09-05 13:40:51 +0000
+++ product_multi_price/product.py 2012-11-19 23:44:28 +0000
@@ -1,4 +1,4 @@
-# -*- encoding: utf-8 -*-
+ # -*- encoding: utf-8 -*-
#################################################################################
# #
# product_multi_price for OpenERP #
@@ -19,16 +19,14 @@
# #
#################################################################################
-from osv import osv, orm, fields
-import netsvc
+from openerp.osv.orm import Model, setup_modifiers
+from openerp.osv.osv import except_osv
from lxml import etree
-import decimal_precision as dp
from tools.translate import _
-class product_product(osv.osv):
-
+class product_product(Model):
_inherit = "product.product"
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
@@ -73,19 +71,19 @@
if btn:
btn = btn[0]
group_ex = etree.Element('group', colspan="2", col="11")
- separator_ex = etree.SubElement(
+ _separator_ex = etree.SubElement(
group_ex,
'separator',
colspan="10",
string="Tax exclude prices")
group_inc = etree.Element('group', colspan="2", col="11")
- separator_inc = etree.SubElement(
+ _separator_inc = etree.SubElement(
group_inc,
'separator',
colspan="10",
string="Tax include prices")
group_sep = etree.Element('group', colspan="2", col="11")
- separator_end = etree.SubElement(
+ _separator_end = etree.SubElement(
group_sep,
'separator',
colspan="11")
@@ -96,7 +94,7 @@
button_parent = group_inc
else:
button_parent = group_ex
- button = etree.SubElement(
+ _button = etree.SubElement(
button_parent,
'button',
colspan="1",
@@ -116,19 +114,24 @@
tax_ex = True
inc_readonly = "1"
ex_readonly = "0"
- label = etree.SubElement(
+ _label = etree.SubElement(
parent,
'label',
colspan="3",
string="%s" % field.name)
- basedon = etree.SubElement(
+ _basedon = etree.SubElement(
parent,
'field',
name="%s" % field.basedon_field_id.name,
colspan="4",
nolabel="1")
+<<<<<<< TREE
orm.setup_modifiers(
basedon, field=result['fields'][field.basedon_field_id.name], context=context)
+=======
+ setup_modifiers(
+ _basedon, field=result['fields'][field.basedon_field_id.name], context=context)
+>>>>>>> MERGE-SOURCE
coef = etree.SubElement(
parent,
'field',
@@ -137,8 +140,9 @@
string="Coef",
colspan="1",
attrs="{'readonly':[('%s','!=','product_coef')]}" % field.basedon_field_id.name)
- orm.setup_modifiers(
- coef, field=result['fields'][field.product_coef_field_id.name], context=context)
+ setup_modifiers(coef,
+ field=result['fields'][field.product_coef_field_id.name],
+ context=context)
price = etree.SubElement(
parent,
'field',
@@ -148,8 +152,9 @@
nolabel="1",
readonly = ex_readonly,
attrs="{'readonly':[('%s','!=','manual')]}" % field.basedon_field_id.name)
- orm.setup_modifiers(
- price, field=result['fields'][field.field_name], context=context)
+ setup_modifiers(price,
+ field=result['fields'][field.field_name],
+ context=context)
inc_price = etree.SubElement(
parent,
'field',
@@ -159,8 +164,9 @@
nolabel="1",
readonly = inc_readonly,
attrs="{'readonly':[('%s','!=','manual')]}" % field.basedon_field_id.name)
- orm.setup_modifiers(
- inc_price, field=result['fields'][field.inc_price_field_id.name], context=context)
+ setup_modifiers(inc_price,
+ field=result['fields'][field.inc_price_field_id.name],
+ context=context)
arch = etree.Element('group', colspan="2", col="11")
if tax_inc:
arch.extend(group_inc)
@@ -268,7 +274,7 @@
if name:
if name == 'list_price':
price_name = 'list_price'
- else:
+ else:
price_name = 'x_pm_price_' + name
tax_inc = False
price_field_ids = prod_price_fields_obj.search(cr, uid, [
@@ -285,7 +291,7 @@
if result['standard_price']:
if tax_inc and result.get('taxes_id'):
if not tax.related_inc_tax_id:
- raise osv.except_osv(_("No related tax"), _("You need to define a related included tax for the sale tax!"))
+ raise except_osv(_("No related tax"), _("You need to define a related included tax for the sale tax!"))
taxes = tax_obj.compute_all_with_precision(cr, uid, [tax.related_inc_tax_id], result['x_pm_inc_price_' + name], 1, precision=6)
result[price_name] = taxes['total']
elif result.get('taxes_id'):
@@ -328,10 +334,9 @@
results = super(product_product, self).read(cr, uid, ids, fields=fields, context=context, load=load)
return results
-product_product()
-
-class product_category(osv.osv):
-
+
+
+class product_category(Model):
_inherit = 'product.category'
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
@@ -345,14 +350,14 @@
if btn:
btn = btn[0]
arch = etree.Element('group', colspan="2", col="2")
- separator = etree.SubElement(
+ _separator = etree.SubElement(
arch,
'separator',
colspan="2",
string="Product price coefficients")
for field in product_price_fields_obj.browse(cr, uid, product_price_fields_ids, context=context):
price_fields.append(field.categ_coef_field_id.name)
- coef = etree.SubElement(
+ _coef = etree.SubElement(
arch,
'field',
digits="(18, 6)",
=== modified file 'product_multi_price/product_price_fields.py'
--- product_multi_price/product_price_fields.py 2012-09-05 13:40:51 +0000
+++ product_multi_price/product_price_fields.py 2012-11-19 23:44:28 +0000
@@ -19,19 +19,17 @@
# #
#################################################################################
-from osv import osv, fields
-import netsvc
+from openerp.osv.orm import Model
+from openerp.osv import fields
+from openerp.osv.osv import except_osv
from tools.translate import _
-import decimal_precision as dp
#TODO
-class product_price_fields(osv.osv):
-
+class product_price_fields(Model):
_name = "product.price.fields"
_description = "product price fields"
-
_columns = {
'name': fields.related('price_field_id', 'field_description', type='char', size=64, string='Field Label', store=True),
'field_name': fields.related('price_field_id', 'name', type='char', size=64, string='Field Name', store=True, help ="you can chose the field name by default it will be build with the name of the field replacing the space by '_' and adding x_pm_ add the start"),
@@ -44,7 +42,7 @@
'default_basedon':fields.selection([('categ_coef','Price on category coefficient'),('product_coef','Price on product coefficient'),('manual','Manual price')], 'Based on by default', required=True),
'currency_id': fields.many2one('res.currency', "Currency", required=True, help="The currency the field is expressed in."),
'inc_price_field_id' : fields.many2one('ir.model.fields', 'Price Included Field ID', domain = [('model', '=', 'product.product'), ('ttype', '=', 'float')]),
- }
+ }
def _get_currency(self, cr, uid, ctx):
comp = self.pool.get('res.users').browse(cr, uid, uid).company_id
@@ -119,7 +117,7 @@
print 'field name'
exist_id = self.pool.get('ir.model.fields').search(cr, uid, [('name', '=', vals['field_name'])])
if not exist_id and vals['field_name'][0:2] != 'x_':
- raise osv.except_osv(_('User Error'), _("Please prefix the name field by x_ as it's a custom field"))
+ raise except_osv(_('User Error'), _("Please prefix the name field by x_ as it's a custom field"))
field_list = ['price', 'inc_price', 'basedon','product_coef','categ_coef']
product_ids = self.pool.get('product.product').search(cr, uid, [], context=context)
for field in field_list:
@@ -170,6 +168,3 @@
price_field.product_coef_field_id.unlink()
price_field.categ_coef_field_id.unlink()
return super(product_price_fields, self).unlink(cr, uid, ids, context=context)
-
-product_price_fields()
-
=== added directory 'product_price_tax_inc_exc'
=== added file 'product_price_tax_inc_exc/__init__.py'
--- product_price_tax_inc_exc/__init__.py 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/__init__.py 2012-11-19 23:44:28 +0000
@@ -0,0 +1,25 @@
+# -*- encoding: utf-8 -*-
+###############################################################################
+#
+# product_price_tax_inc_exc for OpenERP
+# Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>. All Rights Reserved
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+import sale
+import pricelist
+import account
+import invoice
=== added file 'product_price_tax_inc_exc/__openerp__.py'
--- product_price_tax_inc_exc/__openerp__.py 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/__openerp__.py 2012-11-19 23:44:28 +0000
@@ -0,0 +1,42 @@
+# -*- encoding: utf-8 -*-
+###############################################################################
+#
+# product_price_tax_inc_exc for OpenERP
+# Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>. All Rights Reserved
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+{
+ 'name': 'product_price_tax_inc_exc',
+ 'version': '0.1',
+ 'category': 'Generic Modules/Others',
+ 'license': 'AGPL-3',
+ 'description': """empty""",
+ 'author': 'Akretion',
+ 'website': 'http://www.akretion.com/',
+ 'depends': ['product_multi_price'],
+ 'init_xml': [],
+ 'update_xml': [
+ 'sale_view.xml',
+ 'pricelist_view.xml',
+ 'account_view.xml',
+ 'invoice_view.xml',
+ ],
+ 'demo_xml': [],
+ 'installable': True,
+ 'active': False,
+}
+
=== added file 'product_price_tax_inc_exc/account.py'
--- product_price_tax_inc_exc/account.py 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/account.py 2012-11-19 23:44:28 +0000
@@ -0,0 +1,40 @@
+ # -*- encoding: utf-8 -*-
+###############################################################################
+#
+# product_price_tax_inc_exc for OpenERP
+# Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>.
+# All Rights Reserved
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+from openerp.osv import fields
+from openerp.osv.orm import Model
+
+class account_fiscal_position(Model):
+ _inherit = 'account.fiscal.position'
+ _columns = {
+ 'pricelist_compatibility': fields.selection([
+ ('tax-inc', 'Tax Inc'),
+ ('tax-exc', 'Tax Exc'),
+ ('both', 'Both'),
+ ], 'Pricelist Compatibility',
+ help=("Choose the kind of pricelist compatible"
+ "with the fiscal position")),
+ }
+
+ _defaults = {
+ 'pricelist_compatibility': 'tax-exc',
+ }
=== added file 'product_price_tax_inc_exc/account_view.xml'
--- product_price_tax_inc_exc/account_view.xml 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/account_view.xml 2012-11-19 23:44:28 +0000
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ product_price_tax_inc_exc for OpenERP
+ Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+ The licence is in the file __openerp__.py
+-->
+
+<openerp>
+ <data>
+ <!-- INHERITED VIEW FOR THE OBJECT : sale_order -->
+
+ <record id="view_account_position_form" model="ir.ui.view">
+ <field name="name">product_price_tax_inc_exc.view_account_position_form</field>
+ <field name="model">account.fiscal.position</field>
+ <field name="inherit_id" ref="account.view_account_position_form" />
+ <field eval="16" name="priority"/>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <field name="active" position="after">
+ <field name="is_tax_inc"/>
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
=== added file 'product_price_tax_inc_exc/invoice.py'
--- product_price_tax_inc_exc/invoice.py 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/invoice.py 2012-11-19 23:44:28 +0000
@@ -0,0 +1,122 @@
+# -*- encoding: utf-8 -*-
+###############################################################################
+#
+# product_price_tax_inc_exc for OpenERP
+# Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>. All Rights Reserved
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+from openerp.osv import fields
+from openerp.osv.orm import Model
+import decimal_precision as dp
+
+
+#class account_invoice(Model):
+# _inherit = "account.invoice"
+
+# _columns = {
+# 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
+# }
+
+# def pricelist_id_change(self, cr, uid, ids, pricelist_id):
+
+# if self.pool.get('product.pricelist').read(cr, uid, pricelist_id, ['is_tax_inc'])['is_tax_inc']:
+# res = {
+# 'value': {'fiscal_position' : False},
+# 'domain': {'fiscal_position': [['pricelist_compatibility', "in", ['tax-inc', 'both']]]},
+# }
+# else:
+# res = {
+# 'value': {'fiscal_position' : False},
+# 'domain': {'fiscal_position': [['pricelist_compatibility', "in", ['tax-exc', 'both']]]},
+# }
+# return res
+
+class account_invoice_line(Model):
+ _inherit = "account.invoice.line"
+
+ def _amount_line_tax_inc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ tax_obj = self.pool.get('account.tax')
+ cur_obj = self.pool.get('res.currency')
+ for line in self.browse(cr, uid, ids):
+ price = line.price_unit * (1-(line.discount or 0.0)/100.0)
+ taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, address_id=line.invoice_id.address_invoice_id, partner=line.invoice_id.partner_id)
+ res[line.id] = taxes['total_included']
+ if line.invoice_id:
+ cur = line.invoice_id.currency_id
+ res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
+ return res
+
+ _columns = {
+ 'sub_total_tax_inc' : fields.function(_amount_line_tax_inc, method=True, digits_compute= dp.get_precision('Sale Price'), string='Sub-Total Tax Inc'),
+ }
+
+# def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='',
+# type='out_invoice', partner_id=False, fposition_id=False,
+# price_unit=False, address_invoice_id=False, currency_id=False,
+# context=None, company_id=None, pricelist_id=None):
+
+# res = super(account_invoice_line, self).product_id_change(cr, uid,
+# ids, product, uom, qty=qty, name=name,type=type,
+# partner_id=partner_id, fposition_id=fposition_id,
+# price_unit=price_unit, address_invoice_id=address_invoice_id,
+# currency_id=currency_id, context=context,
+# company_id=company_id)
+# if pricelist_id:
+# pricelist = self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context)
+# if pricelist.is_tax_inc and res.get('value', {}).get('tax_id'):
+# tax_ids = []
+# for tax in self.pool.get('account.tax').browse(cr, uid, res['value']['tax_id'], context=context):
+# tax_ids.append(tax.related_inc_tax_id.id or tax.id)
+# res['value']['tax_id'] = tax_ids
+# return res
+
+
+#TODO keep it commented for now, maybe we will use it latter
+#class account_invoice_line(Model):
+# _inherit = "account.invoice.line"
+#
+# def _amount_line_tax_inc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+# res = {}
+# tax_obj = self.pool.get('account.tax')
+# cur_obj = self.pool.get('res.currency')
+# for line in self.browse(cr, uid, ids):
+# price = line.price_unit * (1-(line.discount or 0.0)/100.0)
+# taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, address_id=line.invoice_id.address_invoice_id, partner=line.invoice_id.partner_id)
+# res[line.id] = taxes['total_included']
+# if line.invoice_id:
+# cur = line.invoice_id.currency_id
+# res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
+# return res
+
+# def _get_amount_line_tax(self, cr, uid, ids, field_name, arg, context=None):
+# invoice_obj = self.pool.get('account.invoice')
+# tax_obj = self.pool.get('account.tax')
+# res = {}
+# for line in self.browse(cr, uid, ids, context=context):
+# if line.invoice_line_tax_id:
+# res2 = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, line.price_unit, 1, product=line.product_id, address_id=line.invoice_id.address_invoice_id, partner=line.invoice_id.partner_id)
+# res[line.id] = {'price_unit_tax_exc' : res2['total'], 'price_unit_tax_inc' : res2['total_included']}
+# else:
+# res[line.id] = {'price_unit_tax_exc' : line.price_unit, 'price_unit_tax_inc' : line.price_unit}
+# return res
+#
+# _columns = {
+# 'sub_total_tax_inc' : fields.function(_amount_line_tax_inc, method=True, digits_compute= dp.get_precision('Sale Price'), string='Sub-Total Tax Inc'),
+# 'price_unit_tax_exc' : fields.function(_get_amount_line_tax, method=True, digits_compute= dp.get_precision('Sale Price'), string='Unit Price Tax Exc', multi='tax_val'),
+# 'price_unit_tax_inc' : fields.function(_get_amount_line_tax, method=True, digits_compute= dp.get_precision('Sale Price'), string='Unit Price Tax Inc', multi='tax_val'),
+# }
=== added file 'product_price_tax_inc_exc/invoice_view.xml'
--- product_price_tax_inc_exc/invoice_view.xml 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/invoice_view.xml 2012-11-19 23:44:28 +0000
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ product_price_tax_inc_exc for OpenERP
+ Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+ The licence is in the file __openerp__.py
+-->
+
+<openerp>
+ <data>
+ <!-- INHERITED VIEW FOR THE OBJECT : account_invoice -->
+
+ <record id="product_price_tax_inc_exc_account_invoice_view_form" model="ir.ui.view">
+ <field name="name">product_price_tax_inc_exc.account_invoice.view_form</field>
+ <field name="model">account.invoice.line</field>
+ <field name="inherit_id" ref="account.view_invoice_line_tree" />
+ <field eval="16" name="priority"/>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <!--
+ <field name="price_unit" position="after">
+ <field name="price_unit_tax_exc"/>
+ <field name="price_unit_tax_inc"/>
+ </field>
+ -->
+ <field name="price_subtotal" position="after">
+ <field name="sub_total_tax_inc"/>
+ </field>
+ </field>
+ </record>
+
+<!--
+ <record id="invoice_form" model="ir.ui.view">
+ <field name="name">product_price_tax_inc_exc.invoice_form</field>
+ <field name="model">account.invoice</field>
+ <field name="inherit_id" ref="account.invoice_form" />
+ <field eval="100" name="priority"/>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <field name="fiscal_position" position="replace">
+ <field name="pricelist_id" on_change="pricelist_id_change(pricelist_id)"/>
+ <field name="fiscal_position"/>
+ </field>
+ </field>
+ </record>
+
+ <record id="view_invoice_line_form" model="ir.ui.view">
+ <field name="name">account.invoice.line.form</field>
+ <field name="model">account.invoice.line</field>
+ <field name="inherit_id" ref="account.view_invoice_line_form" />
+ <field name="type">form</field>
+ <field eval="100" name="priority"/>
+ <field name="arch" type="xml">
+ <field name="product_id" position="attributes">
+ <attribute name="on_change">product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, context, parent.company_id, parent.pricelist_id)
+ </attribute>
+ </field>
+ </field>
+ </record>
+-->
+
+ </data>
+</openerp>
=== added file 'product_price_tax_inc_exc/pricelist.py'
--- product_price_tax_inc_exc/pricelist.py 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/pricelist.py 2012-11-19 23:44:28 +0000
@@ -0,0 +1,30 @@
+# -*- encoding: utf-8 -*-
+###############################################################################
+#
+# product_price_tax_inc_exc for OpenERP
+# Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>. All Rights Reserved
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+from openerp.osv import fields
+from openerp.osv.orm import Model
+
+class product_pricelist(Model):
+ _inherit = "product.pricelist"
+
+ _columns = {
+ 'is_tax_inc': fields.boolean('Is Tax Inc'),
+ }
=== added file 'product_price_tax_inc_exc/pricelist_view.xml'
--- product_price_tax_inc_exc/pricelist_view.xml 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/pricelist_view.xml 2012-11-19 23:44:28 +0000
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ product_price_tax_inc_exc for OpenERP
+ Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+ The licence is in the file __openerp__.py
+-->
+
+<openerp>
+ <data>
+ <!-- INHERITED VIEW FOR THE OBJECT : product_pricelist -->
+
+ <record id="product_price_tax_inc_exc_product_pricelist_view_form" model="ir.ui.view">
+ <field name="name">product_price_tax_inc_exc.product_pricelist.view_form</field>
+ <field name="model">product.pricelist</field>
+ <field name="inherit_id" ref="product.product_pricelist_view" />
+ <field eval="16" name="priority"/>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <field name="active" position="after">
+ <field name="is_tax_inc" />
+ </field>
+ </field>
+ </record>
+
+ <record id="product_price_tax_inc_exc_product_pricelist_view_tree" model="ir.ui.view">
+ <field name="name">product_price_tax_inc_exc.product_pricelist.view_tree</field>
+ <field name="model">product.pricelist</field>
+ <field name="inherit_id" ref="product.product_pricelist_view_tree" />
+ <field eval="16" name="priority"/>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <field name="active" position="after">
+ <field name="is_tax_inc" />
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
=== added file 'product_price_tax_inc_exc/sale.py'
--- product_price_tax_inc_exc/sale.py 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/sale.py 2012-11-19 23:44:28 +0000
@@ -0,0 +1,96 @@
+# -*- encoding: utf-8 -*-
+###############################################################################
+#
+# product_price_tax_inc_exc for OpenERP
+# Copyright (C) 2011-TODAY Akretion <http://www.akretion.com>. All Rights Reserved
+# @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+from openerp.osv import fields
+from openerp.osv.orm import Model
+import decimal_precision as dp
+
+class sale_order(Model):
+ _inherit = "sale.order"
+
+ def pricelist_id_change(self, cr, uid, ids, pricelist_id):
+ if self.pool.get('product.pricelist').read(cr, uid, pricelist_id, ['is_tax_inc'])['is_tax_inc']:
+ res = {
+ 'value': {'fiscal_position' : False},
+ 'domain': {'fiscal_position': [['pricelist_compatibility', "in", ['tax-inc', 'both']]]},
+ }
+ else:
+ res = {
+ 'value': {'fiscal_position' : False},
+ 'domain': {'fiscal_position': [['pricelist_compatibility', "in", ['tax-exc', 'both']]]},
+ }
+ return res
+
+# def _prepare_invoice(self, cr, uid, order, lines, context=None):
+# result = super(sale_order, self)._prepare_invoice(cr, uid, order, lines, context=context)
+# result['pricelist_id'] = order.pricelist_id.id
+# return result
+
+
+class sale_order_line(Model):
+ _inherit = "sale.order.line"
+
+ def _get_amount_line_tax(self, cr, uid, ids, field_name, arg, context=None):
+ order_obj = self.pool.get('sale.order')
+ tax_obj = self.pool.get('account.tax')
+ res = {}
+ for line in self.browse(cr, uid, ids, context=context):
+ amount_tax_line = order_obj._amount_line_tax(cr, uid, line, context=None)
+ res[line.id] = amount_tax_line + line.price_subtotal
+ return res
+
+ _columns = {
+ 'sub_total_tax_inc' : fields.function(_get_amount_line_tax, method=True, digits_compute= dp.get_precision('Sale Price'), string='Sub-Total Tax Inc'),
+ }
+
+ def product_id_change(self, cr, uid, ids, pricelist_id, *args, **kwargs):
+ res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist_id, *args, **kwargs)
+ context = kwargs.get('context')
+ pricelist = self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context)
+ if pricelist.is_tax_inc and res.get('value', {}).get('tax_id'):
+ tax_ids = []
+ for tax in self.pool.get('account.tax').browse(cr, uid, res['value']['tax_id'], context=context):
+ tax_ids.append(tax.related_inc_tax_id.id or tax.id)
+ res['value']['tax_id'] = tax_ids
+ return res
+
+#TODO keep it commented for now, maybe we will use it latter
+
+# def _get_amount_line_tax(self, cr, uid, ids, field_name, arg, context=None):
+# order_obj = self.pool.get('sale.order')
+# tax_obj = self.pool.get('account.tax')
+# res = {}
+# for line in self.browse(cr, uid, ids, context=context):
+# res[line.id] = {'amount_tax_line' : order_obj._amount_line_tax(cr, uid, line, context=None)}
+# res[line.id]['sub_total_tax_inc'] = res[line.id]['amount_tax_line'] + line.price_subtotal
+# if line.tax_id:
+# res2 = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, 1, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
+# print 'res2', res2
+# res[line.id]['price_unit_tax_exc'] = res2['total']
+# res[line.id]['price_unit_tax_inc'] = res2['total_included']
+# return res
+#
+# _columns = {
+# 'amount_tax_line' : fields.function(_get_amount_line_tax, method=True, digits_compute= dp.get_precision('Sale Price'), string='Taxes Amount', multi='tax_val'),
+# 'sub_total_tax_inc' : fields.function(_get_amount_line_tax, method=True, digits_compute= dp.get_precision('Sale Price'), string='Sub-Total Tax Inc', multi='tax_val'),
+# 'price_unit_tax_exc' : fields.function(_get_amount_line_tax, method=True, digits_compute= dp.get_precision('Sale Price'), string='Unit Price Tax Exc', multi='tax_val'),
+# 'price_unit_tax_inc' : fields.function(_get_amount_line_tax, method=True, digits_compute= dp.get_precision('Sale Price'), string='Unit Price Tax Inc', multi='tax_val'),
+# }
=== added file 'product_price_tax_inc_exc/sale_view.xml'
--- product_price_tax_inc_exc/sale_view.xml 1970-01-01 00:00:00 +0000
+++ product_price_tax_inc_exc/sale_view.xml 2012-11-19 23:44:28 +0000
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ product_price_tax_inc_exc for OpenERP
+ Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+ The licence is in the file __openerp__.py
+-->
+
+<openerp>
+ <data>
+ <!-- INHERITED VIEW FOR THE OBJECT : sale_order -->
+
+ <record id="product_price_tax_inc_exc_sale_order_view_form" model="ir.ui.view">
+ <field name="name">product_price_tax_inc_exc.sale_order.view_form</field>
+ <field name="model">sale.order</field>
+ <field name="inherit_id" ref="sale.view_order_form" />
+ <field eval="16" name="priority"/>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+
+
+ <field name="fiscal_position" position="replace">
+ </field>
+
+ <field name="pricelist_id" position="attributes">
+ <attribute name="on_change">pricelist_id_change(pricelist_id)</attribute>
+ </field>
+
+ <field name="pricelist_id" position="after">
+ <field name="fiscal_position"/>
+ </field>
+
+ <field name="price_subtotal" position="after">
+ <field name="sub_total_tax_inc"/>
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
=== modified file 'product_prices_on_variant/__openerp__.py'
--- product_prices_on_variant/__openerp__.py 2012-07-18 07:55:31 +0000
+++ product_prices_on_variant/__openerp__.py 2012-11-19 23:44:28 +0000
@@ -29,9 +29,9 @@
'description': """empty""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
- 'depends': ['product'],
+ 'depends': ['product'],
'init_xml': [],
- 'update_xml': [
+ 'update_xml': [
],
'demo_xml': [],
'installable': True,
=== modified file 'product_prices_on_variant/product.py'
--- product_prices_on_variant/product.py 2012-07-18 07:55:31 +0000
+++ product_prices_on_variant/product.py 2012-11-19 23:44:28 +0000
@@ -19,24 +19,26 @@
# #
###############################################################################
-from osv import osv, fields
-import netsvc
+from openerp.osv.orm import Model
+from openerp.osv import fields
import decimal_precision as dp
-class product_product(osv.osv):
-
+class product_product(Model):
_inherit = "product.product"
-
-
_columns = {
- 'list_price': fields.float('Sale Price', digits_compute=dp.get_precision('Sale Price'), help="Base price for computing the customer price. Sometimes called the catalog price."),
- 'standard_price': fields.float('Cost Price', required=True, digits_compute=dp.get_precision('Purchase Price'), help="Product's cost for accounting stock valuation. It is the base price for the supplier price."),
- }
-
+ 'list_price': fields.float('Sale Price',
+ digits_compute=dp.get_precision('Sale Price'),
+ help="Base price for computing the customer price. "
+ "Sometimes called the catalog price."),
+ 'standard_price': fields.float('Cost Price', required=True,
+ digits_compute=dp.get_precision('Purchase Price'),
+ help="Product's cost for accounting stock valuation. "
+ "It is the base price for the supplier price."),
+ }
_defaults = {
'list_price': lambda *a: 1,
'standard_price': lambda *a: 1,
- }
+ }
=== modified file 'product_quick_stock_rule/__openerp__.py'
--- product_quick_stock_rule/__openerp__.py 2012-05-21 12:59:56 +0000
+++ product_quick_stock_rule/__openerp__.py 2012-11-19 23:44:28 +0000
@@ -29,16 +29,16 @@
'description': """
This module simplifie the stock rule managment.
Two field have been had on product view : 'active_rule' and 'min_qty'
- If you click on 'active rule' and select a 'min_qty' a stock rule will be automatically
+ If you click on 'active rule' and select a 'min_qty' a stock rule will be automatically
generated.
If you unselect the 'active rule' the rule will be unactive.
And the field min qty will be in readonly.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
- 'depends': ['procurement'],
+ 'depends': ['procurement'],
'init_xml': [],
- 'update_xml': [
+ 'update_xml': [
'product_view.xml',
],
'demo_xml': [],
=== modified file 'product_quick_stock_rule/product.py'
--- product_quick_stock_rule/product.py 2012-05-21 13:55:05 +0000
+++ product_quick_stock_rule/product.py 2012-11-19 23:44:28 +0000
@@ -19,18 +19,18 @@
# #
###############################################################################
-from osv import osv, fields
-import netsvc
-
-
-class product_product(osv.osv):
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+
+class product_product(Model):
_inherit = "product.product"
def _get_min_stock(self, cr, uid, ids, field_name, arg, context=None):
orderpoint_obj = self.pool.get('stock.warehouse.orderpoint')
res={}
for product_id in ids:
- op_ids = orderpoint_obj.search(cr, uid, ['|', ('active', '=', False),
+ op_ids = orderpoint_obj.search(cr, uid, ['|', ('active', '=', False),
('active', '=', True), ('product_id', '=', product_id)], context=context)
if op_ids:
op = orderpoint_obj.browse(cr, uid, op_ids[0], context=context)
@@ -70,7 +70,7 @@
def _set_rule_status(self, cr, uid, product_id, name, value, arg, context=None):
orderpoint_obj = self.pool.get('stock.warehouse.orderpoint')
- op_ids = orderpoint_obj.search(cr, uid, ['|', ('active', '=', False),
+ op_ids = orderpoint_obj.search(cr, uid, ['|', ('active', '=', False),
('active', '=', True), ('product_id', '=', product_id)], context=context)
if op_ids:
orderpoint_obj.write(cr, uid, op_ids[0], {'active': value}, context=context)
@@ -79,22 +79,20 @@
orderpoint_obj.create(cr, uid, vals, context=context)
return True
-
_columns = {
'active_rule': fields.function(_get_rule_status, fnct_inv =_set_rule_status, type='boolean', string='Active Rule'),
'qty_min': fields.function(_get_min_stock, fnct_inv =_set_min_stock, type='float', string='Minimal Stock'),
- }
-
-
-class stock_warehouse_orderpoint(osv.osv):
+ }
+
+
+class stock_warehouse_orderpoint(Model):
"""
Defines Minimum stock rules.
"""
_inherit = "stock.warehouse.orderpoint"
-
_columns = {
'sequence': fields.integer('Sequence', require=True),
- }
+ }
def _get_default_warehouse(self, cr, uid, context=None):
warehouse_ids = self.pool.get('stock.warehouse').search(cr, uid, [], context=context)
@@ -115,4 +113,4 @@
'warehouse_id': _get_default_warehouse,
'product_max_qty': 0,
'sequence': 0,
- }
+ }
=== modified file 'product_sequence/product_product.py'
--- product_sequence/product_product.py 2012-07-06 10:11:58 +0000
+++ product_sequence/product_product.py 2012-11-19 23:44:28 +0000
@@ -19,23 +19,21 @@
#
##############################################################################
-from osv import osv, fields
-from tools.translate import _
+from openerp.osv.orm import Model
+from openerp.osv import fields
+from openerp.tools.translate import _
-class product_product(osv.osv):
+class product_product(Model):
_inherit = 'product.product'
-
_columns = {
'default_code' : fields.char('Reference', size=64, required=True),
- }
-
+ }
_sql_constraints = [
('uniq_default_code', 'unique(default_code)', "The reference must be unique"),
- ]
-
+ ]
_defaults = {
'default_code': lambda * a: '/',
- }
+ }
def create(self, cr, uid, vals, context=None):
if context is None:
@@ -45,6 +43,8 @@
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)
@@ -63,5 +63,3 @@
})
return super(product_product, self).copy(cr, uid, id, default, context)
-
-product_product()