← Back to team overview

openerp-community-reviewer team mailing list archive

Re: [Merge] lp:~agilebg/account-invoice-report/adding_account_invoice_production_lot_7 into lp:~account-core-editors/account-invoice-report/7.0

 

does anyone know how to make the S/N text translatable?

> u'<li>S/N {0}</li>'.format(lot.name)

I would like to have it translated in the right language in my webkit invoices
many thanks

Diff comments:

> === added directory 'account_invoice_production_lot'
> === added file 'account_invoice_production_lot/__init__.py'
> --- account_invoice_production_lot/__init__.py	1970-01-01 00:00:00 +0000
> +++ account_invoice_production_lot/__init__.py	2014-01-02 10:05:23 +0000
> @@ -0,0 +1,24 @@
> +# -*- coding: utf-8 -*-
> +##############################################################################
> +#
> +#    OpenERP, Open Source Management Solution
> +#    Author: Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
> +#    Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
> +#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
> +#
> +#    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 . import invoice
> 
> === added file 'account_invoice_production_lot/__openerp__.py'
> --- account_invoice_production_lot/__openerp__.py	1970-01-01 00:00:00 +0000
> +++ account_invoice_production_lot/__openerp__.py	2014-01-02 10:05:23 +0000
> @@ -0,0 +1,49 @@
> +# -*- coding: utf-8 -*-
> +##############################################################################
> +#
> +#    OpenERP, Open Source Management Solution
> +#    Author: Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
> +#    Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
> +#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
> +#
> +#    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/>.
> +#
> +##############################################################################
> +
> +
> +{
> +    "name": "Invoice Production Lots",
> +    "version": "1.1",
> +    'category': 'Generic Modules/Accounting',
> +    "depends": [
> +        "sale_stock",
> +        "invoice_webkit",
> +        ],
> +    "author": "Agile Business Group",
> +    "summary": "Display delivered serial numbers in invoice",
> +    "description": """
> +This module prints, for each (customer) invoice line, the delivered production
> +lots. The serial numbers are displayed in the "formatted note" field,
> +introduced by invoice_webkit module""",
> +    'website': 'http://www.agilebg.com',
> +    'data': [
> +        'invoice_view.xml',
> +        ],
> +    'demo': [],
> +    'test': [
> +        'test/sale.yml',
> +        ],
> +    'installable': True,
> +    'active': False,
> +}
> 
> === added directory 'account_invoice_production_lot/i18n'
> === added file 'account_invoice_production_lot/i18n/account_invoice_production_lot.pot'
> --- account_invoice_production_lot/i18n/account_invoice_production_lot.pot	1970-01-01 00:00:00 +0000
> +++ account_invoice_production_lot/i18n/account_invoice_production_lot.pot	2014-01-02 10:05:23 +0000
> @@ -0,0 +1,53 @@
> +# Translation of OpenERP Server.
> +# This file contains the translation of the following modules:
> +#	* account_invoice_production_lot
> +#
> +msgid ""
> +msgstr ""
> +"Project-Id-Version: OpenERP Server 7.0\n"
> +"Report-Msgid-Bugs-To: \n"
> +"POT-Creation-Date: 2013-08-23 08:50+0000\n"
> +"PO-Revision-Date: 2013-08-23 08:50+0000\n"
> +"Last-Translator: <>\n"
> +"Language-Team: \n"
> +"MIME-Version: 1.0\n"
> +"Content-Type: text/plain; charset=UTF-8\n"
> +"Content-Transfer-Encoding: \n"
> +"Plural-Forms: \n"
> +
> +#. module: account_invoice_production_lot
> +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice
> +msgid "Invoice"
> +msgstr ""
> +
> +#. module: account_invoice_production_lot
> +#: view:account.invoice:0
> +msgid "Load Lines Lots"
> +msgstr ""
> +
> +#. module: account_invoice_production_lot
> +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice_line
> +msgid "Invoice Line"
> +msgstr ""
> +
> +#. module: account_invoice_production_lot
> +#: field:account.invoice.line,displayed_lot_id:0
> +msgid "Lot"
> +msgstr ""
> +
> +#. module: account_invoice_production_lot
> +#: view:account.invoice.line:0
> +#: field:account.invoice.line,prod_lot_ids:0
> +msgid "Production Lots"
> +msgstr ""
> +
> +#. module: account_invoice_production_lot
> +#: field:account.invoice.line,order_lines:0
> +msgid "Order Lines"
> +msgstr ""
> +
> +#. module: account_invoice_production_lot
> +#: view:account.invoice:0
> +msgid "This will overwrite the formatted note. Continue?"
> +msgstr ""
> +
> 
> === added file 'account_invoice_production_lot/i18n/it.po'
> --- account_invoice_production_lot/i18n/it.po	1970-01-01 00:00:00 +0000
> +++ account_invoice_production_lot/i18n/it.po	2014-01-02 10:05:23 +0000
> @@ -0,0 +1,52 @@
> +# Translation of OpenERP Server.
> +# This file contains the translation of the following modules:
> +# 	* account_invoice_production_lot
> +#
> +msgid ""
> +msgstr ""
> +"Project-Id-Version: OpenERP Server 7.0\n"
> +"Report-Msgid-Bugs-To: \n"
> +"POT-Creation-Date: 2013-08-23 08:49+0000\n"
> +"PO-Revision-Date: 2013-08-23 10:51+0100\n"
> +"Last-Translator: Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>\n"
> +"Language-Team: \n"
> +"MIME-Version: 1.0\n"
> +"Content-Type: text/plain; charset=UTF-8\n"
> +"Content-Transfer-Encoding: 8bit\n"
> +"Plural-Forms: \n"
> +"X-Generator: Poedit 1.5.4\n"
> +
> +#. module: account_invoice_production_lot
> +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice
> +msgid "Invoice"
> +msgstr "Fattura"
> +
> +#. module: account_invoice_production_lot
> +#: view:account.invoice:0
> +msgid "Load Lines Lots"
> +msgstr "Carica i lotti delle righe"
> +
> +#. module: account_invoice_production_lot
> +#: model:ir.model,name:account_invoice_production_lot.model_account_invoice_line
> +msgid "Invoice Line"
> +msgstr "Righe Fattura"
> +
> +#. module: account_invoice_production_lot
> +#: field:account.invoice.line,displayed_lot_id:0
> +msgid "Lot"
> +msgstr "Lotto"
> +
> +#. module: account_invoice_production_lot
> +#: view:account.invoice.line:0 field:account.invoice.line,prod_lot_ids:0
> +msgid "Production Lots"
> +msgstr "Lotti di produzione"
> +
> +#. module: account_invoice_production_lot
> +#: field:account.invoice.line,order_lines:0
> +msgid "Order Lines"
> +msgstr "Righe ordine"
> +
> +#. module: account_invoice_production_lot
> +#: view:account.invoice:0
> +msgid "This will overwrite the formatted note. Continue?"
> +msgstr "Questo sovrascriverà la note formattate. Continuare?"
> 
> === added file 'account_invoice_production_lot/invoice.py'
> --- account_invoice_production_lot/invoice.py	1970-01-01 00:00:00 +0000
> +++ account_invoice_production_lot/invoice.py	2014-01-02 10:05:23 +0000
> @@ -0,0 +1,79 @@
> +# -*- coding: utf-8 -*-
> +##############################################################################
> +#
> +#    OpenERP, Open Source Management Solution
> +#    Author: Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
> +#    Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
> +#    Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
> +#
> +#    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 openerp.osv import fields, orm
> +
> +
> +class account_invoice_line(orm.Model):
> +
> +    def _get_prod_lots(self, cr, uid, ids, field_name, arg, context=None):
> +        result = {}
> +        for line in self.browse(cr, uid, ids, context=context):
> +            result[line.id] = []
> +            for order_line in line.order_lines:
> +                for move in order_line.move_ids:
> +                    if move.prodlot_id:
> +                        result[line.id].append(move.prodlot_id.id)
> +        return result
> +
> +    _inherit = "account.invoice.line"
> +
> +    _columns = {
> +        # order_lines is the reverse of invoice_lines field of sale module
> +        'order_lines': fields.many2many(
> +            'sale.order.line', 'sale_order_line_invoice_rel', 'invoice_id',
> +            'order_line_id', 'Order Lines', readonly=True),
> +        'prod_lot_ids': fields.function(
> +            _get_prod_lots, method=True, type='many2many',
> +            relation="stock.production.lot", string="Production Lots"),
> +        'displayed_lot_id': fields.many2one('stock.production.lot', 'Lot'),
> +        }
> +
> +    def load_line_lots(self, cr, uid, ids, context=None):
> +        for line in self.browse(cr, uid, ids, context):
> +            if line.prod_lot_ids:
> +                note = u'<ul> '
> +                note += u' '.join([
> +                    u'<li>S/N {0}</li>'.format(lot.name)

does anyone know how to make the S/N text translatable? I would like to have it translated in my webkit invoice
many thanks

> +                    for lot in line.prod_lot_ids
> +                ])
> +                note += u' </ul>'
> +                line.write({'formatted_note': note}, context=context)
> +        return True
> +
> +    def create(self, cr, uid, vals, context=None):
> +        res = super(account_invoice_line, self).create(cr, uid, vals, context)
> +        if not vals.get('formatted_note'):
> +            self.load_line_lots(cr, uid, [res], context)
> +        return res
> +
> +class account_invoice(orm.Model):
> +
> +    def load_lines_lots(self, cr, uid, ids, context=None):
> +        invoices = self.browse(cr, uid, ids, context)
> +        inv_line_obj = self.pool.get('account.invoice.line')
> +        for invoice in invoices:
> +            inv_line_obj.load_line_lots(cr, uid, [l.id for l in invoice.invoice_line], context)
> +        return True
> +
> +    _inherit = "account.invoice"
> 
> === added file 'account_invoice_production_lot/invoice_view.xml'
> --- account_invoice_production_lot/invoice_view.xml	1970-01-01 00:00:00 +0000
> +++ account_invoice_production_lot/invoice_view.xml	2014-01-02 10:05:23 +0000
> @@ -0,0 +1,26 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<openerp>
> +    <data>
> +        <record model="ir.ui.view" id="view_invoice_line_form_prod_lots">
> +            <field name="name">account.invoice.line.form.prod_lots</field>
> +            <field name="model">account.invoice.line</field>
> +            <field name="inherit_id" ref="account.view_invoice_line_form"/>
> +            <field name="arch" type="xml">
> +                 <field name="name" position="after">
> +                    <separator colspan="4" string="Production Lots"/>
> +                    <field colspan="4" name="prod_lot_ids" nolabel="1"/>
> +                </field>
> +            </field>
> +        </record>
> +        <record model="ir.ui.view" id="invoice_form_load_button">
> +            <field name="name">account.invoice.form.load_button</field>
> +            <field name="model">account.invoice</field>
> +            <field name="inherit_id" ref="account.invoice_form"/>
> +            <field name="arch" type="xml">
> +                 <field name="invoice_line" position="after">
> +                        <button name="load_lines_lots" type="object" string="Load Lines Lots" colspan="2" confirm="This will overwrite the formatted note. Continue?"/>
> +                </field>
> +            </field>
> +        </record>
> +    </data>
> +</openerp>
> 
> === added directory 'account_invoice_production_lot/test'
> === added file 'account_invoice_production_lot/test/sale.yml'
> --- account_invoice_production_lot/test/sale.yml	1970-01-01 00:00:00 +0000
> +++ account_invoice_production_lot/test/sale.yml	2014-01-02 10:05:23 +0000
> @@ -0,0 +1,77 @@
> +-
> + !record {model: stock.location, id: location_opening}:
> +    name: opening
> +    usage: inventory
> +-
> + !record {model: product.product, id: product_icecream}:
> +    default_code: 001
> +    name: Ice Cream
> +    type: product
> +    categ_id: product.product_category_1
> +    list_price: 100.0
> +    standard_price: 70.0
> +    uom_id: product.product_uom_kgm
> +    uom_po_id: product.product_uom_kgm
> +    procure_method: make_to_stock
> +    property_stock_inventory: location_opening
> +    valuation: real_time
> +    cost_method: average
> +    property_stock_account_input: account.o_expense
> +    property_stock_account_output: account.o_income
> +    description: Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events.
> +-
> + !record {model: stock.production.lot, id: lot_icecream_0}:
> +    name: Lot0 for Ice cream
> +    product_id: product_icecream
> +-
> +  I create a draft Sale Order
> +-
> +  !record {model: sale.order, id: sale_order}:
> +    partner_id: base.res_partner_2
> +    partner_invoice_id: base.res_partner_address_3
> +    partner_shipping_id: base.res_partner_address_3
> +    pricelist_id: 1
> +    order_policy: picking
> +    order_line:
> +      - product_id: product_icecream
> +        product_uom_qty: 1.0
> +        product_uom: 1
> +        price_unit: 100.0
> +-
> +  I confirm the quotation with Invoice based on deliveries policy.
> +-
> +  !workflow {model: sale.order, action: order_confirm, ref: sale_order}
> +-
> +  Now, I dispatch delivery order.
> +-
> +  !python {model: stock.partial.picking}: |
> +    order = self.pool.get('sale.order').browse(cr, uid, ref("sale_order"))
> +    for pick in order.picking_ids:
> +        data = pick.force_assign()
> +        if data == True:
> +          partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick.id]})
> +          partial = self.browse(cr, uid, partial_id)
> +          partial.move_ids[0].write({
> +              'prodlot_id': ref("lot_icecream_0"),
> +              })
> +          self.do_partial(cr, uid, [partial_id])
> +-
> +  I create Invoice from Delivery Order.
> +-
> +  !python {model: stock.invoice.onshipping}: |
> +    sale = self.pool.get('sale.order')
> +    sale_order = sale.browse(cr, uid, ref("sale_order"))
> +    ship_ids = [x.id for x in sale_order.picking_ids]
> +    wiz_id = self.create(cr, uid, {'journal_id': ref('account.sales_journal')},
> +      {'active_ids': ship_ids, 'active_model': 'stock.picking'})
> +    self.create_invoice(cr, uid, [wiz_id], {"active_ids": ship_ids, "active_id": ship_ids[0]})
> +-
> +  I check the invoice details after dispatched delivery.
> +-
> +  !python {model: sale.order}: |
> +    order = self.browse(cr, uid, ref("sale_order"))
> +    assert order.invoice_ids, "Invoice is not created."
> +    ac = order.partner_invoice_id.property_account_receivable.id
> +    for invoice in order.invoice_ids:
> +        invoice.load_lines_lots()
> +        assert invoice.invoice_line[0].formatted_note == '<ul> <li>S/N Lot0 for Ice cream</li> </ul>', "Wrgong formatted note for '%s' line" % invoice.invoice_line[0].name
> 


-- 
https://code.launchpad.net/~agilebg/account-invoice-report/adding_account_invoice_production_lot_7/+merge/191230
Your team OpenERP Community Reviewer/Maintainer is subscribed to branch lp:~account-core-editors/account-invoice-report/7.0.


References