mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
move constrain to product
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import stock_warehouse_orderpoint
|
||||
from . import product_template
|
||||
|
||||
23
stock_orderpoint_uom/models/product_template.py
Normal file
23
stock_orderpoint_uom/models/product_template.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
@api.constrains('uom_id')
|
||||
def _check_orderpoint_procure_uom(self):
|
||||
for rec in self:
|
||||
orderpoint = self.env['stock.warehouse.orderpoint'].search([
|
||||
('procure_uom_id.category_id', '!=',
|
||||
rec.uom_id.category_id.id),
|
||||
('product_id.product_tmpl_id', '=', rec.id)], limit=1)
|
||||
if orderpoint:
|
||||
raise UserError(
|
||||
_("At least one reordering rule for this product has a "
|
||||
"different Procurement unit of measure category."))
|
||||
@@ -13,8 +13,7 @@ class Orderpoint(models.Model):
|
||||
procure_uom_id = fields.Many2one(comodel_name='product.uom',
|
||||
string="Procurement UoM")
|
||||
|
||||
@api.constrains('product_id', 'product_id.product_tmpl_id.uom_id',
|
||||
'procure_uom_id')
|
||||
@api.constrains('product_id', 'procure_uom_id')
|
||||
def _check_procure_uom(self):
|
||||
if any(orderpoint.product_uom and
|
||||
orderpoint.procure_uom_id and
|
||||
|
||||
Reference in New Issue
Block a user