forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port sale_start_end_dates and sale_rental (OCA#353)
- Loading branch information
1 parent
c80a2ad
commit 0f5d788
Showing
22 changed files
with
909 additions
and
941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Sale Rental module for Odoo | ||
# Copyright (C) 2014-2015 Akretion (http://www.akretion.com) | ||
# @author Alexis de Lattre <alexis.delattre@akretion.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import rental | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,27 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Rental module for Odoo | ||
# Copyright (C) 2014-2015 Akretion (http://www.akretion.com) | ||
# @author Alexis de Lattre <alexis.delattre@akretion.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
# -*- coding: utf-8 -*- | ||
# © 2014-2016 Akretion (http://www.akretion.com) | ||
# @author Alexis de Lattre <alexis.delattre@akretion.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Rental', | ||
'version': '8.0.0.1.0', | ||
'version': '9.0.1.0.0', | ||
'category': 'Sales Management', | ||
'license': 'AGPL-3', | ||
'summary': 'Manage Rental of Products', | ||
'author': 'Akretion', | ||
'author': 'Akretion, Odoo Community Association (OCA)', | ||
'website': 'http://www.akretion.com', | ||
'depends': ['sale_start_end_dates', 'stock'], | ||
'depends': ['sale_start_end_dates', 'sale_stock'], | ||
'data': [ | ||
'sale_view.xml', | ||
'stock_view.xml', | ||
'rental_view.xml', | ||
'rental_data.xml', | ||
'data/rental_data.xml', | ||
'views/sale_order.xml', | ||
'views/stock.xml', | ||
'views/sale_rental.xml', | ||
'wizard/create_rental_product_view.xml', | ||
'product_view.xml', | ||
'views/product.xml', | ||
'security/ir.model.access.csv', | ||
'security/sale_rental_security.xml', | ||
], | ||
'demo': ['rental_demo.xml'], | ||
'installable': False, | ||
'demo': ['demo/rental_demo.xml'], | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
© 2014-2016 Akretion (http://www.akretion.com/) | ||
@author Alexis de Lattre <alexis.delattre@akretion.com> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
|
||
<odoo noupdate="1"> | ||
|
||
<record id="route_warehouse0_rental" model="stock.location.route"> | ||
<field name="name">Rent</field> | ||
<field name="sequence">100</field> | ||
<field name="warehouse_selectable" eval="True"/> | ||
<field name="product_selectable" eval="False"/> | ||
</record> | ||
|
||
<record id="route_warehouse0_sell_rented_product" model="stock.location.route"> | ||
<field name="name">Sell Rented Product</field> | ||
<field name="sequence">100</field> | ||
</record> | ||
|
||
<record id="stock.warehouse0" model="stock.warehouse"> | ||
<field name="rental_allowed" eval="True"/> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import product | ||
from . import sale_order | ||
from . import sale_rental | ||
from . import stock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2016 Akretion (http://www.akretion.com) | ||
# @author Alexis de Lattre <alexis.delattre@akretion.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields, api, _ | ||
from openerp.exceptions import ValidationError | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = 'product.product' | ||
|
||
# Link rental service -> rented HW product | ||
rented_product_id = fields.Many2one( | ||
'product.product', string='Related Rented Product', | ||
domain=[('type', 'in', ('product', 'consu'))]) | ||
# Link rented HW product -> rental service | ||
rental_service_ids = fields.One2many( | ||
'product.product', 'rented_product_id', | ||
string='Related Rental Services') | ||
|
||
@api.one | ||
@api.constrains('rented_product_id', 'must_have_dates', 'type', 'uom_id') | ||
def _check_rental(self): | ||
if self.rented_product_id and self.type != 'service': | ||
raise ValidationError(_( | ||
"The rental product '%s' must be of type 'Service'.") | ||
% self.name) | ||
if self.rented_product_id and not self.must_have_dates: | ||
raise ValidationError(_( | ||
"The rental product '%s' must have the option " | ||
"'Must Have Start and End Dates' checked.") | ||
% self.name) | ||
# In the future, we would like to support all time UoMs | ||
# but it is more complex and requires additionnal developments | ||
day_uom = self.env.ref('product.product_uom_day') | ||
if self.rented_product_id and self.uom_id != day_uom: | ||
raise ValidationError(_( | ||
"The unit of measure of the rental product '%s' must " | ||
"be 'Day'.") % self.name) | ||
|
||
@api.multi | ||
def _need_procurement(self): | ||
# Missing self.ensure_one() in the native code ! | ||
res = super(ProductProduct, self)._need_procurement() | ||
if not res: | ||
for product in self: | ||
if product.type == 'service' and product.rented_product_id: | ||
return True | ||
# TODO find a replacement for soline.rental_type == 'new_rental') | ||
return res |
Oops, something went wrong.