Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I'm trying to add a field to stock.picking that would compute the set of packages created during the transfer operation.
stock.picking has a One2many relation to the package operations, and each package operation has a Many2one relation with the resulting package, so the relations might look like this:
Picking A is related to 3 Pack Ops: [1, 2, 3].
Pack Op 1 is related to Package x.
Pack Op 2 and 3 are both related to package y.
I want the set of packages [x, y]. However, if I loop through the packing operations, I will get [x, y, y]. I need this set in a QWeb template, so I don't have access to full Python functionality.
This is the code I have so far:
# -*- coding: utf-8 -*-
from openerp import models, fields, api
_logger = logging.getLogger(__name__)
_inherit = 'stock.picking'
self.result_packages = self.mapped('pack_operation_ids.result_package_id')
result_packages = fields.One2many(compute=_compute_result_packages, comodel_name='stock.quant.package')
However, updating the module where this Python file is imported does not change the model (checked via Settings -> Technical -> Database Structure -> Models and via erppeek 1.6.1).
There are other changes in the same file that are successfully applied, so it seems I must have defined the field incorrectly.
How do I set up a computed field for this kind of relation?
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 6/22/15, 2:33 AM|
|Seen: 808 times|
|Last updated: 6/22/15, 2:35 AM|