llx_product.sql 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. -- ============================================================================
  2. -- Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. -- Copyright (C) 2008-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  4. -- Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
  5. -- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  6. -- Copyright (C) 2012-2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  7. -- Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  8. --
  9. -- This program is free software; you can redistribute it and/or modify
  10. -- it under the terms of the GNU General Public License as published by
  11. -- the Free Software Foundation; either version 3 of the License, or
  12. -- (at your option) any later version.
  13. --
  14. -- This program is distributed in the hope that it will be useful,
  15. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. -- GNU General Public License for more details.
  18. --
  19. -- You should have received a copy of the GNU General Public License
  20. -- along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. --
  22. -- ============================================================================
  23. create table llx_product
  24. (
  25. rowid integer AUTO_INCREMENT PRIMARY KEY,
  26. ref varchar(128) NOT NULL,
  27. entity integer DEFAULT 1 NOT NULL, -- Multi company id
  28. ref_ext varchar(128), -- reference into an external system (not used by dolibarr)
  29. datec datetime,
  30. tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  31. fk_parent integer DEFAULT 0, -- Not used. Used by external modules. Virtual product id
  32. label varchar(255) NOT NULL,
  33. description text,
  34. note_public text,
  35. note text,
  36. customcode varchar(32), -- Optionnal custom code
  37. fk_country integer DEFAULT NULL, -- Optionnal id of original country
  38. fk_state integer DEFAULT NULL, -- Optionnal id of original state/province
  39. price double(24,8) DEFAULT 0, -- price without tax
  40. price_ttc double(24,8) DEFAULT 0, -- price inc vat (but not localtax1 nor localtax2)
  41. price_min double(24,8) DEFAULT 0,
  42. price_min_ttc double(24,8) DEFAULT 0,
  43. price_base_type varchar(3) DEFAULT 'HT',
  44. cost_price double(24,8) DEFAULT NULL, -- Cost price without tax. Can be used for margin calculation.
  45. default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product.
  46. tva_tx double(7,4), -- Default VAT rate of product
  47. recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT
  48. localtax1_tx double(7,4) DEFAULT 0,
  49. localtax1_type varchar(10) NOT NULL DEFAULT '0',
  50. localtax2_tx double(7,4) DEFAULT 0,
  51. localtax2_type varchar(10) NOT NULL DEFAULT '0',
  52. fk_user_author integer DEFAULT NULL, -- user making creation
  53. fk_user_modif integer, -- user making last change
  54. tosell tinyint DEFAULT 1, -- Product you sell
  55. tobuy tinyint DEFAULT 1, -- Product you buy
  56. onportal tinyint DEFAULT 0, -- If it is a product you sell and you want to sell it from internal portal (module 'portal')
  57. tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch management (eat-by or lot management)
  58. sell_or_eat_by_mandatory tinyint DEFAULT 0 NOT NULL, -- Make sell-by or eat-by date mandatory
  59. batch_mask varchar(32) DEFAULT NULL, -- If the product has batch feature, you may want to use a batch mask per product
  60. fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module)
  61. duration varchar(6),
  62. seuil_stock_alerte float DEFAULT NULL,
  63. url varchar(255),
  64. barcode varchar(180) DEFAULT NULL, -- barcode
  65. fk_barcode_type integer DEFAULT NULL, -- barcode type
  66. accountancy_code_sell varchar(32), -- Selling accountancy code
  67. accountancy_code_sell_intra varchar(32), -- Selling accountancy code for vat intracommunity
  68. accountancy_code_sell_export varchar(32), -- Selling accountancy code for vat export
  69. accountancy_code_buy varchar(32), -- Buying accountancy code
  70. accountancy_code_buy_intra varchar(32), -- Buying accountancy code for vat intracommunity
  71. accountancy_code_buy_export varchar(32), -- Buying accountancy code for vat export
  72. partnumber varchar(32), -- Part/Serial number. TODO To use it into screen if not a duplicate of barcode.
  73. net_measure float DEFAULT NULL,
  74. net_measure_units tinyint DEFAULT NULL,
  75. weight float DEFAULT NULL,
  76. weight_units tinyint DEFAULT NULL,
  77. length float DEFAULT NULL,
  78. length_units tinyint DEFAULT NULL,
  79. width float DEFAULT NULL,
  80. width_units tinyint DEFAULT NULL,
  81. height float DEFAULT NULL,
  82. height_units tinyint DEFAULT NULL,
  83. surface float DEFAULT NULL,
  84. surface_units tinyint DEFAULT NULL,
  85. volume float DEFAULT NULL,
  86. volume_units tinyint DEFAULT NULL,
  87. stock real, -- Current physical stock (dernormalized field)
  88. pmp double(24,8) DEFAULT 0 NOT NULL, -- To store valuation of stock calculated using average price method, for this product
  89. fifo double(24,8), -- To store valuation of stock calculated using fifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table.
  90. lifo double(24,8), -- To store valuation of stock calculated using lifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table.
  91. fk_default_warehouse integer DEFAULT NULL,
  92. canvas varchar(32) DEFAULT NULL,
  93. finished tinyint DEFAULT NULL, -- see dictionnary c_product_nature
  94. lifetime integer DEFAULT NULL,
  95. qc_frequency integer DEFAULT NULL, -- Quality control periodicity
  96. hidden tinyint DEFAULT 0, -- Not used. Deprecated.
  97. import_key varchar(14), -- Import key
  98. model_pdf varchar(255), -- model save dodument used
  99. fk_price_expression integer, -- Link to the rule for dynamic price calculation
  100. desiredstock float DEFAULT 0,
  101. fk_unit integer DEFAULT NULL,
  102. price_autogen tinyint DEFAULT 0,
  103. fk_project integer DEFAULT NULL, -- Used when product was generated by a project or is specifif to a project
  104. mandatory_period tinyint DEFAULT 0, -- is used to signal to the user that the start and end dates are mandatory for this type of product the fk_product_type == 1 (service) (non-blocking action)
  105. fk_default_bom integer DEFAULT NULL,
  106. fk_default_workstation integer DEFAULT NULL
  107. )ENGINE=innodb;