[11.0][FIX] mrp_multi_level: fix supply method computation and add required fields.

This commit is contained in:
Lois Rilo
2019-06-03 14:51:54 +02:00
committed by JasminSForgeFlow
parent 55b8703ea7
commit 91bee78ae7
4 changed files with 7 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ class MrpInventory(models.Model):
product_mrp_area_id = fields.Many2one( product_mrp_area_id = fields.Many2one(
comodel_name='product.mrp.area', string='Product Parameters', comodel_name='product.mrp.area', string='Product Parameters',
index=True, index=True,
required=True,
) )
product_id = fields.Many2one( product_id = fields.Many2one(
comodel_name='product.product', comodel_name='product.product',

View File

@@ -14,6 +14,7 @@ class MrpMove(models.Model):
product_mrp_area_id = fields.Many2one( product_mrp_area_id = fields.Many2one(
comodel_name="product.mrp.area", comodel_name="product.mrp.area",
string="Product", index=True, string="Product", index=True,
required=True,
) )
mrp_area_id = fields.Many2one( mrp_area_id = fields.Many2one(
comodel_name="mrp.area", comodel_name="mrp.area",

View File

@@ -15,6 +15,7 @@ class MrpPlannedOrder(models.Model):
comodel_name="product.mrp.area", comodel_name="product.mrp.area",
string="Product", string="Product",
index=True, index=True,
required=True,
) )
mrp_area_id = fields.Many2one( mrp_area_id = fields.Many2one(
comodel_name="mrp.area", comodel_name="mrp.area",
@@ -22,11 +23,13 @@ class MrpPlannedOrder(models.Model):
string="MRP Area", string="MRP Area",
store=True, store=True,
index=True, index=True,
readonly=True,
) )
product_id = fields.Many2one( product_id = fields.Many2one(
comodel_name="product.product", comodel_name="product.product",
related="product_mrp_area_id.product_id", related="product_mrp_area_id.product_id",
store=True, store=True,
readonly=True,
) )
order_release_date = fields.Date( order_release_date = fields.Date(
string="Release Date", string="Release Date",

View File

@@ -131,13 +131,13 @@ class ProductMRPArea(models.Model):
def _compute_supply_method(self): def _compute_supply_method(self):
group_obj = self.env['procurement.group'] group_obj = self.env['procurement.group']
for rec in self: for rec in self:
proc_loc = rec.location_proc_id or rec.mrp_area_id.location_id
values = { values = {
'warehouse_id': rec.mrp_area_id.warehouse_id, 'warehouse_id': rec.mrp_area_id.warehouse_id,
'company_id': self.env.user.company_id.id, 'company_id': self.env.user.company_id.id,
# TODO: better way to get company # TODO: better way to get company
} }
rule = group_obj._get_rule( rule = group_obj._get_rule(rec.product_id, proc_loc, values)
rec.product_id, rec.mrp_area_id.location_id, values)
rec.supply_method = rule.action if rule else 'none' rec.supply_method = rule.action if rule else 'none'
@api.multi @api.multi