OpenERP and Perl  Jon	  Allen	  (JJ)	  –	  jj@opusvl.com	  
OpenERP       www.opusvl.com!
enterprise" resource" planning          www.opusvl.com!
?     www.opusvl.com!
core business" applications           www.opusvl.com!
sales crm"manufacturing" purchasing           www.opusvl.com!
accounting         www.opusvl.com!
integratedaccounting         www.opusvl.com!
www.opusvl.com!
Perl?         www.opusvl.com!
OpenERPwebsite          intranet                        www.opusvl.com!
api       www.opusvl.com!
XML-RPC       www.opusvl.com!
single"requests        www.opusvl.com!
stateless         www.opusvl.com!
object"model          www.opusvl.com!
relationships           www.opusvl.com!
res.partner.address                one2manyres.partner     many2one                   res.company                         ...
database        www.opusvl.com!
ORM       www.opusvl.com!
object"relational" mapper          www.opusvl.com!
OOM       www.opusvl.com!
object to" object"mapper         www.opusvl.com!
OpenERP::OOM         www.opusvl.com!
Moose         www.opusvl.com!
object model          www.opusvl.com!
SchemaClass      Class    ClassObject     Object     OpenERP                      www.opusvl.com!
# Code layout for module using OpenERP::OOM	lib/	    MyApp.pm    # Schema definition	    MyApp/	        Class/           #...
schema      www.opusvl.com!
# MyApp.pm	package MyApp;	use Moose;	extends OpenERP::OOM::Schema;	1;	                         www.opusvl.com!
connection         www.opusvl.com!
use MyApp;	my $schema = MyApp->new(	    openerp_connect => {	        host     => localhost,                	        dbname...
classes           www.opusvl.com!
# MyApp/Class/Company.pm	package MyApp::Class::Company;	use OpenERP::OOM::Class;	object_type MyApp::Object::Company;	# Cla...
objects           www.opusvl.com!
fields         www.opusvl.com!
relationships           www.opusvl.com!
partner"has many"addresses        www.opusvl.com!
package MyApp::Object::Partner;	use OpenERP::OOM::Object;	openerp_model res.partner;	has name => (isa=>Str, is=>rw);	relat...
object "creation        www.opusvl.com!
# Schema -> Class -> Class Method	my $partner = $schema->class(Partner)->	              create({ name => JJ });	# Updates	...
search          www.opusvl.com!
# Single result	my $jj = $schema->class(Partner)->	         find([name => = => JJ]);	# Multiple results	my @partners = 	  ...
related"objects           www.opusvl.com!
$partner->create_related(	    addresses,	    {	        name   => ...,	        street => ...,	        city   => ...,	    }	...
add"methods       www.opusvl.com!
extendOpenERP objects        www.opusvl.com!
external"data sources          www.opusvl.com!
DBIx::Class         www.opusvl.com!
not just" data            www.opusvl.com!
OpenERP"methods       www.opusvl.com!
workflows       www.opusvl.com!
integrated"accounting         www.opusvl.com!
my $po = $schema->class(PurchaseOrder)->	         search([ ... ]);	$po->update({ ... });	# Approve purchase order	$po->exe...
applicationlogic = Perl          www.opusvl.com!
application"data = DBIC          www.opusvl.com!
generic logic "= OpenERP            www.opusvl.com!
generic data "= OpenERP           www.opusvl.com!
many uses        www.opusvl.com!
Catalyst model           www.opusvl.com!
18 months"development         www.opusvl.com!
3 commercial"deployments          www.opusvl.com!
open sourced"   today          www.opusvl.com!
http://search.cpan.org/ dist/OpenERP-OOM                  www.opusvl.com!
questions?         www.opusvl.com!
www.opusvl.com!
Upcoming SlideShare
Loading in …5
×

OpenERP and Perl

1,580 views
1,466 views

Published on

OpenERP is a very flexible open-source ERP system, which handles accounting, CRM, sales, purchasing, manufacturing, and many other business functions.

It is written in Python but has an XML-RPC API so we can control all of its functions from Perl. However, despite OpenERP having an object-oriented architecture the API is quite 'low-level', and using it is a very different experience compared to having an ORM like DBIx::Class.

OpenERP::OOM (Object to Object Mapper) bridges this gap, letting us use Moose classes to represent the OpenERP schema. As with an ORM, the schema and object classes can be extended with our own methods and functions.

With this approach the underlying interface to OpenERP becomes transparent - everything is done with Perl - which means we can write Catalyst models, extend OpenERP with CPAN modules, and use all of OpenERP's functions from our Perl code.

Presented at the YAPC Europe 2012 conference in Frankfurt, Germany.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,580
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

OpenERP and Perl

  1. 1. OpenERP and Perl Jon  Allen  (JJ)  –  jj@opusvl.com  
  2. 2. OpenERP www.opusvl.com!
  3. 3. enterprise" resource" planning www.opusvl.com!
  4. 4. ? www.opusvl.com!
  5. 5. core business" applications www.opusvl.com!
  6. 6. sales crm"manufacturing" purchasing www.opusvl.com!
  7. 7. accounting www.opusvl.com!
  8. 8. integratedaccounting www.opusvl.com!
  9. 9. www.opusvl.com!
  10. 10. Perl? www.opusvl.com!
  11. 11. OpenERPwebsite intranet www.opusvl.com!
  12. 12. api www.opusvl.com!
  13. 13. XML-RPC www.opusvl.com!
  14. 14. single"requests www.opusvl.com!
  15. 15. stateless www.opusvl.com!
  16. 16. object"model www.opusvl.com!
  17. 17. relationships www.opusvl.com!
  18. 18. res.partner.address one2manyres.partner many2one res.company www.opusvl.com!
  19. 19. database www.opusvl.com!
  20. 20. ORM www.opusvl.com!
  21. 21. object"relational" mapper www.opusvl.com!
  22. 22. OOM www.opusvl.com!
  23. 23. object to" object"mapper www.opusvl.com!
  24. 24. OpenERP::OOM www.opusvl.com!
  25. 25. Moose www.opusvl.com!
  26. 26. object model www.opusvl.com!
  27. 27. SchemaClass Class ClassObject Object OpenERP www.opusvl.com!
  28. 28. # Code layout for module using OpenERP::OOM lib/ MyApp.pm # Schema definition MyApp/ Class/ # Class definitions Company.pm Partner.pm Object/ # Object definitions Company.pm Partner.pm www.opusvl.com!
  29. 29. schema www.opusvl.com!
  30. 30. # MyApp.pm package MyApp; use Moose; extends OpenERP::OOM::Schema; 1; www.opusvl.com!
  31. 31. connection www.opusvl.com!
  32. 32. use MyApp; my $schema = MyApp->new( openerp_connect => { host => localhost, dbname => jj_test_1, username => admin, password => admin, }, ); www.opusvl.com!
  33. 33. classes www.opusvl.com!
  34. 34. # MyApp/Class/Company.pm package MyApp::Class::Company; use OpenERP::OOM::Class; object_type MyApp::Object::Company; # Class methods go here 1; www.opusvl.com!
  35. 35. objects www.opusvl.com!
  36. 36. fields www.opusvl.com!
  37. 37. relationships www.opusvl.com!
  38. 38. partner"has many"addresses www.opusvl.com!
  39. 39. package MyApp::Object::Partner; use OpenERP::OOM::Object; openerp_model res.partner; has name => (isa=>Str, is=>rw); relationship addresses => ( key => address, # OpenERP field type => one2many, # OpenERP type class => PartnerAddress, ); www.opusvl.com!
  40. 40. object "creation www.opusvl.com!
  41. 41. # Schema -> Class -> Class Method my $partner = $schema->class(Partner)-> create({ name => JJ }); # Updates $partner->update({name => Jon Allen}); say $partner->name; www.opusvl.com!
  42. 42. search www.opusvl.com!
  43. 43. # Single result my $jj = $schema->class(Partner)-> find([name => = => JJ]); # Multiple results my @partners = $schema->class(Partner)-> search([name => like => J]); www.opusvl.com!
  44. 44. related"objects www.opusvl.com!
  45. 45. $partner->create_related( addresses, { name => ..., street => ..., city => ..., } ); www.opusvl.com!
  46. 46. add"methods www.opusvl.com!
  47. 47. extendOpenERP objects www.opusvl.com!
  48. 48. external"data sources www.opusvl.com!
  49. 49. DBIx::Class www.opusvl.com!
  50. 50. not just" data www.opusvl.com!
  51. 51. OpenERP"methods www.opusvl.com!
  52. 52. workflows www.opusvl.com!
  53. 53. integrated"accounting www.opusvl.com!
  54. 54. my $po = $schema->class(PurchaseOrder)-> search([ ... ]); $po->update({ ... }); # Approve purchase order $po->execute_workflow(purchase_confirm); # Print (returns PDF) $po->get_report(purchase.order); www.opusvl.com!
  55. 55. applicationlogic = Perl www.opusvl.com!
  56. 56. application"data = DBIC www.opusvl.com!
  57. 57. generic logic "= OpenERP www.opusvl.com!
  58. 58. generic data "= OpenERP www.opusvl.com!
  59. 59. many uses www.opusvl.com!
  60. 60. Catalyst model www.opusvl.com!
  61. 61. 18 months"development www.opusvl.com!
  62. 62. 3 commercial"deployments www.opusvl.com!
  63. 63. open sourced" today www.opusvl.com!
  64. 64. http://search.cpan.org/ dist/OpenERP-OOM www.opusvl.com!
  65. 65. questions? www.opusvl.com!
  66. 66. www.opusvl.com!

×