1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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
25 class res_partner(osv.osv):
26 _inherit = 'res.partner'
28 'property_invoice_type': fields.property(
29 'sale_journal.invoice.type',
31 relation='sale_journal.invoice.type',
32 string="Invoicing Method",
35 group_name="Accounting Properties",
36 help="The type of journal used for sales and picking."),
40 class picking(osv.osv):
41 _inherit="stock.picking"
43 'journal_id': fields.many2one('sale_journal.picking.journal', 'Journal'),
44 'sale_journal_id': fields.many2one('sale_journal.sale.journal', 'Sale Journal'),
45 'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoice Type', readonly=True)
52 'journal_id': fields.many2one('sale_journal.sale.journal', 'Journal'),
53 'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoice Type')
55 def action_ship_create(self, cr, uid, ids, *args):
56 result = super(sale, self).action_ship_create(cr, uid, ids, *args)
57 for order in self.browse(cr, uid, ids, context={}):
58 pids = [ x.id for x in order.picking_ids]
59 self.pool.get('stock.picking').write(cr, uid, pids, {
60 'invoice_type_id': order.invoice_type_id.id,
61 'sale_journal_id': order.journal_id.id
65 def onchange_partner_id(self, cr, uid, ids, part):
66 result = super(sale, self).onchange_partner_id(cr, uid, ids, part)
68 itype = self.pool.get('res.partner').browse(cr, uid, part).property_invoice_type.id
69 result['value']['invoice_type_id'] = itype
72 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: