odoo/ext/custom-addons/dp_custom/models/stock.py

61 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
##############################################################################
#
# datenpol gmbh
# Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# 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/>.
#
##############################################################################
from odoo import fields, models, api, tools
class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'
assembled = fields.Boolean(string='Zusammengebaut')
notes = fields.Text()
weight = fields.Float(string='Gewicht')
intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Nummer (Code)')
image = fields.Binary("Produktbild", attachment=True,
help="Wenn vorhanden, wird dieses Bild in den Angeboten/Aufträgen angedruckt")
image_medium = fields.Binary("Produktbild (resized)", attachment=True,
help="Produktbild 'resized' auf 128x128")
@api.model
def create(self, vals):
tools.image_resize_images(vals)
return super(StockProductionLot, self).create(vals)
@api.multi
def write(self, vals):
tools.image_resize_images(vals)
return super(StockProductionLot, self).write(vals)
class StockPicking(models.Model):
_inherit = 'stock.picking'
@api.model
def _formatLang(self, value):
lang = self.partner_id.lang
lang_objs = self.env['res.lang'].search([('code', '=', lang)])
if not lang_objs:
lang_objs = self.env['res.lang'].search([], limit=1)
lang_obj = lang_objs[0]
res = lang_obj.format('%.' + str(2) + 'f', value, grouping=True, monetary=True)
return res