updates
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
Odoo Proprietary License v1.0
|
||||
|
||||
This software and associated files (the “Software”) may only be used (executed,
|
||||
modified, executed after modifications) if you have purchased a valid license
|
||||
from the authors, typically via Odoo Apps, or if you have received a written
|
||||
agreement from the authors of the Software (see the COPYRIGHT file).
|
||||
|
||||
You may develop Odoo modules that use the Software as a library (typically by
|
||||
depending on it, importing it and using its resources), but without copying any
|
||||
source code or material from the Software. You may distribute those modules
|
||||
under the license of your choice, provided that this license is compatible with
|
||||
the terms of the Odoo Proprietary License (For example: LGPL, MIT, or
|
||||
proprietary licenses similar to this one).
|
||||
|
||||
It is forbidden to publish, distribute, sublicense, or sell copies of the
|
||||
Software or modified copies of the Software.
|
||||
|
||||
The above copyright notice and this permission notice must be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
=======================================
|
||||
Product Label Printing without download
|
||||
=======================================
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Production-green.png
|
||||
:alt: Production
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-OPL--1-purple.png
|
||||
:target: https://www.odoo.com/documentation/15.0/legal/licenses.html
|
||||
:alt: License: OPL-1
|
||||
.. |badge4| image:: https://img.shields.io/badge/link-Garazd%20Apps-154577.png
|
||||
:target: https://garazd.biz/shop/product-label-printing-without-download-134
|
||||
:alt: Get the app on Garazd Apps store
|
||||
|
||||
|
||||
|badge1| |badge2| |badge4|
|
||||
|
||||
|
||||
Product Label Printing without download
|
||||
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Garazd Creation
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the Garazd Creation.
|
||||
|
||||
.. image:: https://garazd.biz/logo.png
|
||||
:alt: Garazd Creation
|
||||
:target: https://garazd.biz
|
||||
|
||||
Our mission is to create convenient and effective business solutions
|
||||
based on the Odoo ERP system in the areas in which we have the maximum
|
||||
expertise, such as: eCommerce, marketing, SEO, integration with
|
||||
marketplaces and analytic systems, product label printing and designing.
|
||||
|
||||
To solve these tasks, we create modules that complement each other,
|
||||
extend the functionality of Odoo and improve the usability of the system.
|
||||
Our solutions come with detailed documentation and additional materials
|
||||
for easy use.
|
||||
@@ -0,0 +1,2 @@
|
||||
from . import wizard
|
||||
from . import controllers
|
||||
@@ -0,0 +1,25 @@
|
||||
# Copyright © 2023 Garazd Creation (https://garazd.biz)
|
||||
# @author: Yurii Razumovskyi (support@garazd.biz)
|
||||
# @author: Iryna Razumovska (support@garazd.biz)
|
||||
# License OPL-1 (https://www.odoo.com/documentation/15.0/legal/licenses.html).
|
||||
|
||||
{
|
||||
'name': 'Product Label Printing without download',
|
||||
'version': '19.0.1.0.0',
|
||||
'category': 'Hidden',
|
||||
'author': 'Garazd Creation',
|
||||
'website': 'https://garazd.biz/shop',
|
||||
'license': 'OPL-1',
|
||||
'summary': 'Product Label Printing without download',
|
||||
'depends': [
|
||||
'garazd_product_label',
|
||||
],
|
||||
'data': [
|
||||
'views/print_product_label_templates.xml',
|
||||
'wizard/print_product_label_views.xml',
|
||||
],
|
||||
'support': 'support@garazd.biz',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
from . import main
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright © 2023 Garazd Creation (<https://garazd.biz>)
|
||||
# @author: Yurii Razumovskyi (<support@garazd.biz>)
|
||||
# @author: Iryna Razumovska (<support@garazd.biz>)
|
||||
# License OPL-1 (https://www.odoo.com/documentation/15.0/legal/licenses.html).
|
||||
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
|
||||
from ..wizard.print_product_label import LABEL_ATTACHMENT_NAME
|
||||
|
||||
|
||||
class PrintPDF(http.Controller):
|
||||
|
||||
@http.route(
|
||||
'/print_label/<string:attachment_id>',
|
||||
type='http',
|
||||
auth='user',
|
||||
sitemap=False,
|
||||
)
|
||||
def print_label_pdf(self, attachment_id=None, **kwargs):
|
||||
if not attachment_id:
|
||||
return request.not_found()
|
||||
|
||||
try:
|
||||
attachment_id = int(attachment_id)
|
||||
except ValueError:
|
||||
return request.not_found()
|
||||
|
||||
attachment = request.env['ir.attachment'].sudo().search([
|
||||
('name', '=', LABEL_ATTACHMENT_NAME),
|
||||
('mimetype', '=', 'application/pdf'),
|
||||
('id', '=', attachment_id),
|
||||
])
|
||||
|
||||
if not attachment:
|
||||
return request.not_found()
|
||||
|
||||
pdf_url = f'/web/content/{attachment_id}'
|
||||
return request.render(
|
||||
'garazd_product_label_print.print_product_label_pdf_template',
|
||||
{'title': 'Print Product Labels', 'pdf_url': pdf_url},
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
.. _changelog:
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
`18.0.1.0.0`
|
||||
------------
|
||||
|
||||
- Migration from 17.0.
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * garazd_product_label_print
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 17.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-09-02 11:08+0000\n"
|
||||
"PO-Revision-Date: 2024-09-02 11:08+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: garazd_product_label_print
|
||||
#: model_terms:ir.ui.view,arch_db:garazd_product_label_print.print_product_label_view_form
|
||||
msgid "Download"
|
||||
msgstr "Завантажити"
|
||||
|
||||
#. module: garazd_product_label_print
|
||||
#: model_terms:ir.ui.view,arch_db:garazd_product_label_print.print_product_label_view_form
|
||||
msgid "Download product labels"
|
||||
msgstr "Завантажити етикетки товарів"
|
||||
|
||||
#. module: garazd_product_label_print
|
||||
#: model_terms:ir.ui.view,arch_db:garazd_product_label_print.print_product_label_view_form
|
||||
msgid "Print"
|
||||
msgstr "Друк"
|
||||
|
||||
#. module: garazd_product_label_print
|
||||
#: model_terms:ir.ui.view,arch_db:garazd_product_label_print.print_product_label_view_form
|
||||
msgid "Print product labels"
|
||||
msgstr "Друк товарних етикеток"
|
||||
|
||||
#. module: garazd_product_label_print
|
||||
#: model:ir.model,name:garazd_product_label_print.model_print_product_label
|
||||
msgid "Wizard to print Product Labels"
|
||||
msgstr "Майстер для друку товарних етикеток"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="print_product_label_pdf_template" name="print_pdf_template">
|
||||
<head>
|
||||
<title><t t-out="title"/></title>
|
||||
</head>
|
||||
<body style="margin:auto;">
|
||||
<iframe t-att-src="pdf_url" frameborder="0" scrolling="yes" seamless="seamless" style="display:block; width:100%; height:100vh;"></iframe>
|
||||
</body>
|
||||
<script>
|
||||
printPdf = function (url) {
|
||||
var iframe = this._printIframe;
|
||||
if (!this._printIframe) {
|
||||
iframe = this._printIframe = document.createElement('iframe');
|
||||
document.body.appendChild(iframe);
|
||||
iframe.style.display = 'none';
|
||||
iframe.onload = function() {
|
||||
setTimeout(function() {
|
||||
iframe.focus();
|
||||
iframe.contentWindow.print();
|
||||
}, 1);
|
||||
};
|
||||
}
|
||||
iframe.src = url;
|
||||
}
|
||||
printPdf("<t t-out="pdf_url"/>")
|
||||
</script>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1 @@
|
||||
from . import print_product_label
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright © 2023 Garazd Creation (<https://garazd.biz>)
|
||||
# @author: Yurii Razumovskyi (<support@garazd.biz>)
|
||||
# @author: Iryna Razumovska (<support@garazd.biz>)
|
||||
# License OPL-1 (https://www.odoo.com/documentation/15.0/legal/licenses.html).
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
|
||||
LABEL_ATTACHMENT_NAME = 'Product Label Direct Printing'
|
||||
|
||||
|
||||
class PrintProductLabel(models.TransientModel):
|
||||
_inherit = "print.product.label"
|
||||
|
||||
def action_print_direct(self):
|
||||
""" Print labels directly without download. """
|
||||
self.ensure_one()
|
||||
attachment = self.env['ir.attachment'].create({
|
||||
'name': LABEL_ATTACHMENT_NAME,
|
||||
'type': 'binary',
|
||||
'datas': self.get_pdf(),
|
||||
'mimetype': 'application/pdf',
|
||||
'public': False,
|
||||
})
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': f'/print_label/{attachment.id}',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
@api.autovacuum
|
||||
def _gc_print_label_attachments(self):
|
||||
timeout_ago = datetime.utcnow() - timedelta(days=1)
|
||||
domain = [
|
||||
('name', '=', LABEL_ATTACHMENT_NAME),
|
||||
('mimetype', '=', 'application/pdf'),
|
||||
('create_date', '<', timeout_ago.strftime(DEFAULT_SERVER_DATETIME_FORMAT)),
|
||||
]
|
||||
return self.env['ir.attachment'].sudo().search(domain).unlink()
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="print_product_label_view_form" model="ir.ui.view">
|
||||
<field name="name">print.product.label.view.form.inherit.garazd_product_label_print</field>
|
||||
<field name="model">print.product.label</field>
|
||||
<field name="inherit_id" ref="garazd_product_label.print_product_label_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_print']" position="before">
|
||||
<button name="action_print_direct"
|
||||
string="Print"
|
||||
help="Print product labels"
|
||||
type="object"
|
||||
icon="fa-print"
|
||||
class="btn-primary mr8"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_print']" position="attributes">
|
||||
<attribute name="string">Download</attribute>
|
||||
<attribute name="help">Download product labels</attribute>
|
||||
<attribute name="icon">fa-download</attribute>
|
||||
<attribute name="class" separator=" " remove="btn-primary" add="btn-light border"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user