1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2011 TeMPO Consulting, MSF
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
22
from osv import osv, fields
23
from tools.translate import _
25
class procurement_request(osv.osv):
27
_inherit = 'sale.order'
30
'requestor': fields.char(size=128, string='Requestor'),
31
'procurement_request': fields.boolean(string='Procurement Request', readonly=True),
32
'warehouse_id': fields.many2one('stock.warehouse', string='Warehouse'),
33
'origin': fields.char(size=64, string='Origin'),
34
'notes': fields.text(string='Notes'),
36
# Remove readonly parameter from sale.order class
37
'partner_id': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)]}, required=False, change_default=True, select=True),
38
'partner_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=False, states={'draft': [('readonly', False)]}, help="Invoice address for current sales order."),
39
'partner_order_id': fields.many2one('res.partner.address', 'Ordering Contact', readonly=True, required=False, states={'draft': [('readonly', False)]}, help="The name and address of the contact who requested the order or quotation."),
40
'partner_shipping_id': fields.many2one('res.partner.address', 'Shipping Address', readonly=True, required=False, states={'draft': [('readonly', False)]}, help="Shipping address for current sales order."),
41
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=False, readonly=True, states={'draft': [('readonly', False)]}, help="Pricelist for current sales order."),
42
'state': fields.selection([
43
('procurement', 'Internal Supply Requirement'),
44
('proc_progress', 'In Progress'),
45
('proc_cancel', 'Cancelled'),
46
('proc_done', 'Done'),
47
('draft', 'Quotation'),
48
('waiting_date', 'Waiting Schedule'),
49
('manual', 'Manual In Progress'),
50
('progress', 'In Progress'),
51
('shipping_except', 'Shipping Exception'),
52
('invoice_except', 'Invoice Exception'),
54
('cancel', 'Cancelled')
55
], 'Order State', readonly=True, help="Gives the state of the quotation or sales order. \nThe exception state is automatically set when a cancel operation occurs in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception). \nThe 'Waiting Schedule' state is set when the invoice is confirmed but waiting for the scheduler to run on the date 'Ordered Date'.", select=True),
59
'name': lambda obj, cr, uid, context: context.get('procurement_request', False) and obj.pool.get('ir.sequence').get(cr, uid, 'procurement.request') or obj.pool.get('ir.sequence').get(cr, uid, 'sale.order'),
60
'procurement_request': lambda obj, cr, uid, context: context.get('procurement_request', False),
61
'state': lambda self, cr, uid, c: c.get('procurement_request', False) and 'procurement' or 'draft',
65
def copy(self, cr, uid, id, default=None, context=None):
69
seq_obj = self.pool.get('ir.sequence')
70
order = self.browse(cr, uid, id)
71
name = (order.procurement_request or context.get('procurement.request', False)) and seq_obj.get(cr, uid, 'procurement.request') or seq_obj.get(cr, uid, 'sale.order')
72
proc = order.procurement_request or context.get('procurement.request', False)
79
'date_confirm': False,
81
'procurement_request': proc,
84
return super(sale_order, self).copy(cr, uid, id, default, context=context)
88
class procurement_request_line(osv.osv):
89
_name = 'sale.order.line'
90
_inherit= 'sale.order.line'
93
'procurement_request': fields.boolean(string='Procurement Request', readonly=True),
94
'supplier_id': fields.many2one('res.partner', string='Supplier'),
95
'latest': fields.char(size=64, string='Latest documents', readonly=True),
99
'procurement_request': lambda self, cr, uid, c: c.get('procurement_request', False),
102
def requested_product_id_change(self, cr, uid, ids, product_id, context={}):
104
Fills automatically the product_uom_id field on the line when the
107
product_obj = self.pool.get('product.product')
111
v.update({'product_uom': False, 'supplier_id': False})
113
product = product_obj.browse(cr, uid, product_id, context=context)
114
v.update({'product_uom': product.uom_id.id, 'supplier_id': product.seller_id.id})
118
procurement_request_line()
120
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'