1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2011 MSF, TeMPO Consulting
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as
8
# published by the Free Software Foundation, either version 3 of the
9
# License, or (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
##############################################################################
21
from datetime import datetime, timedelta, date
22
from dateutil.relativedelta import relativedelta, relativedelta
23
from osv import osv, fields
24
from osv.orm import browse_record, browse_null
25
from tools.translate import _
27
import decimal_precision as dp
32
class sale_order_line(osv.osv):
34
override to add message at sale order creation and update
36
_inherit = 'sale.order.line'
38
# def create(self, cr, uid, vals, context=None):
40
# display message for short shelf life things
42
# sol_id = super(sale_order_line, self).create(cr, uid, vals, context=context)
43
# sol = self.browse(cr, uid, sol_id, context=context)
45
# if sol.product_id.short_shelf_life:
46
# self.log(cr, uid, sol_id, 'Product with short shelf life, check the accuracy of the order quantity, frequency and mode of transport.', context=context)
50
# def write(self, cr, uid, ids, vals, context=None):
52
# display message for short shelf life things
54
# if isinstance(ids, (int, long)):
57
# result = super(sale_order_line, self).write(cr, uid, ids, vals, context=context)
59
# for sol in self.browse(cr, uid, ids, context=context):
61
# if sol.product_id.short_shelf_life:
63
# self.log(cr, uid, sol.id, 'Product with short shelf life, check the accuracy of the order quantity, frequency and mode of transport.', context=context)
69
class sale_order(osv.osv):
73
_inherit = 'sale.order'
75
def write(self, cr, uid, ids, vals, context=None):
77
display message if contains short shelf life
79
if isinstance(ids, (int, long)):
82
for obj in self.browse(cr, uid, ids, context=context):
83
for line in obj.order_line:
85
if line.product_id.short_shelf_life:
87
self.log(cr, uid, obj.id, 'Product with Short Shelf Life, check the accuracy of the order quantity, frequency and mode of transport.', context=context)
89
return super(sale_order, self).write(cr, uid, ids, vals, context=context)
94
class purchase_order(osv.osv):
98
_inherit = 'purchase.order'
100
# def wkf_confirm_order(self, cr, uid, ids, context=None):
104
# result = super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context=context)
110
def write(self, cr, uid, ids, vals, context=None):
112
display message if contains short shelf life
114
if isinstance(ids, (int, long)):
117
for obj in self.browse(cr, uid, ids, context=context):
118
for line in obj.order_line:
120
if line.product_id.short_shelf_life:
122
self.log(cr, uid, obj.id, 'Product with Short Shelf Life, check the accuracy of the order quantity, frequency and mode of transport.', context=context)
124
return super(purchase_order, self).write(cr, uid, ids, vals, context=context)