|
|
@ -2,8 +2,23 @@ |
|
|
|
############################################################################## |
|
|
|
# |
|
|
|
# Cybrosys Technologies Pvt. Ltd. |
|
|
|
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
|
|
# Maintainer: Cybrosys Technologies (<https://www.cybrosys.com>) |
|
|
|
# Copyright (C) 2009-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|
|
|
# Author: fasluca(<https://www.cybrosys.com>) |
|
|
|
# you can modify it under the terms of the GNU LESSER |
|
|
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|
|
|
# |
|
|
|
# It is forbidden to publish, distribute, sublicense, or sell copies |
|
|
|
# of the Software or modified copies of the Software. |
|
|
|
# |
|
|
|
# This program is distributed in the hope that it will be useful, |
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|
|
|
# |
|
|
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|
|
|
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. |
|
|
|
# If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# |
|
|
|
############################################################################## |
|
|
|
|
|
|
|
from odoo import api, models, fields, _ |
|
|
@ -24,6 +39,10 @@ class MrpProduction(models.Model): |
|
|
|
('cancel', 'Cancelled')], string='State', |
|
|
|
copy=False, default='draft', track_visibility='onchange') |
|
|
|
|
|
|
|
_sql_constraints = [ |
|
|
|
('name_uniq', 'check(1=1)', 'Reference must be unique per Company!'), |
|
|
|
] |
|
|
|
|
|
|
|
@api.model |
|
|
|
def create(self, values): |
|
|
|
production = super(mp, self).create(values) |
|
|
@ -33,13 +52,12 @@ class MrpProduction(models.Model): |
|
|
|
def unlink(self): |
|
|
|
if any(production.state not in ['draft', 'cancel'] for production in self): |
|
|
|
raise UserError(_('Cannot delete a manufacturing order not in draft or cancel state')) |
|
|
|
return super(MrpProduction, self).unlink() |
|
|
|
return super(mp, self).unlink() |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def action_confirm(self): |
|
|
|
if not self.name or self.name == _('New'): |
|
|
|
self.name = self.env['ir.sequence'].next_by_code('mrp.production') or _('New') |
|
|
|
print self.name |
|
|
|
if not self.procurement_group_id: |
|
|
|
self.procurement_group_id = self.env["procurement.group"].create({'name': self.name}).id |
|
|
|
self._generate_moves() |
|
|
|