1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2011 Tiny SPRL (<http://tiny.be>).
6
# Copyright (C) 2011 Camptocamp Austria (<http://www.camptocamp.com>).
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Affero General Public License as
10
# published by the Free Software Foundation, either version 3 of the
11
# License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU Affero General Public License for more details.
18
# You should have received a copy of the GNU Affero General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
22
from osv import fields, osv, orm
23
from tools.translate import _
24
import one2many_sorted
26
class purchase_order(osv.osv):
27
_inherit = "purchase.order"
29
def _print_uom(self, cr, uid, ids, name, args, context=None):
31
for order in self.browse(cr, uid, ids, context=context):
34
for line in order.order_line:
36
res[order.id] = print_uom
40
def _print_ean(self, cr, uid, ids, name, args, context=None):
42
for order in self.browse(cr, uid, ids, context=context):
44
if order.order_line and order.company_id.print_ean:
45
for line in order.order_line:
46
if line.product_packaging.ean or line.product_id.ean13 :
48
res[order.id] = print_ean
51
def _print_code(self, cr, uid, ids, name, args, context=None):
53
for order in self.browse(cr, uid, ids, context=context):
56
for line in order.order_line:
57
if line.product_id.default_code:
59
res[order.id] = print_code
62
def _get_cols(self, cr, uid, ids, name, args, context=None):
64
for order in self.browse(cr, uid, ids, context=context):
79
'print_uom': fields.function(_print_uom, method=True, type='boolean', string='Print UoM if different from UoS',),
80
'print_ean': fields.function(_print_ean, method=True, type='boolean', string='Print EAN if available',),
81
'print_code': fields.function(_print_code, method=True, type='boolean', string='Print code if available',),
82
'cols': fields.function(_get_cols, method=True, type='integer', string='No of columns before totals',),
83
'order_line_sorted' : one2many_sorted.one2many_sorted
84
( 'purchase.order.line'
86
, 'Order Lines Sorted'
87
, states={'draft': [('readonly', False)]}
88
, order = 'product_id.name,name'
90
# 'order_line' : one2many_sorted.one2many_sorted
91
# ( 'purchase.order.line'
93
# , 'Order Lines Sorted'
94
# , states={'draft': [('readonly', False)]}
95
# , order = 'product_id.name,name'