You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
4.0 KiB
106 lines
4.0 KiB
# -*- coding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
|
|
# Author: Cybrosys Technologies(<http://www.cybrosys.com>)
|
|
# you can modify it under the terms of the GNU LESSER
|
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
|
|
#
|
|
# It is forbidden to publish, distribute, sublicense, or sell copies
|
|
# of the Software or modified copies of the Software.
|
|
#
|
|
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
|
|
#
|
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
|
|
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
|
|
from openerp import fields, models, api
|
|
|
|
|
|
class OrderLineImage(models.Model):
|
|
_inherit = 'sale.order.line'
|
|
|
|
image = fields.Binary(string="Image")
|
|
|
|
@api.multi
|
|
@api.onchange('product_id')
|
|
def product_id_change(self):
|
|
if not self.product_id:
|
|
return {'domain': {'product_uom': []}}
|
|
|
|
vals = {}
|
|
self.image = self.product_id.image_medium
|
|
domain = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
|
|
if not self.product_uom or (self.product_id.uom_id.id != self.product_uom.id):
|
|
vals['product_uom'] = self.product_id.uom_id
|
|
vals['product_uom_qty'] = 1.0
|
|
|
|
product = self.product_id.with_context(
|
|
lang=self.order_id.partner_id.lang,
|
|
partner=self.order_id.partner_id.id,
|
|
quantity=vals.get('product_uom_qty') or self.product_uom_qty,
|
|
date=self.order_id.date_order,
|
|
pricelist=self.order_id.pricelist_id.id,
|
|
uom=self.product_uom.id
|
|
)
|
|
|
|
name = product.name_get()[0][1]
|
|
if product.description_sale:
|
|
name += '\n' + product.description_sale
|
|
vals['name'] = name
|
|
|
|
self._compute_tax_id()
|
|
|
|
if self.order_id.pricelist_id and self.order_id.partner_id:
|
|
vals['price_unit'] = self.env['account.tax']._fix_tax_included_price(product.price, product.taxes_id,
|
|
self.tax_id)
|
|
self.update(vals)
|
|
return {'domain': domain}
|
|
|
|
|
|
class ReportImage(models.Model):
|
|
_inherit = 'sale.order'
|
|
|
|
@api.multi
|
|
def print_quotation(self):
|
|
self.filtered(lambda s: s.state == 'draft').write({'state': 'sent'})
|
|
return self.env['report'].get_action(self, 'sale_product_image.report_saleorder')
|
|
|
|
@api.multi
|
|
def action_quotation_send(self):
|
|
self.ensure_one()
|
|
ir_model_data = self.env['ir.model.data']
|
|
try:
|
|
template_id = ir_model_data.get_object_reference('sale_product_image', 'email_template_edi_sales')[1]
|
|
except ValueError:
|
|
template_id = False
|
|
try:
|
|
compose_form_id = ir_model_data.get_object_reference('mail', 'email_compose_message_wizard_form')[1]
|
|
except ValueError:
|
|
compose_form_id = False
|
|
ctx = dict()
|
|
ctx.update({
|
|
'default_model': 'sale.order',
|
|
'default_res_id': self.ids[0],
|
|
'default_use_template': bool(template_id),
|
|
'default_template_id': template_id,
|
|
'default_composition_mode': 'comment',
|
|
'mark_so_as_sent': True
|
|
})
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'view_type': 'form',
|
|
'view_mode': 'form',
|
|
'res_model': 'mail.compose.message',
|
|
'views': [(compose_form_id, 'form')],
|
|
'view_id': compose_form_id,
|
|
'target': 'new',
|
|
'context': ctx,
|
|
}
|
|
|