2013-07-16 09:36:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
2013-08-12 16:31:23 +00:00
|
|
|
# Copyright (C)-2010 Tiny SPRL (<http://tiny.be>).
|
2013-07-16 09:36:24 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
2013-08-12 16:31:23 +00:00
|
|
|
# published by the Free Software Foundation, either version of the
|
2013-07-16 09:36:24 +00:00
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2013-09-02 10:46:46 +00:00
|
|
|
from openerp import SUPERUSER_ID
|
2013-10-08 15:22:33 +00:00
|
|
|
from openerp.osv import osv, fields
|
2013-07-16 09:36:24 +00:00
|
|
|
|
2013-09-24 12:19:44 +00:00
|
|
|
class sale_order(osv.Model):
|
2013-08-12 16:31:23 +00:00
|
|
|
_inherit = "sale.order"
|
2013-09-24 12:19:44 +00:00
|
|
|
|
2013-10-08 15:22:33 +00:00
|
|
|
_columns = {
|
|
|
|
'website_session_id': fields.char('Session UUID4'),
|
|
|
|
}
|
|
|
|
|
2013-08-12 16:31:23 +00:00
|
|
|
def get_total_quantity(self, cr, uid, ids, context=None):
|
|
|
|
order = self.browse(cr, uid, ids[0], context=context)
|
2013-10-03 11:23:54 +00:00
|
|
|
return int(sum(l.product_uom_qty for l in (order.order_line or [])))
|
2013-09-02 10:46:46 +00:00
|
|
|
|
2013-09-24 12:19:44 +00:00
|
|
|
|
|
|
|
class sale_order_line(osv.Model):
|
2013-09-02 10:46:46 +00:00
|
|
|
_inherit = "sale.order.line"
|
2013-09-24 12:19:44 +00:00
|
|
|
|
2013-10-02 07:12:39 +00:00
|
|
|
def _recalculate_product_values(self, cr, uid, ids, product_id=0, context=None):
|
2013-09-24 12:19:44 +00:00
|
|
|
if context is None:
|
|
|
|
context = {}
|
2013-09-02 10:46:46 +00:00
|
|
|
user_obj = self.pool.get('res.users')
|
2013-12-03 15:44:22 +00:00
|
|
|
product_id = product_id or ids and self.browse(cr, uid, ids[0], context=context).product_id.id
|
2013-10-02 07:12:39 +00:00
|
|
|
|
2013-09-24 12:19:44 +00:00
|
|
|
return self.product_id_change(
|
2013-10-02 07:12:39 +00:00
|
|
|
cr, SUPERUSER_ID, ids,
|
2013-09-02 10:46:46 +00:00
|
|
|
pricelist=context.pop('pricelist'),
|
|
|
|
product=product_id,
|
|
|
|
partner_id=user_obj.browse(cr, SUPERUSER_ID, uid).partner_id.id,
|
2013-09-24 12:19:44 +00:00
|
|
|
context=context
|
|
|
|
)['value']
|