Files
manufacture/mrp_multi_level/models/product_template.py
Lois Rilo e6e1af8da9 [11.0] mrp_multi_level:
* fix api.depends fields fro main supplier.
 * fix ordering and missing demo file in manifest.
 * Update README.
 * fix action_view* methods.
 * readd hook to exclude in mrp initialization
 * fix computation of qty available (it was considering several times sub-locations).
 * Remove contraint for outoing and incoming moves to be moved in/outside the company, they can be internal transfers.
 * mrp.moves visible with technical settings.
 * Show product and allow to search by it in mrp.inventory.
2022-11-21 11:16:14 +01:00

40 lines
1.3 KiB
Python

# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
mrp_area_ids = fields.One2many(
comodel_name='product.mrp.area',
inverse_name='product_tmpl_id',
string='MRP Area parameters',
)
mrp_area_count = fields.Integer(
string='MRP Area Parameter Count',
readonly=True,
compute='_compute_mrp_area_count',
)
@api.multi
def _compute_mrp_area_count(self):
for rec in self:
rec.mrp_area_count = len(rec.mrp_area_ids)
@api.multi
def action_view_mrp_area_parameters(self):
self.ensure_one()
action = self.env.ref('mrp_multi_level.product_mrp_area_action')
result = action.read()[0]
mrp_area_ids = self.with_context(
active_test=False).mrp_area_ids.ids
if len(mrp_area_ids) != 1:
result['domain'] = [('id', 'in', mrp_area_ids)]
else:
res = self.env.ref('mrp_multi_level.product_mrp_area_form', False)
result['views'] = [(res and res.id or False, 'form')]
result['res_id'] = mrp_area_ids[0]
return result