1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
5
# Author: Nicola Malcontenti <nicola.malcontenti@agilebg.com>
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 published
9
# by the Free Software Foundation, either version 3 of the License, or
10
# (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
##############################################################################
21
from openerp.osv import fields, orm
23
class account_invoice(orm.Model):
24
_inherit = 'account.invoice'
26
def _get_product_customer_code(self, cr, uid, ids,
27
name, args, context=None):
31
product_customer_code_obj = self.pool.get('product.customer.code')
32
for line in self.browse(cr, uid, ids, context=context):
34
partner = line.order_id.partner_id
35
product = line.product_id
36
if product and partner:
37
code_ids = product_customer_code_obj.search(cr, uid, [
38
('product_id', '=', product.id),
39
('partner_id', '=', partner.id),
40
], limit=1, context=context)
42
code = product_customer_code_obj.browse(cr, uid,
43
code_ids[0], context=context).code or ''
48
'product_customer_code': fields.function(_get_product_customer_code,
49
string='Product Customer Code', type='char', size=64),
b'\\ No newline at end of file'