diff --git a/classification.py b/classification.py index be22375..fff70fc 100644 --- a/classification.py +++ b/classification.py @@ -48,8 +48,8 @@ def _check_code(self, cr, uid, ids, context=None): if len(rec.code) != 8: return False try: - code = int(rec.code) - except: + int(rec.code) + except ValueError: return False return True @@ -57,6 +57,28 @@ def _check_code(self, cr, uid, ids, context=None): (_check_code, 'Error: Code must have 8 digits only', ['code']), ] + _sql_constraints = [ + ('code_unique', 'UNIQUE (code)', 'The UNSPSC code must be unique !'), + ] + + +class UnitedNationsUOM(orm.Model): + _name = 'product.uom.un' + _description = 'United Nations UOM' + + _columns = { + 'name': fields.char('Name', size=256, translate=True), + 'code': fields.char('Code', size=64, help='Common code'), + 'description': fields.text('Description', translate=True), + 'symbol': fields.char('Symbol', size=64, help='Symbole of the uom'), + 'factor': fields.char( + 'Conversion Factor', size=128, + help='Conversion factor'), + } + + _sql_constraints = [ + ('code_unique', 'UNIQUE (code)', 'The UNSPSC code must be unique !'), + ] # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/classification_view.xml b/classification_view.xml index 9c65423..1c34e45 100644 --- a/classification_view.xml +++ b/classification_view.xml @@ -24,6 +24,10 @@ # ############################################################################## + + + + product.category.unspsc.tree product.category.unspsc @@ -94,5 +98,86 @@ sequence="20" action="act_open_product_category_unspsc_view"/> + + + + + product.uom.un.tree + product.uom.un + tree + + + + + + + + + + + + + product.uom.un.form + product.uom.un + form + + +
+ + + + + + + + +
+ + + product.uom.un.search + product.uom.un + search + + + + + + + + + + + + + + UNUOM + ir.actions.act_window + product.uom.un + form + tree,form + + [] + {} + + + + + + form + + + + + + + tree + + + + + diff --git a/data/README.rst b/data/README.rst index 0637c54..ccb9cc7 100644 --- a/data/README.rst +++ b/data/README.rst @@ -2,6 +2,17 @@ This folder contains file to import manually Use PostgreSQL COPY command to import the files +UNSPSC +------ + Usage:: copy product_category_unspsc (code, name) from 'unspsc-computers.csv' WITH DELIMITER ';'; + + +UNUOM +----- + +Download Recommendation No. 20 (Codes for Units of Measure used in International Trade) to find how unit of measure is organized. + + diff --git a/data/unuom-level-1-normative-units.csv b/data/unuom-level-1-normative-units.csv new file mode 100644 index 0000000..624bfea --- /dev/null +++ b/data/unuom-level-1-normative-units.csv @@ -0,0 +1,30 @@ +KEL;kelvin;Refer ISO 80000-5 (Quantities and units — Part 5: Thermodynamics);K;K +KGM;kilogram;A unit of mass equal to one thousand grams.;kg;kg +KGS;kilogram per second;;kg/s;kg/s +KL;kilogram per metre;;kg/m;kg/m +KMQ;kilogram per cubic metre;A unit of weight expressed in kilograms of a substance that fills a volume of one cubic metre.;kg/m³;kg/m³ +KNT;knot;;kn;0,514 444 m/s +LTR;litre;;l;10⁻³ m³ +LUM;lumen;;lm;cd x sr +LUX;lux;;lx;cd x sr / m² +MIN;minute [unit of time];;min;60 s +MQS;cubic metre per second;;m³/s;m³/s +MSK;metre per second squared;;m/s²;m/s² +MTK;square metre;;m²;m² +MTQ;cubic metre;Synonym: metre cubed;m³;m³ +MTR;metre;;m;m +MTS;metre per second;;m/s;m/s +NEW;newton;;N;(kg x m)/s² +NMI;nautical mile;;n mile;1 852 m +NU;newton metre;;N·m;N x m +OHM;ohm;;Ω;Ω +PAL;pascal;;Pa;Pa +RPM;revolutions per minute;Refer ISO/TC12 SI Guide;r/min;1,67 x 10⁻²/s +RPS;revolutions per second;Refer ISO/TC12 SI Guide;r/s;1/s +S4;square metre per second;Synonym: metre squared per second (square metres/second US);m²/s;m²/s +SEC;second [unit of time];;s;s +SIE;siemens;;S;A/V +VLT;volt;;V;V +WEB;weber;;Wb;Wb +WHR;watt hour;;W·h;3,6 x 10³ J +WTT;watt;;W;W diff --git a/product.py b/product.py index c42c522..7092c98 100644 --- a/product.py +++ b/product.py @@ -36,6 +36,16 @@ class ProductCategory(orm.Model): } +class ProductUOM(orm.Model): + _inherit = 'product.uom' + + _columns = { + 'unuom_id': fields.many2one( + 'product.uom.un', 'UNUOM', + help='Link current UOM to the UNUOM reference'), + } + + class Product(orm.Model): _inherit = 'product.product' diff --git a/product_view.xml b/product_view.xml index 9ab787d..826a340 100644 --- a/product_view.xml +++ b/product_view.xml @@ -38,11 +38,16 @@
+ + + + + product.category.form product.category - + @@ -51,5 +56,20 @@ + + + + + product.uom.form + product.uom + + + + + + + + + diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index cc2dffe..eda32a9 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -4,3 +4,5 @@ access_product_catalog,access_product_catalog,model_product_catalog,group_produc access_product_catalog_user,access_product_catalog_user,model_product_catalog,group_product_catalog_manager,1,1,1,1 access_product_category_unspsc,access_product_category_unspsc,model_product_category_unspsc,,1,0,0,0 access_product_category_unspsc_manager,access_product_category_unspsc_manager,model_product_category_unspsc,group_product_catalog_manager,1,1,1,1 +access_product_uom_un,access_product_uom_un,model_product_uom_un,,1,0,0,0 +access_product_uom_un,access_product_uom_un,model_product_uom_un,group_product_catalog_manager,1,1,1,1