diff options
| author | Pierre Masereel <pim@odoo.com> | 2016-11-02 18:05:50 +0100 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2016-11-04 16:42:28 +0100 |
| commit | 56278a2303bfb6028e44fb20fb4a2fcb937ec9fe (patch) | |
| tree | 9ec289893a4df19c113196da33250e6cb5f444c1 /addons | |
| parent | 1872b39f921efb883fdaa015c6cab7f03b3c1042 (diff) | |
[FIX] stock: _compute_package_info when children are packages
When we put a pack in a pack and try to validate the picking, we get
an error saying we are trying to create a pack operation without a
location id.
This is caused by the 'quant.package' location computation, when we
validate a picking, odoo will create the pack operations in the next
picking if there are any. And when it tries to create a pack operation
of a pack in pack, it cannot get the location id of the top level
package quant because in the compution of the location_id, it only looks
at quants having a package_id correspeding to the package. And there are
not any when the it's a package of package.
To solve this issue, we fixed the function '_compute_children_quant_ids'
that doesn't work either because of the same reasons. And then we use it
in function '_compute_package_info' to get the quants if there are any.
This bug has been introduced in rev: https://github.com/odoo/odoo/commit/fe9b31c0e703cf4f3f4f4001ab199f7a4353f9b9
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/stock/models/stock_quant.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 6e05a8b3727..62ade53bc68 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -615,21 +615,17 @@ class QuantPackage(models.Model): @api.one @api.depends('parent_id', 'children_ids', 'quant_ids.package_id') def _compute_children_quant_ids(self): - res = dict.fromkeys(self.ids, self.env['stock.quant']) - children_quants = self.env['stock.quant'].search(['package_id', 'child_of', self.ids]) - for quant in children_quants: - res[quant.package_id.id] |= quant for package in self: - package.children_quant_ids = res[package.id].ids + package.children_quant_ids = self.env['stock.quant'].search([('package_id', 'child_of', package.id)]).ids @api.depends('quant_ids.package_id', 'quant_ids.location_id', 'quant_ids.company_id', 'quant_ids.owner_id', 'ancestor_ids') def _compute_package_info(self): - res = {} - quants = self.env['stock.quant'].search([('package_id', 'in', self.ids)]) # TDE FIXME: was child_od - for quant in quants: - res[quant.package_id.id] = {'location_id': quant.location_id.id, 'owner_id': quant.owner_id.id, 'company_id': quant.company_id.id} for package in self: - values = res.get(package.id, {'location_id': False, 'company_id': self.env.user.company_id.id, 'owner_id': False}) + quants = package.children_quant_ids + if quants: + values = quants[0] + else: + values = {'location_id': False, 'company_id': self.env.user.company_id.id, 'owner_id': False} package.location_id = values['location_id'] package.company_id = values['company_id'] package.owner_id = values['owner_id'] |
