From d85563ca55dfbdc96862fe04128a04392333c268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 16 Mar 2012 12:39:35 +0100 Subject: [PATCH] New product types: Goods, Assets and Service review260001 --- CHANGELOG | 1 + product.py | 19 ++++++++++++++++--- product.xml | 11 ++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ace5261857..fe7c7ee3a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* New product types: Goods, Assets and Service * Category is no more required on product Version 2.2.0 - 2011-10-24 diff --git a/product.py b/product.py index 0e9b9c607e..112d058f92 100644 --- a/product.py +++ b/product.py @@ -20,10 +20,16 @@ class Template(ModelSQL, ModelView): name = fields.Char('Name', size=None, required=True, translate=True, select=True, states=STATES, depends=DEPENDS) type = fields.Selection([ - ('stockable', 'Stockable'), - ('consumable', 'Consumable'), + ('goods', 'Goods'), + ('assets', 'Assets'), ('service', 'Service') ], 'Type', required=True, states=STATES, depends=DEPENDS) + consumable = fields.Boolean('Consumable', + states={ + 'readonly': ~Eval('active', True), + 'invisible': Eval('type', 'goods') != 'goods', + }, + depends=['active', 'type']) category = fields.Many2One('product.category', 'Category', states=STATES, depends=DEPENDS) list_price = fields.Property(fields.Numeric('List Price', states=STATES, @@ -54,11 +60,18 @@ class Template(ModelSQL, ModelView): # Migration from 2.2: category is no more required table.not_null_action('category', 'remove') + # Migration from 2.2: new types + cursor.execute('UPDATE "' + self._table + '" ' + 'SET consumable = %s WHERE type = %s', (True, 'consumable')) + cursor.execute('UPDATE "' + self._table + '" ' + 'SET type = %s WHERE type IN (%s, %s)', + ('goods', 'stockable', 'consumable')) + def default_active(self): return True def default_type(self): - return 'stockable' + return 'goods' def default_cost_price_method(self): return 'fixed' diff --git a/product.xml b/product.xml index 4231cab091..f726a0a897 100644 --- a/product.xml +++ b/product.xml @@ -46,16 +46,17 @@ this repository contains the full copyright notices and license terms. --> form +