Skip to Content
Menu
This question has been flagged
2 Replies
1850 Views

Hi,

I am using odoo 14 and want to print the delivery order and invoice in .xls or .ods format so that I can tweak the layout if needed. Can someone tell me how I can do this? Right now, it only prints to .pdf format. Thanks.

Regards,

Simon Lee

Avatar
Discard
Author Best Answer

Hi,

I want to add a print item to the print menu in the deliveryslip form that can print the delivery slip in excel format.

I have follow your youtube link and successfully installed Base report xlsx and the writers. But I encountered the following parsing error. Can you give me some advise of how to correct?

I have a custom module called "hago" which has the following directory structure:

odoo 14
  >custom
    >hago
      __init__.py
      __manifest__.py
      >models
        >deliveryslip_xlsx.py
        >models.py
      >reports
           >reports.xml

I added the following to hago>reports>reports.xml


   Delivery Slip Excel
  stock.picking
  xlsx
   hago.report_deliveryslip_xlsx
   hago.report_deliveryslip_xlsx
  
   report

------------------

And the following to hago>deliveryslip_xlsx.py

# -*- coding: utf-8 -*-

from odoo import models

class hago_deliveryslip_xlsx(models.AbstractModel):
   _name = 'report.hago.report_deliveryslip_xlsx'
   _inherit = 'report.report_xlsx.abstract'

   def generate_xlsx_report(self, workbook, data, deliveryslip):
     bold = workbook.add_format({'bold': True})

-------------

hago>
  __init__.py has this content:

# -*- coding: utf-8 -*-

from . import controllers
from . import models
from . import reports

---------------

hago>
  __manifest__.py has this content:

'depends': ['base', 'sale', 'purchase', 'stock', 'delivery', 'report_xlsx'],
'data': [
     'views/views.xml',
     'views/templates.xml',
     'reports/reports.xml',
     ],

=================

Here's the error when I upgrade the module:

Odoo Server Error
Traceback (most recent call last):
  File "/home/simon/odoo14/odoo/tools/cache.py", line 85, in lookup
    r = d[key]
  File "/home/simon/odoo14/odoo/tools/func.py", line 71, in wrapper
    return func(self, *args, **kwargs)
  File "/home/simon/odoo14/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('ir.model.data', , 'hago.model_stock_picking')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/simon/odoo14/odoo/tools/convert.py", line 677, in _tag_root
    f(rec)
  File "/home/simon/odoo14/odoo/tools/convert.py", line 564, in _tag_record
    f_val = self.id_get(f_ref)
  File "/home/simon/odoo14/odoo/tools/convert.py", line 660, in id_get
    res = self.model_id_get(id_str, raise_if_not_found)
  File "/home/simon/odoo14/odoo/tools/convert.py", line 666, in model_id_get
    return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
  File "/home/simon/odoo14/odoo/addons/base/models/ir_model.py", line 1927, in xmlid_to_res_model_res_id
    return self.xmlid_lookup(xmlid)[1:3]
  File "", line 2, in xmlid_lookup
  File "/home/simon/odoo14/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/home/simon/odoo14/odoo/addons/base/models/ir_model.py", line 1920, in xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: hago.model_stock_picking

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/simon/odoo14/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/home/simon/odoo14/odoo/http.py", line 683, in dispatch
    result = self._call_function(**self.params)
  File "/home/simon/odoo14/odoo/http.py", line 359, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/simon/odoo14/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/simon/odoo14/odoo/http.py", line 347, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/simon/odoo14/odoo/http.py", line 912, in __call__
    return self.method(*args, **kw)
  File "/home/simon/odoo14/odoo/http.py", line 531, in response_wrap
    response = f(*args, **kw)
  File "/home/simon/odoo14/odoo/addons/web/controllers/main.py", line 1393, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/home/simon/odoo14/odoo/addons/web/controllers/main.py", line 1381, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/simon/odoo14/odoo/api.py", line 396, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/home/simon/odoo14/odoo/api.py", line 383, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "", line 2, in button_immediate_upgrade
  File "/home/simon/odoo14/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
    return method(self, *args, **kwargs)
  File "/home/simon/odoo14/odoo/addons/base/models/ir_module.py", line 654, in button_immediate_upgrade
    return self._button_immediate_function(type(self).button_upgrade)
  File "/home/simon/odoo14/odoo/addons/base/models/ir_module.py", line 593, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)
  File "/home/simon/odoo14/odoo/modules/registry.py", line 89, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/home/simon/odoo14/odoo/modules/loading.py", line 449, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/simon/odoo14/odoo/modules/loading.py", line 346, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/simon/odoo14/odoo/modules/loading.py", line 221, in load_module_graph
    load_data(cr, idref, mode, kind='data', package=package)
  File "/home/simon/odoo14/odoo/modules/loading.py", line 69, in load_data
    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
  File "/home/simon/odoo14/odoo/tools/convert.py", line 733, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate)
  File "/home/simon/odoo14/odoo/tools/convert.py", line 799, in convert_xml_import
    obj.parse(doc.getroot())
  File "/home/simon/odoo14/odoo/tools/convert.py", line 719, in parse
    self._tag_root(de)
  File "/home/simon/odoo14/odoo/tools/convert.py", line 681, in _tag_root
    raise ParseError('while parsing %s:%s, near\n%s' % (
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/simon/odoo14/odoo/http.py", line 639, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/simon/odoo14/odoo/http.py", line 315, in _handle_exception
    raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /home/simon/odoo14/custom/hago/reports/reports.xml:27, near

	    Delivery Slip Excel
	    stock.picking
	    xlsx
	    hago.report_deliveryslip_xlsx
	    hago.report_deliveryslip_xlsx
	    
	    report
	
Regards,
Simon
Avatar
Discard
Best Answer

Hi,

By default for the invoice and delivery slip odoo provides only the PDF report. If you need to have excel report either you have to build a module that adds this functionality or you can check the odoo apps store for the modules providing such features.

If you are a tech person, you can add new excel report by referring this: https://www.youtube.com/watch?v=fnIpIs4UqVs


Thanks

Avatar
Discard