-
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crm_rma_stock_location: Migration V9
- Loading branch information
Cyril Gaudin
committed
May 12, 2016
1 parent
2f0b2ff
commit dff5d17
Showing
14 changed files
with
397 additions
and
313 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
================== | ||
RMA Stock Location | ||
================== | ||
|
||
A RMA location can be selected on the warehouses. | ||
The product views displays the quantity available and virtual in this | ||
RMA location (including the children locations). | ||
|
||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/145/9.0 | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/rma/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Guewen Baconnier <guewen.baconnier@camptocamp.com> | ||
* Cyril Gaudin <cyril.gaudin@camptocamp.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
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,23 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Guewen Baconnier | ||
# Copyright 2014 Camptocamp SA | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
|
||
from . import stock_warehouse | ||
from . import product | ||
from . import models |
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,49 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Guewen Baconnier | ||
# Copyright 2014 Camptocamp SA | ||
# | ||
# 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/>. | ||
# | ||
############################################################################## | ||
# © 2014-2016 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
{'name': 'RMA Stock Location', | ||
'version': '1.0', | ||
'version': '9.0.1.0.0', | ||
'author': "Camptocamp,Odoo Community Association (OCA)", | ||
'maintainer': 'Camptocamp', | ||
'license': 'AGPL-3', | ||
'category': 'Generic Modules/CRM & SRM', | ||
'depends': ['stock', | ||
'procurement', | ||
], | ||
'description': """ | ||
RMA Stock Location | ||
================== | ||
A RMA location can be selected on the warehouses. | ||
The product views displays the quantity available and virtual in this | ||
RMA location (including the children locations). | ||
""", | ||
'depends': [ | ||
'crm_rma_location', | ||
], | ||
'website': 'http://www.camptocamp.com', | ||
'data': ['stock_data.xml', | ||
'stock_warehouse_view.xml', | ||
'product_view.xml', | ||
], | ||
'test': ['test/quantity.yml', | ||
], | ||
'installable': False, | ||
'data': [ | ||
'data/stock.xml', | ||
'views/product_view.xml', | ||
], | ||
'installable': True, | ||
'auto_install': False, | ||
} |
File renamed without changes.
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,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import product |
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,99 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2016 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import api, fields, models | ||
import openerp.addons.decimal_precision as dp | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = 'product.template' | ||
|
||
rma_qty_available = fields.Float( | ||
compute='_compute_rma_template_quantities', | ||
digits_compute=dp.get_precision('Product Unit of Measure'), | ||
string='RMA Quantity On Hand' | ||
) | ||
rma_virtual_available = fields.Float( | ||
compute='_compute_rma_template_quantities', | ||
digits_compute=dp.get_precision('Product Unit of Measure'), | ||
string='RMA Forecasted Quantity' | ||
) | ||
|
||
@api.depends('product_variant_ids.rma_qty_available', | ||
'product_variant_ids.rma_virtual_available') | ||
def _compute_rma_template_quantities(self): | ||
""" Compute rma_qty_available and rma_virtual_available | ||
with sum of variants quantities. | ||
""" | ||
|
||
for template in self: | ||
qantities = template.product_variant_ids.read( | ||
['rma_qty_available', 'rma_virtual_available'] | ||
) | ||
template.rma_qty_available = sum( | ||
qty['rma_qty_available'] for qty in qantities | ||
) | ||
template.rma_virtual_available = sum( | ||
qty['rma_virtual_available'] for qty in qantities | ||
) | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = 'product.product' | ||
|
||
rma_qty_available = fields.Float( | ||
compute='_compute_rma_product_quantities', | ||
digits_compute=dp.get_precision('Product Unit of Measure'), | ||
string='RMA Quantity On Hand' | ||
) | ||
rma_virtual_available = fields.Float( | ||
compute='_compute_rma_product_quantities', | ||
digits_compute=dp.get_precision('Product Unit of Measure'), | ||
string='RMA Forecasted Quantity' | ||
) | ||
|
||
def _compute_rma_product_quantities(self): | ||
""" Compute both rma_qty_available and rma_virtual_available values | ||
by calling product_product._product_available with RMA locations | ||
in context. | ||
""" | ||
warehouse_model = self.env['stock.warehouse'] | ||
|
||
locations = self.env['stock.location'] | ||
|
||
warehouse_id = self.env.context.get('warehouse_id') | ||
if warehouse_id: | ||
warehouse = warehouse_model.browse(warehouse_id) | ||
if warehouse.lot_rma_id: | ||
locations |= warehouse.lot_rma_id | ||
|
||
else: | ||
warehouses = warehouse_model.search([('lot_rma_id', '!=', False)]) | ||
locations |= warehouses.mapped('lot_rma_id') | ||
|
||
if locations: | ||
result = self.with_context( | ||
# Sorted by parent_left to avoid a little Odoo bug | ||
# in tests environnement | ||
# see https://github.com/odoo/odoo/pull/11996 | ||
location=locations.sorted( | ||
lambda l: l.parent_left | ||
).mapped('id'), | ||
)._product_available() | ||
|
||
else: | ||
result = {} | ||
|
||
for product in self: | ||
try: | ||
product_qties = result[product.id] | ||
except KeyError: | ||
product.rma_qty_available = 0 | ||
product.rma_virtual_available = 0 | ||
|
||
else: | ||
product.rma_qty_available = product_qties['qty_available'] | ||
product.rma_virtual_available = product_qties[ | ||
'virtual_available' | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.