├── docs ├── themes ├── source │ ├── index.rst │ ├── contribute.rst │ ├── install.rst │ ├── configure.rst │ ├── use.rst │ └── conf.py └── Makefile ├── README.rst ├── rent ├── reports │ ├── order.odt │ └── reports.xml ├── data │ ├── intervals.xml │ ├── cron.xml │ └── uoms.xml ├── views │ ├── sequence.xml │ ├── company.xml │ ├── product.xml │ ├── menus.xml │ └── rent.xml ├── security │ └── ir.model.access.csv ├── __init__.py ├── __openerp__.py ├── intervals.py ├── company.py ├── product.py ├── workflow │ └── rent.xml └── i18n │ ├── en.po │ ├── de.po │ └── fr.po ├── rent_rtz ├── reports │ ├── order.odt │ ├── invoice.odt │ ├── parser.py │ └── reports.xml ├── __init__.py ├── __openerp__.py ├── i18n │ └── fr.po ├── views │ └── rent.xml └── rent.py ├── AUTHORS ├── migrations └── Migrate-0.3-To-0.4.sql └── LICENSE /docs/themes: -------------------------------------------------------------------------------- 1 | ../../../../Applications/jinja2/docs/_themes/ -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Read the documentation on http://doc.we2bs.com/openerp-rent/ ! 2 | -------------------------------------------------------------------------------- /rent/reports/order.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WE2BS/openerp-rent/HEAD/rent/reports/order.odt -------------------------------------------------------------------------------- /rent_rtz/reports/order.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WE2BS/openerp-rent/HEAD/rent_rtz/reports/order.odt -------------------------------------------------------------------------------- /rent_rtz/reports/invoice.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WE2BS/openerp-rent/HEAD/rent_rtz/reports/invoice.odt -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Developpers: 2 | - Thibaut DIRLIK (thibaut.dirlik@gmail.com) 3 | 4 | Contributors: 5 | - Bernard JAVELLE 6 | - William FAMY 7 | 8 | Investors: 9 | - Rtz Évènement (http://www.rtzevenement.fr, France) 10 | -------------------------------------------------------------------------------- /migrations/Migrate-0.3-To-0.4.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Migration script from 0.3 to 0.4 3 | -- 4 | -- This script must be applied before you restart OpenERP with the new 0.4 5 | -- version. If you updated first, it won't work ! To apply this file, run : 6 | -- 7 | -- psql -f Migrate-0.3-To-0.4.sql 8 | -- 9 | 10 | -- Renamed column 'ref' to 'reference' in rent.order object 11 | ALTER TABLE rent_order RENAME ref TO reference; 12 | -------------------------------------------------------------------------------- /rent/data/intervals.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Once 6 | get_invoice_for_once_period 7 | 8 | 9 | Monthly (Based on begin date) 10 | get_invoices_for_month_period 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /rent/views/sequence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | Rent Order 9 | rent.order 10 | 11 | 12 | Rent Order 13 | rent.order 14 | RENT 15 | 7 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /rent/security/ir.model.access.csv: -------------------------------------------------------------------------------- 1 | "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" 2 | "access_rent_order","rent.order","model_rent_order","base.group_sale_salesman",1,1,1,0 3 | "access_rent_order_line","rent.order.line","model_rent_order_line","base.group_sale_salesman",1,1,1,1 4 | "access_rent_order_manager","rent.order.manager","model_rent_order","base.group_sale_manager",1,1,1,1 5 | "access_rent_order_line_manager","rent.order.line.manager","model_rent_order_line","base.group_sale_manager",1,1,1,1 6 | "access_rent_interval","rent.interval","model_rent_interval","base.group_sale_salesman",1,0,0,0 7 | "access_rent_interval_manager","rent.interval","model_rent_interval","base.group_sale_manager",1,0,0,0 8 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | OpenERP Rent 2 | ============ 3 | 4 | The `OpenERP Rent`_ module let you rent products to your customers. It supports both *service* and *stockable* products. 5 | OpenERP supports many reporting engines, but we decided to use `Aeroo Report`_ so you can edit your report 6 | directly inside *LibreOffice*. 7 | 8 | Currently, OpenERP Rent is only compatible with OpenERP 6.0 (but should be ported to 6.1 as soon as possible). 9 | 10 | .. _OpenERP Rent: http://github.com/WE2BS/openerp-rent 11 | .. _Aeroo Report: http://www.alistek.com/index.php?option=com_content&view=article&id=93%3Aaeroo-reports-for-open-erp-5-a-6&catid=34%3Azias&lang=lv 12 | 13 | .. toctree:: 14 | :maxdepth: 3 15 | 16 | install 17 | configure 18 | use 19 | contribute 20 | -------------------------------------------------------------------------------- /rent_rtz/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent Module 4 | # Copyright (C) 2010-Today Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from . import rent 21 | -------------------------------------------------------------------------------- /rent/views/company.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | rent.company.form.view 6 | res.company 7 | form 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /rent/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent Module 4 | # Copyright (C) 2010-Today Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | GITHUB_ENABLED = True 21 | GITHUB_USER = 'WE2BS' 22 | GITHUB_REPO = 'openerp-rent' 23 | 24 | import intervals 25 | import company 26 | import rent 27 | import product 28 | 29 | -------------------------------------------------------------------------------- /docs/source/contribute.rst: -------------------------------------------------------------------------------- 1 | Contribute to OpenERP Rent 2 | ========================== 3 | 4 | This module is an open-source project and we need contributors to make it better ! You contribute in different ways. 5 | 6 | Translate OpenERP Rent 7 | ---------------------- 8 | 9 | Because it's not easy to translate extra modules, we choosed to host our project on `Transifex`_. Subscribe 10 | and join our `project-page`_. You must join a translation team to be able to translate. 11 | 12 | If the team doesn't exist yet, `contact me`_. 13 | 14 | The translation should be integrated into the next version, but you can download the ``.po`` file manually 15 | to enable it on you current version. 16 | 17 | .. _Transifex: 18 | .. _project-page: https://www.transifex.net/projects/p/openerp-rent/ 19 | .. _contact me: mailto:thibaut.dirlik@gmail.com 20 | 21 | Make bug reports 22 | ---------------- 23 | 24 | If you encounter bugs, you must report them. This is done easily on the `github project page`_. 25 | 26 | .. _github project page: https://github.com/WE2BS/openerp-rent/issues 27 | 28 | Improve the code 29 | ---------------- 30 | 31 | If you are a developper, just fork the project on github and send me a pull request with your modifications. 32 | If you are not sure, or have questions, send me a private message on github or open an new issue. 33 | -------------------------------------------------------------------------------- /rent/reports/reports.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Quotation / Rent Order 7 | ir.actions.report.xml 8 | rent.order 9 | rent_order_report 10 | aeroo 11 | oo-odt 12 | 13 | rent/reports/order.odt 14 | file 15 | default 16 | 17 | 18 | action 19 | client_print_multi 20 | 21 | rent_order_report 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /rent/data/cron.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Rent - Services Rent Cron Checker 6 | 7 | 8 | minutes 9 | 10 | 11 | rent.order 12 | run_cron_start_stop_rents 13 | 14 | 15 | 16 | Rent - Invoices Cron 17 | 18 | 19 | days 20 | 21 | 22 | rent.order 23 | run_cron_make_invoices 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /rent/data/uoms.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Duration 6 | 7 | 8 | Day 9 | 10 | 13 | 14 | smaller 15 | 16 | 17 | 18 | Month 19 | 20 | 21 | smaller 22 | 23 | 24 | 25 | Year 26 | 27 | 28 | reference 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /rent_rtz/__openerp__.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent - A rent module for OpenERP 6 4 | # Copyright (C) 2010-Today Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | { 21 | "name": "Rent - Extension for Rtz Evenement", 22 | "version": "0.2", 23 | "author": "UIDE/WE2BS", 24 | "category": "Generic Modules/Sales & Purchases", 25 | "website": "http://www.rtzevenement.fr/", 26 | "description": 27 | """ 28 | This module is an extension to the rent module, to fill the need of the Rtz Evenement french company. 29 | """, 30 | "depends": ["rent", "report_aeroo_ooo"], 31 | "init_xml": [], 32 | "demo_xml": [], 33 | "update_xml": ['views/rent.xml', 'reports/reports.xml'], 34 | "active": False, 35 | "test": [], 36 | "installable": True 37 | } 38 | -------------------------------------------------------------------------------- /rent_rtz/reports/parser.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent - Extention for Rtz Evènement 4 | # Copyright (C) 2010-2011 Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from datetime import datetime 21 | from report import report_sxw 22 | from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT 23 | 24 | class Parser(report_sxw.rml_parse): 25 | 26 | def __init__(self, cr, uid, name, context): 27 | super(Parser, self).__init__(cr, uid, name, context) 28 | self.localcontext.update({ 29 | 'format_datetime': self.format_datetime, 30 | }) 31 | 32 | def format_datetime(self, value): 33 | 34 | """ 35 | Format the datetime into a date only string. 36 | """ 37 | 38 | datetime_object = datetime.strptime(value, DEFAULT_SERVER_DATETIME_FORMAT) 39 | 40 | return datetime_object.strftime('%d/%m/%y') -------------------------------------------------------------------------------- /docs/source/install.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | You should follow these steps to install OpenER Rent. If you are familiar with git, you can directly clone 5 | the `Github repository`_ to get the latest version, else, read this page. 6 | 7 | Download 8 | -------- 9 | 10 | The current version is |release| and can be downloaded from the `Github project page`_ (By clicking on the ``Downloads`` 11 | button). We provide a packaged version which includes all the dependancies. 12 | 13 | Here is a list of the required modules, if you want to install them manually : 14 | 15 | * `Aeroo Report`_ (6xRC4 or superior) 16 | * `Aeroo Lib`_ (RC2 or superior) 17 | * `OpenLib`_ (0.2.5 or superior) 18 | 19 | Moreover, you need these python packages : 20 | 21 | * genshi 22 | * httplib2 23 | 24 | .. _Github project page: 25 | .. _Github repository: http://github.com/WE2BS/openerp-rent 26 | .. _Aeroo Report: https://launchpad.net/aeroo 27 | .. _Aeroo Lib: https://launchpad.net/aeroolib 28 | .. _OpenLib: https://github.com/WE2BS/openerp-openlib 29 | 30 | Install modules 31 | --------------- 32 | 33 | If you downloaded the packaged version, you should have a *zipfile* containing all the required modules. 34 | You must extract these modules in the directory ``bin/addons`` of the OpenERP Server. 35 | 36 | Once all modules have been extracted, go to OpenERP ``Administration->Modules->Update modules list`` menu and refresh 37 | the list of availabe modules. 38 | 39 | Install rent 40 | ------------ 41 | 42 | Finally, install the ``rent`` module in OpenERP ``Administration->Modules->Modules`` view. 43 | -------------------------------------------------------------------------------- /rent/__openerp__.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent - A rent module for OpenERP 6 4 | # Copyright (C) 2010-Today Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | { 21 | "name": "Rent", 22 | "version": "0.4", 23 | "author": "UIDE/WE2BS", 24 | "category": "Generic Modules/Sales & Purchases", 25 | "website": "https://github.com/thibautd/openerp-rent", 26 | "description": 27 | """ 28 | This module manages the leasing of products to partners. 29 | """, 30 | "depends": ["base", "openlib", "sale", "report_aeroo"], 31 | "init_xml": [], 32 | "demo_xml": [], 33 | "update_xml": ['data/uoms.xml', 'data/intervals.xml', 'views/rent.xml', 'views/product.xml', 'views/menus.xml', 34 | 'views/sequence.xml', 'views/company.xml', 'workflow/rent.xml', 'security/ir.model.access.csv', 35 | 'reports/reports.xml', 'data/cron.xml'], 36 | "active": False, 37 | "test": [], 38 | "installable": True 39 | } 40 | -------------------------------------------------------------------------------- /rent/intervals.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent - A rent module for OpenERP 6 4 | # Copyright (C) 2010-Today Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from osv import osv, fields 21 | from openlib.orm import * 22 | 23 | class InvoiceInterval(osv.osv, ExtendedOsv): 24 | 25 | """ 26 | This object represents a invoice interval the user can used when invoicing rent orders. 27 | 28 | In this object, we define the name of the interval, and the name of the python method called. 29 | If you want to add support for a specific interval, just creates one of this object, inherit rent.order 30 | and add your custom method with this signature : 31 | 32 | method(self, cr, uid, order, context=None) 33 | 34 | Where order is the result of a browse() on the current order. This method must returns a list of the created 35 | invoices ids, or raise an exception. 36 | """ 37 | 38 | _name = 'rent.interval' 39 | _columns = { 40 | 'name' : fields.char('Name', size=150, required=True, translate=True), 41 | 'method' : fields.char('Method', size=255, required=True), 42 | 'not_allowed_duration_unities' : fields.many2many('product.uom', 'rent_interval_not_allowed_durations', 43 | 'interval_id', 'duration_id', string='Duration not allowed with this interval !'), 44 | } 45 | 46 | InvoiceInterval() 47 | -------------------------------------------------------------------------------- /rent/company.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent - A rent module for OpenERP 6 4 | # Copyright (C) 2010-Today Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from osv import osv, fields 21 | 22 | DEFAULT_BEGIN = ( 23 | ('today', 'Today'), 24 | ('tomorrow_morning', 'Tomorrow (Morning)'), 25 | ('tomorrow_after', 'Tomorrow (Afternoon)'), 26 | ('empty', 'Empty'), 27 | ) 28 | 29 | class Company(osv.osv): 30 | 31 | """ 32 | These fields are used in the comptation of an order duration. 33 | """ 34 | 35 | _inherit = 'res.company' 36 | _columns = { 37 | 'rent_morning_begin' : fields.time('Day begin', required=True, help= 38 | "This time will be used as default rent begin date/time if you select 'Tomorrow (Morning)' as default value."), 39 | 'rent_afternoon_begin' : fields.time('Afternoon begin', required=True, help= 40 | "This time will be used as default rent begin date/time if you select 'Tomorrow (Afternoon)' as default value."), 41 | 'rent_afternoon_end' : fields.time('Afternoon end', required=True, help= 42 | "This time will be used as the time of the rent end date."), 43 | 'rent_default_begin' : fields.selection(DEFAULT_BEGIN, 'Rent default begin/shipping', required=True, help= 44 | "Specify the default rent begin date/time value you want to have when you create a new rent order.") 45 | } 46 | _defaults = { 47 | 'rent_morning_begin' : '09:00:00', 48 | 'rent_afternoon_begin' : '14:00:00', 49 | 'rent_afternoon_end' : '19:00:00', 50 | 'rent_default_begin' : 'today', 51 | } 52 | 53 | Company() 54 | -------------------------------------------------------------------------------- /rent/views/product.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | rent.product.normal.form 12 | product.product 13 | form 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 35 | product.search.form 36 | product.product 37 | 38 | search 39 | 40 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /rent_rtz/reports/reports.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Quotation / Order 7 | ir.actions.report.xml 8 | rent.order 9 | rent_order_rtz_report 10 | aeroo 11 | oo-odt 12 | 13 | rent_rtz/reports/parser.py 14 | rent_rtz/reports/order.odt 15 | loc 16 | file 17 | 18 | 19 | action 20 | client_print_multi 21 | 22 | rent_order_rtz_report 23 | 24 | 25 | 26 | 27 | 28 | 29 | Print Invoice 30 | ir.actions.report.xml 31 | account.invoice 32 | invoice_rtz_report 33 | aeroo 34 | oo-odt 35 | 36 | rent_rtz/reports/parser.py 37 | rent_rtz/reports/invoice.odt 38 | loc 39 | file 40 | 41 | 42 | action 43 | client_print_multi 44 | 45 | invoice_rtz_report 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /rent/product.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent - A rent module for OpenERP 6 4 | # Copyright (C) 2010-Today Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | import logging 21 | 22 | from osv import osv, fields 23 | from tools.translate import _ 24 | 25 | from openlib.orm import * 26 | from openlib.github import report_bugs 27 | 28 | _logger = logging.getLogger('rent') 29 | 30 | class Product(osv.osv, ExtendedOsv): 31 | 32 | @report_bugs 33 | def check_rent_price(self, cr, uid, ids, context=None): 34 | 35 | """ 36 | We check that the rent price is neither empty or 0 if the product can be rent. 37 | """ 38 | 39 | products = self.filter(ids) 40 | 41 | for product in products: 42 | if product.can_be_rent: 43 | if not product.rent_price or product.rent_price <= 0: 44 | return False 45 | return True 46 | 47 | @report_bugs 48 | def default_price_unity(self, cr, uid, context=None): 49 | 50 | """ 51 | Returns the default price unity (the first in the list). 52 | """ 53 | 54 | unity = self.get(category_id__name='Duration', _object='product.uom') 55 | 56 | if not unity: 57 | _logger.warning("It seems that there isn't a reference unity in the 'Duration' UoM category. " 58 | "Please check that the category exists, and there's a refernce unity.") 59 | 60 | return unity.id if unity else False 61 | 62 | _name = 'product.product' 63 | _inherit = 'product.product' 64 | 65 | _columns = { 66 | 'can_be_rent' : fields.boolean('Can be rented', help='Enable this if you want to rent this product.'), 67 | 'rent_price' : fields.float('Rent price', help= 68 | 'The price is expressed for the duration unity defined in the company configuration.'), 69 | 'rent_price_unity' : fields.many2one('product.uom', 'Rent Price Unity', domain=[('category_id.name', '=', 'Duration')], 70 | help='Rent duration unity in which the price is defined.'), 71 | } 72 | 73 | _defaults = { 74 | 'can_be_rent' : False, 75 | 'rent_price' : 1.0, 76 | 'rent_price_unity' : default_price_unity, 77 | } 78 | 79 | _constraints = [(check_rent_price, _('The Rent price must be a positive value.'), ['rent_price']),] 80 | 81 | Product() 82 | -------------------------------------------------------------------------------- /rent_rtz/i18n/fr.po: -------------------------------------------------------------------------------- 1 | # Translation of OpenERP Server. 2 | # This file contains the translation of the following modules: 3 | # * rent_rtz 4 | # 5 | msgid "" 6 | msgstr "" 7 | "Project-Id-Version: OpenERP Server 6.0.2\n" 8 | "Report-Msgid-Bugs-To: support@openerp.com\n" 9 | "POT-Creation-Date: 2011-04-21 19:57+0000\n" 10 | "PO-Revision-Date: 2011-04-21 19:57+0000\n" 11 | "Last-Translator: <>\n" 12 | "Language-Team: \n" 13 | "MIME-Version: 1.0\n" 14 | "Content-Type: text/plain; charset=UTF-8\n" 15 | "Content-Transfer-Encoding: \n" 16 | "Plural-Forms: \n" 17 | 18 | #. module: rent_rtz 19 | #: code:addons/rent_rtz/rent.py:143 20 | #: field:rent.order.line,coeff:0 21 | #, python-format 22 | msgid "Coefficient" 23 | msgstr "Coefficient" 24 | 25 | #. module: rent_rtz 26 | #: code:addons/rent_rtz/rent.py:82 27 | #, python-format 28 | msgid "Rental from %s to %s.\n" 29 | "Invoice %d/%d.\n" 30 | "" 31 | msgstr "Location du %s au %s.\n" 32 | "Facture %d/%d.\n" 33 | "" 34 | 35 | #. module: rent_rtz 36 | #: model:ir.model,name:rent_rtz.model_rent_order 37 | msgid "rent.order" 38 | msgstr "rent.order" 39 | 40 | #. module: rent_rtz 41 | #: constraint:rent.order.line:0 42 | msgid "You can't use this product type with this product. Check that the product is marked for rent or for sale. Moreover, Service products must be declared as 'Service' in the product view." 43 | msgstr "Vous ne pouvez pas utiliser ce produit avec ce type de produit. Vérifiez que le produit peut être loué ou acheté. De plus, les produits de type 'Service' doivent être défini comme tel dans la fiche produit." 44 | 45 | #. module: rent_rtz 46 | #: sql_constraint:rent.order:0 47 | msgid "The begin date must later than the order date." 48 | msgstr "The begin date must later than the order date." 49 | 50 | #. module: rent_rtz 51 | #: model:ir.actions.report.xml,name:rent_rtz.rent_order_rtz_report 52 | msgid "Quotation / Order" 53 | msgstr "Devis / Commande" 54 | 55 | #. module: rent_rtz 56 | #: sql_constraint:rent.order:0 57 | msgid "Rent Order reference must be unique !" 58 | msgstr "La référence doit être unique !" 59 | 60 | #. module: rent_rtz 61 | #: model:ir.model,name:rent_rtz.model_rent_order_line 62 | msgid "rent.order.line" 63 | msgstr "rent.order.line" 64 | 65 | #. module: rent_rtz 66 | #: model:ir.module.module,shortdesc:rent_rtz.module_meta_information 67 | msgid "Rent - Extension for Rtz Evenement" 68 | msgstr "Rent - Extension for Rtz Evenement" 69 | 70 | #. module: rent_rtz 71 | #: sql_constraint:rent.order.line:0 72 | msgid "The price must be superior to 0." 73 | msgstr "Le prix doit être superieur à 0." 74 | 75 | #. module: rent_rtz 76 | #: code:addons/rent_rtz/rent.py:151 77 | #: sql_constraint:rent.order.line:0 78 | #, python-format 79 | msgid "The coefficient must be superior to 0." 80 | msgstr "Le coefficient doit être superieur à 0." 81 | 82 | #. module: rent_rtz 83 | #: sql_constraint:rent.order:0 84 | #: sql_constraint:rent.order.line:0 85 | msgid "Discount must be a value between 0 and 100." 86 | msgstr "La réduction doitê tre une valeur entre 0 et 100." 87 | 88 | #. module: rent_rtz 89 | #: model:ir.actions.report.xml,name:rent_rtz.invoice_rtz_report 90 | msgid "Print Invoice" 91 | msgstr "Facture (Rtz)" 92 | 93 | #. module: rent_rtz 94 | #: model:ir.module.module,description:rent_rtz.module_meta_information 95 | msgid "\n" 96 | " This module is an extension to the rent module, to fill the need of the Rtz Evenement french company.\n" 97 | " " 98 | msgstr "\n" 99 | " This module is an extension to the rent module, to fill the need of the Rtz Evenement french company.\n" 100 | " " 101 | 102 | -------------------------------------------------------------------------------- /rent/views/menus.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | Rent Order 9 | rent.order 10 | form 11 | tree,form,calendar 12 | menu 13 | 14 | 15 | 17 | 18 | 21 | 22 | ir.actions.server 23 | True 24 | code 25 | 26 | 27 | action = self.action_show_shipping(cr, uid, [context.get('active_id')], 'out', context) 28 | Delivery Order 29 | 30 | 31 | 32 | Delivery Order 33 | client_action_relate 34 | 35 | action 36 | rent.order 37 | 38 | 39 | ir.actions.server 40 | True 41 | code 42 | 43 | 44 | action = self.action_show_shipping(cr, uid, [context.get('active_id')], 'in', context) 45 | Incoming Shipment 46 | 47 | 48 | 49 | Incoming Shipment 50 | client_action_relate 51 | 52 | action 53 | rent.order 54 | 55 | 56 | ir.actions.server 57 | True 58 | code 59 | 60 | 61 | action = self.action_show_invoices(cr, uid, [context.get('active_id')], context) 62 | Invoices 63 | 64 | 65 | 66 | Invoices 67 | client_action_relate 68 | 69 | action 70 | rent.order 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /rent_rtz/views/rent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | rent.order.rtz.tree.view 9 | rent.order 10 | 11 | tree 12 | 13 | 14 | date 15 | 16 | 17 | date 18 | 19 | 20 | date 21 | 22 | 23 | 24 | 25 | rent.order.rtz.form.view 26 | rent.order 27 | 28 | form 29 | 30 | 31 | date 32 | 33 | 34 | date 35 | 36 | 37 | date 38 | 39 | 40 | date 41 | 42 | 43 | 44 | 45 | rent.order.rtz.calendar 46 | rent.order 47 | calendar 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 59 | 60 | rent.order.line.rtz.tree.view 61 | rent.order.line 62 | 63 | tree 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | rent.order.line.rtz.form.view 72 | rent.order.line 73 | form 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /docs/source/configure.rst: -------------------------------------------------------------------------------- 1 | Configuration 2 | ============= 3 | 4 | OpenERP Rent is flexiable and let your configure a lot of things. 5 | 6 | General configuration 7 | --------------------- 8 | 9 | You can configure OpenERP Rent in the company configuration tab. Go to ``Administration->Company``, select your company 10 | and open to the ``Configuration`` tab. You should see a group named ``Rent`` containing configuration fields. 11 | 12 | ``Day begin`` 13 | 14 | This field defines the begin time of a normal day. This value will be used as default value for new rent orders, 15 | depending on what you put in the ``Rent default begin/shipping`` field. 16 | 17 | ``Afternoon begin`` 18 | 19 | This field defines the begin time of the afternoon (after launch). This value will be used as default value for 20 | new rent orders, depending on what you put in the ``Rent default begin/shipping`` field. 21 | 22 | ``Afternoon end`` 23 | 24 | This field defines the time at which the work day is considered finished. This value will be used to defined the 25 | return time of products. For example, if you rent a product from the January 1st at 9am for 1 day, the default product 26 | return datetime will be January 1st at ``Afternoon end`` value. 27 | 28 | ``Rent default begin/shipping`` 29 | 30 | This field defines the default begin datetime of your rent order and its 31 | assodiated shipping order. When you create a rent order, the begin datetime will be one of the following, depending 32 | of the selected value : 33 | 34 | * ``Today`` : The date will be today, and the time will be either the ``Day begin``, if you create the rent order 35 | before the time specified in ``Day begin``. If you are between the ``Day begin`` time and the ``Afternoon begin`` 36 | time, the rent order will be started at the specified in ``Afternoon begin``. If you are after the 37 | ``Afternoon begin`` time, it will be created at the current time + 1 hour. 38 | 39 | * ``Tomorrow (Morning)`` : The rent order begin datetime will be tomorrow at the ``Day begin`` time. 40 | 41 | * ``Tomorrow (Afternoon)`` : The rent order begin datetime will be tomorrow at the ``Day afternoon`` time. 42 | 43 | * ``Empty`` : No default value, you must fill it manually. 44 | 45 | Products configuration 46 | ---------------------- 47 | 48 | Once you have done the global configuration to fit your company needs, you have toconfigure your products. Go to 49 | ``Sales->Products->Products`` and create or select and existing product. First of all, if you want to rent a product, 50 | you must check the ``Can be rented`` checkbox in the ``Characteristics`` group (top right). 51 | 52 | If you want your product to bo sold only once with a rent order as a service, like *Installation* or *Configuration*, 53 | just check the ``Can be sold`` checkbox and mark the product as a ``Service`` in ``Product type``. 54 | 55 | Product types 56 | ~~~~~~~~~~~~~ 57 | 58 | OpenERP Rent let your rent different products : *Service* products and *Stockable (or Consumable)* products. *Services* 59 | product won't generate a out/in shipping order, whereas *Stockable* products will. 60 | 61 | Their is also a difference in the workflow : a *Service*-only rent order will start automatically at 62 | the rent order begin datetime, whereas a *Stockable* product will start when the products have been shipped to the client. 63 | 64 | If you mix both *Service* and *Stockable* products in a rent order, it will start with the shipping of the products. 65 | 66 | Product rent price 67 | ~~~~~~~~~~~~~~~~~~ 68 | 69 | When you check the ``Can be rented`` wheckbox, you can (and must) define a rent price. You can express the price in the 70 | unity of your choice (``Day``, ``Month``, ``Year``). This price will be converted automatically in the rent order. 71 | 72 | For example, if a product costs 15€ per month, and you rent it for 15 days, the customer will pay 7,5€. Because 73 | it's complicated to convert unities based on duration, OpenERP Rent uses the following factors to do the convertion : 74 | 75 | * 1 Month = 30 Days 76 | * 1 Year = 12 Months, or 360 Days 77 | 78 | Go to ``Sales->Configuration->Product->Units of Measure->Units of Measure`` to configure these factors to fit your needs. 79 | -------------------------------------------------------------------------------- /docs/source/use.rst: -------------------------------------------------------------------------------- 1 | User guide 2 | ========== 3 | 4 | You can create and manage your rent orders the same you do with sale orders. Go to ``Sales->Sales->Rent Orders`` 5 | to list/create/delete your rent orders. 6 | 7 | Create a Rent Order 8 | ------------------- 9 | 10 | The rent order view is similar to the sale order view except for few fields specifics to renting : 11 | 12 | * ``Rent begin date`` : Defines the datetime at wich this rent order will start. In the case of a rent order with 13 | only stockable products, this field is only informative, because the rent order will start once all products have been shipped. 14 | 15 | * ``Duration / Duration unity`` : Defines the duration of the rent order. It's pretty obvious. 16 | 17 | * ``Shipping Date`` : Defines the date of delivery of products. It can't be after or before the rent begin date. 18 | This field is ignored in case of a service-only rent order. 19 | 20 | * ``Return Date`` : Defines a specific return date for products. By default, it's the rent order end date. 21 | This field is ignored in case of a service-only rent order. 22 | 23 | * ``Invoice period`` : Defines how to invoice the customer. For example, if you select a *Monthly* period, 24 | an invoice will be generated every month during the rent duration. For short rent order (less than a month), 25 | you can use the *Once* period which generates only once invoice. 26 | 27 | .. warning:: 28 | 29 | You can't use a ``Day`` duration with a ``Monthly`` invoicing period. Currently, if you want to invoice monthly, 30 | you must use a ``Month`` or ``Year`` duration unity. 31 | 32 | .. note:: 33 | 34 | Invoices are generated automatically into a *cron job*. By default, this cron is called once per day. Go to 35 | ``Administration->Scheduler->Scheduled Ations->Rent - Invoices Cron`` to change this. 36 | 37 | Add products 38 | ------------ 39 | 40 | When you add a product to a rent order, there are some options you must be aware of : 41 | 42 | * ``Type of product`` : This is **not** the same that the product's type (*service*, *stockable* or *consumable*). 43 | It defines if the product will be invoiced only once (*Service*), or if it will be rented and invoiced multiple 44 | time (*Rent*). For example, if you want to invoice a product named *Installation* only once, you should choose *Service*. 45 | 46 | However, if you want to rent a service product (defined as *Service* in its product view) like *web hosting*, 47 | you must set this field to *Rent*, because you will invoice it monthly ! 48 | 49 | * ``Product Unit Price`` : This field defines the price of the product. 50 | 51 | * In the case of a ``Rent`` product, it defines its price, expressed in the unity defined for the product 52 | price in the product view. For example, if you defined that a product costs 15€/Day, this field will contain 53 | ``15`` by default, no matter what unity you choosed for the rent order duration. 54 | 55 | * In the case of a ``Service`` product invoiced once, it defines its sale price. Filled with the product's sale 56 | price by default. 57 | 58 | .. note:: 59 | 60 | When you select a product, fields are automatically filled with default values. You shouldn't have to change them. 61 | 62 | Handle the workflow 63 | ------------------- 64 | 65 | There are two cases with rent orders : the rent order is a *service*-only rent order (no shipping), or not. 66 | 67 | Services only rent orders 68 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 69 | 70 | These rent orders will be started by a *cron job* or when you click on ``Starts the rent order manually``. When the 71 | rent order is started, you can see its state is *Ongoing*. A service-only rent order is automatically stopped 72 | when the end date is reached, or when you click on ``Stops the rent order manually``. 73 | 74 | .. warning:: 75 | 76 | A stopped rent order can't be started again ! 77 | 78 | 79 | Deliverable rent orders 80 | ~~~~~~~~~~~~~~~~~~~~~~~ 81 | 82 | If you rent order contains one or more *stockable/consumable* products, it won't be started automatically. It will 83 | be started when the products will be shipped. You must validate the *delivery order* to starts the rent order. 84 | 85 | You can access the delivery order associated to your rent order by clicking on the ``Delivery Order`` button on 86 | the right pane. 87 | 88 | When you validate the delivery order, an incoming shipment is automatically created, dated of the rent order 89 | *return date*. To stop your rent order, you will have to validate this incoming shipment. 90 | 91 | You can acess it using the ``Incoming Shipment`` button on the right pane. 92 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/OpenERPRent.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/OpenERPRent.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/OpenERPRent" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/OpenERPRent" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /rent_rtz/rent.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # 3 | # OpenERP Rent - Extention for Rtz Evènement 4 | # Copyright (C) 2010-2011 Thibaut DIRLIK 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from openlib.orm import * 21 | from openlib.tools import * 22 | from openlib.github import report_bugs 23 | 24 | from osv import osv, fields 25 | from tools.translate import _ 26 | 27 | COEFF_MAPPING = { 28 | 1 : 1, 29 | 2 : 1.5, 30 | 3 : 2, 31 | 4 : 2.3, 32 | 5 : 2.5, 33 | 6 : 3, 34 | 7 : 3.5, 35 | 8 : 3.3, 36 | 9 : 3.8, 37 | 10 : 4.1, 38 | 11 : 4.4, 39 | 12 : 4., 40 | 13 : 4.8, 41 | 14 : 5, 42 | 15 : 5.2, 43 | 16 : 5.5, 44 | 17 : 5.7, 45 | 18 : 6, 46 | 19 : 6.2, 47 | 20 : 6.5, 48 | 21 : 6.8, 49 | 22 : 7, 50 | 23 : 7.2, 51 | 24 : 7.5, 52 | 25 : 7.8, 53 | 26 : 8, 54 | 27 : 8.2, 55 | 28 : 8.4, 56 | 29 : 8.6, 57 | 30 : 8.8, 58 | 'more' : 9, 59 | } 60 | 61 | class RentOrderRtz(osv.osv, ExtendedOsv): 62 | 63 | _inherit = 'rent.order' 64 | 65 | @report_bugs 66 | def get_invoice_comment(self, cursor, user_id, order, date, current, max, period_begin, period_end): 67 | 68 | """ 69 | This method is overriden from rent.order object to only show dates, not times. 70 | """ 71 | 72 | # We use the lang of the partner instead of the lang of the user to put the text into the invoice. 73 | partner = order.partner_id 74 | partner_lang = self.get(code=partner.lang, _object='res.lang') 75 | context = {'lang' : partner.lang} 76 | 77 | format = partner_lang.date_format 78 | 79 | begin_date = to_datetime(order.date_begin_rent).strftime(format) 80 | end_date = to_datetime(order.date_end_rent).strftime(format) 81 | 82 | return _( 83 | "Rental from %s to %s.\n" 84 | "Invoice %d/%d.\n" 85 | ) % ( 86 | begin_date, 87 | end_date, 88 | current, 89 | max, 90 | ) 91 | 92 | RentOrderRtz() 93 | 94 | class RentOrderRtzLine(osv.osv, ExtendedOsv): 95 | 96 | @report_bugs 97 | def get_rent_price(self, line, duration_unit_price): 98 | 99 | """ 100 | Returns the rent price for the line. 101 | """ 102 | 103 | if line.product_type != 'rent': 104 | return 0.0 105 | 106 | return duration_unit_price * line.coeff 107 | 108 | @report_bugs 109 | def get_default_coeff(self, cursor, user_id, context=None): 110 | if context is None: 111 | context = {} 112 | if not 'duration' in context: 113 | return 1 114 | else: 115 | if context['duration'] in COEFF_MAPPING: 116 | # We check that the duration unity is days, because Rtz only rent for days. If it rent for anything 117 | # else that a day, we set the bigger coeff by default. 118 | duration_unity_id = context['duration_unity'] 119 | duration_unity_xmlid = self.pool.get('product.uom').get_xml_id( 120 | cursor, user_id, [duration_unity_id], context=context) 121 | duration_unity_xmlid = duration_unity_xmlid[duration_unity_id] 122 | if not duration_unity_xmlid or duration_unity_xmlid != 'rent.uom_day': 123 | return COEFF_MAPPING['more'] 124 | return COEFF_MAPPING[context['duration']] 125 | return COEFF_MAPPING['more'] 126 | 127 | @report_bugs 128 | def get_invoice_lines_data(self, cr, uid, ids, line_price_factor, first_invoice=False, context=None): 129 | 130 | """ 131 | We append the coeff value tu the name in the invoice line. 132 | """ 133 | 134 | # TODO: Find a way to avoid the double browse (the one within super() and this one 135 | lines = self.browse(cr, uid, ids, context) 136 | result = super(RentOrderRtzLine, self).get_invoice_lines_data(cr, uid, ids, line_price_factor, first_invoice, context) 137 | 138 | for index, line_data in enumerate(result): 139 | line_data['name'] += ' (Coeff: %d)' % lines[index].coeff 140 | 141 | return result 142 | 143 | _inherit = 'rent.order.line' 144 | _name = 'rent.order.line' 145 | 146 | _columns = { 147 | 'coeff' : fields.float(_('Coefficient'), required=True), 148 | } 149 | 150 | _defaults = { 151 | 'coeff' : get_default_coeff, 152 | } 153 | 154 | _sql_constraints = [ 155 | ('valid_coeff', 'check(coeff > 0)', 'The coefficient must be superior to 0.'), 156 | ] 157 | 158 | RentOrderRtzLine() 159 | -------------------------------------------------------------------------------- /rent/workflow/rent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | rent.order.basic 6 | rent.order 7 | True 8 | 9 | 10 | 13 | 14 | 15 | True 16 | draft 17 | 18 | 19 | 20 | confirmed 21 | function 22 | action_confirmed() 23 | OR 24 | 25 | 26 | 27 | confirmed_service_only 28 | function 29 | action_confirmed_service() 30 | OR 31 | 32 | 33 | 34 | ship 35 | function 36 | action_generate_out_move() 37 | 38 | 39 | 40 | ongoing 41 | function 42 | action_ongoing() 43 | XOR 44 | 45 | 46 | 47 | True 48 | done 49 | function 50 | write({'state' : 'done'}) 51 | 52 | 53 | 54 | cancelled 55 | function 56 | action_cancel() 57 | 58 | 59 | 62 | 63 | 64 | 65 | on_confirm_clicked 66 | not is_service_only 67 | 68 | 69 | 70 | 71 | on_confirm_clicked 72 | is_service_only 73 | 74 | 75 | 76 | 77 | on_cancel_clicked 78 | 79 | 80 | 81 | 82 | on_cancel_clicked 83 | 84 | 85 | 86 | 87 | on_force_start_clicked 88 | 89 | 90 | 91 | 92 | on_cancel_clicked 93 | 94 | 95 | 96 | 97 | True 98 | 99 | 100 | 101 | 102 | stock.move 103 | [line.id for line in out_picking_id.move_lines] 104 | test_out_shipping_done() 105 | 106 | 107 | 108 | 109 | stock.move 110 | [line.id for line in (in_picking_id.move_lines if in_picking_id else [])] 111 | test_in_shipping_done() 112 | 113 | 114 | 115 | 116 | on_force_stop_clicked 117 | 118 | 119 | 120 | 121 | on_cancel_clicked 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # OpenERP Rent documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jun 21 10:14:21 2011. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo'] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'OpenERP Rent' 44 | copyright = u'2011, Thibaut DIRLIK' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '0.4' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '0.4.0' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = [] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'jinja' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | html_theme_path = ['../themes'] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'OpenERPRentdoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | # The paper size ('letter' or 'a4'). 173 | #latex_paper_size = 'letter' 174 | 175 | # The font size ('10pt', '11pt' or '12pt'). 176 | #latex_font_size = '10pt' 177 | 178 | # Grouping the document tree into LaTeX files. List of tuples 179 | # (source start file, target name, title, author, documentclass [howto/manual]). 180 | latex_documents = [ 181 | ('index', 'OpenERPRent.tex', u'OpenERP Rent Documentation', 182 | u'Thibaut DIRLIK', 'manual'), 183 | ] 184 | 185 | # The name of an image file (relative to this directory) to place at the top of 186 | # the title page. 187 | #latex_logo = None 188 | 189 | # For "manual" documents, if this is true, then toplevel headings are parts, 190 | # not chapters. 191 | #latex_use_parts = False 192 | 193 | # If true, show page references after internal links. 194 | #latex_show_pagerefs = False 195 | 196 | # If true, show URL addresses after external links. 197 | #latex_show_urls = False 198 | 199 | # Additional stuff for the LaTeX preamble. 200 | #latex_preamble = '' 201 | 202 | # Documents to append as an appendix to all manuals. 203 | #latex_appendices = [] 204 | 205 | # If false, no module index is generated. 206 | #latex_domain_indices = True 207 | 208 | 209 | # -- Options for manual page output -------------------------------------------- 210 | 211 | # One entry per manual page. List of tuples 212 | # (source start file, name, description, authors, manual section). 213 | man_pages = [ 214 | ('index', 'openerprent', u'OpenERP Rent Documentation', 215 | [u'Thibaut DIRLIK'], 1) 216 | ] 217 | 218 | 219 | # Example configuration for intersphinx: refer to the Python standard library. 220 | intersphinx_mapping = {'http://docs.python.org/': None} 221 | -------------------------------------------------------------------------------- /rent/views/rent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | rent.order.calendar 9 | rent.order 10 | calendar 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | rent.order.tree.view 24 | rent.order 25 | tree 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |