-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_voucher_ux: Migration to 18.0
- Loading branch information
Showing
12 changed files
with
431 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.. |company| replace:: ADHOC SA | ||
|
||
.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png | ||
:alt: ADHOC SA | ||
:target: https://www.adhoc.com.ar | ||
|
||
.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png | ||
|
||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
:target: https://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
============= | ||
Stock Voucher | ||
============= | ||
|
||
#. This module makes the assignation of the vouchers depending on the quantity of pages the report has. | ||
#. Replaces the field "Lines per voucher" for the boolean "Autoprinted" maintaining the same functionality. | ||
#. Eliminates the wizard for "Vouchers" and replace it with the action "Print Vouchers", which automatically prints and assigns the voucher/s. | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
#. Only need to install the module | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. To configure Books: Go to Stock / Configurations / Books. | ||
#. To configure the Declared Value , Book Required: Go to Stock Pincking Type. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Just create a sale order, confirm and transfer the products. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: http://runbot.adhoc.com.ar/ | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/ingadhoc/stock/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* |company| |icon| | ||
|
||
Contributors | ||
------------ | ||
|
||
Maintainer | ||
---------- | ||
|
||
|company_logo| | ||
|
||
This module is maintained by the |company|. | ||
|
||
To contribute to this module, please visit https://www.adhoc.com.ar. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
############################################################################## | ||
# | ||
# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar) | ||
# All Rights Reserved. | ||
# | ||
# 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': 'Stock Voucher UX', | ||
'version': "18.0.1.1.0", | ||
'category': 'Warehouse Management', | ||
'sequence': 14, | ||
'summary': '', | ||
'author': 'ADHOC SA', | ||
'website': 'www.adhoc.com.ar', | ||
'license': 'AGPL-3', | ||
'images': [ | ||
], | ||
'depends': [ | ||
'stock_voucher', | ||
'report_aeroo', | ||
'l10n_ar_stock', | ||
], | ||
'data': [ | ||
'views/stock_book_views.xml', | ||
'views/stock_picking_views.xml', | ||
'views/report_deliveryslip.xml', | ||
], | ||
'demo': [ | ||
], | ||
'installable': True, | ||
'auto_install': False, | ||
'application': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
################################################################################ | ||
# | ||
# This file is part of Aeroo Reports software - for license refer LICENSE file | ||
# | ||
################################################################################ | ||
|
||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright 2017 ACSONE SA/NV | ||
# Copyright 2018 - Brain-tec AG - Carlos Jesus Cebrian | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
import io | ||
import json | ||
import urllib.parse | ||
import re | ||
|
||
from odoo.http import route, request | ||
from odoo.addons.web.controllers import report | ||
from PyPDF2 import PdfFileReader | ||
|
||
|
||
class ReportController(report.ReportController): | ||
|
||
@route() | ||
def report_download(self, data, context=None): | ||
"""This function is used by 'qwebactionmanager.js' in order to trigger | ||
the download of a py3o/controller report. | ||
:param data: a javascript array JSON.stringified containg report | ||
internal url ([0]) and type [1] | ||
:returns: Response with a filetoken cookie and an attachment header | ||
""" | ||
response = super().report_download(data, context) | ||
#NTH detect if the binary is a PDF, no matter ifn it was generated by a QWeb or Aeroo | ||
requestcontent = json.loads(data) | ||
url, type = requestcontent[0], requestcontent[1] | ||
# context_part = json.loads(data)[0].split('context=')[1] | ||
# context_dict = json.loads(urllib.parse.unquote(context_part)) | ||
# model = context_dict.get('params', {}).get('model') | ||
if type == 'aeroo': | ||
context_part = json.loads(data)[0].split('context=')[1] | ||
context_dict = json.loads(urllib.parse.unquote(context_part)) | ||
model = context_dict.get('params', {}).get('model') | ||
if model == 'stock.picking': | ||
context_part = json.loads(data)[0].split('context=')[1] | ||
context_dict = json.loads(urllib.parse.unquote(context_part)) | ||
picking_id = context_dict.get('active_ids') | ||
# Get assign on the context. If true, then is not an autoprinted | ||
assign = context_dict.get('assign') | ||
book_id = request.env['stock.picking'].browse(picking_id).book_id | ||
if assign and book_id: | ||
if picking_id: | ||
pdf_response = response.response[0] | ||
reader = PdfFileReader(io.BytesIO(pdf_response)) | ||
# The number of pages will assign the number of vouchers | ||
number_pages = reader.getNumPages() | ||
|
||
# See if there are vouchers already assigned. If not, then it assigns the vouchers | ||
if not request.env['stock.picking'].browse(picking_id).voucher_ids and book_id: | ||
request.env['stock.picking'].browse(picking_id).assign_numbers(number_pages, book_id) | ||
else: | ||
dict_context = json.loads(context) | ||
model = dict_context['active_model'] | ||
if model == 'stock.picking': | ||
# If the report is not an aeroo, the assign method should only assign one voucher | ||
match = re.search(r'(\d+)$', json.loads(data)[0]) | ||
if match: | ||
picking_id = int(match.group(1)) | ||
book_id = request.env['stock.picking'].browse(picking_id).book_id | ||
if not request.env['stock.picking'].browse(picking_id).voucher_ids and book_id: | ||
request.env['stock.picking'].browse(picking_id).assign_numbers(1, book_id) | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_voucher | ||
# | ||
# Translators: | ||
# Juan José Scarafía <[email protected]>, 2023 | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-08-01 16:21+0000\n" | ||
"PO-Revision-Date: 2023-01-13 13:59+0000\n" | ||
"Last-Translator: Juan José Scarafía <[email protected]>, 2023\n" | ||
"Language-Team: Spanish (https://app.transifex.com/adhoc/teams/46451/es/)\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Language: es\n" | ||
"Plural-Forms: nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_print_stock_voucher_form_ux | ||
msgid "<strong>THE VOUCHER IT'S PRINTED.</strong>" | ||
msgstr "EL COMPROBANTE ESTÁ IMPRESO." | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_print_stock_voucher_form_ux | ||
msgid "Print" | ||
msgstr "Imprimir" | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_print_stock_voucher_form_ux | ||
msgid "Number estimated of pages" | ||
msgstr "Número estimado de paginas" | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_print_stock_voucher_form_ux | ||
msgid "Estimate calculated to have an idea of the approximate number of pages. The real value will be known after printing" | ||
msgstr "Estimación calculada para tener una idea del número aproximado de páginas. El valor real se conocerá después de la impresión" | ||
|
||
#. module: stock_voucher_ux | ||
#: model:ir.model.fields,help:stock_voucher_ux.field_stock_book__autoprinted | ||
msgid "" | ||
"If voucher is not an autoprinted, it will assign as many vouchers as pages the report has. " | ||
"Otherwise, it will assign only one voucher" | ||
msgstr "" | ||
"Si el remito no es un autoimpreso, se asignará cantidad de remitos como número de paginas haya. " | ||
"De otra manera, asignará un único remito" | ||
|
||
#. module: stock_voucher_ux | ||
#: model:ir.model.fields,field_description:stock_voucher_ux.field_stock_book__autoprinted | ||
msgid "autoprinted" | ||
msgstr "Autoimpreso" | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_print_stock_voucher_form_ux | ||
msgid "Print" | ||
msgstr "Imprimir" | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_picking_form | ||
msgid "Print" | ||
msgstr "Imprimir" | ||
|
||
#. module: stock_voucher_ux | ||
#: model:ir.model.fields,field_description:stock_voucher_ux.field_stock_picking__book_id | ||
msgid "Book" | ||
msgstr "Talonario" | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_picking_form | ||
msgid "Print Vouchers" | ||
msgstr "Imprimir Remitos" | ||
|
||
#. module: stock_voucher_ux | ||
#: model_terms:ir.ui.view,arch_db:stock_voucher_ux.view_picking_form | ||
msgid "Clean Voucher Data" | ||
msgstr "Limpiar Remitos" | ||
|
||
#. module: stock_voucher_ux | ||
#. odoo-python | ||
#: code:addons/stock_voucher_ux/models/stock_picking.py:0 | ||
#, python-format | ||
msgid "" | ||
"First you have to set a book" | ||
msgstr "" | ||
"Primero debe seleccionar un talonario" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from . import stock_book | ||
from . import stock_picking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import fields, models | ||
|
||
|
||
class StockBook(models.Model): | ||
_inherit = 'stock.book' | ||
|
||
|
||
autoprinted = fields.Boolean( | ||
help="If voucher is not an autoprinted, it will assign as many vouchers as pages the report has. " | ||
"Otherwise, it will assign only one voucher", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import fields, models, api | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class StockPicking(models.Model): | ||
_inherit = 'stock.picking' | ||
|
||
|
||
printed = fields.Boolean( | ||
) | ||
|
||
with_vouchers = fields.Boolean( | ||
compute='_compute_with_vouchers', | ||
) | ||
|
||
book_id = fields.Many2one( | ||
'stock.book', | ||
'Book', | ||
default=lambda self: self._get_book(), | ||
) | ||
|
||
next_voucher_number = fields.Integer( | ||
'Next Voucher Number', | ||
related='book_id.sequence_id.number_next_actual', | ||
) | ||
|
||
autoprinted = fields.Boolean( | ||
related='book_id.autoprinted', | ||
) | ||
|
||
@api.model | ||
def _get_book(self): | ||
return self.book_id or self.env['stock.book'].search([('company_id', '=', self.company_id.id)], limit=1) | ||
|
||
@api.depends('voucher_ids') | ||
def _compute_with_vouchers(self): | ||
for rec in self: | ||
rec.with_vouchers = bool(self.voucher_ids) | ||
|
||
def do_print_voucher(self): | ||
self.printed = True | ||
if self.book_id: | ||
self.book_id = self.book_id.id | ||
return super(StockPicking, self).do_print_voucher() | ||
|
||
def do_print_and_assign(self): | ||
if not self.book_id: | ||
raise UserError("Primero debe seleccionar un talonario") | ||
if self.autoprinted == False: | ||
self.printed = True | ||
return self.with_context(assign=True).do_print_voucher() | ||
else: | ||
self.assign_numbers(1,self.book_id) | ||
return self.do_print_voucher() | ||
|
||
def clean_voucher_data(self): | ||
return super(StockPicking, self).clean_voucher_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<template id="report_delivery_document" inherit_id="l10n_ar_stock.report_delivery_document"> | ||
<xpath expr="//t[@t-set='pre_printed_report']" position="replace"> | ||
<t t-set="pre_printed_report" t-value="not o.autoprinted"/> | ||
</xpath> | ||
<xpath expr="//div[@name='footer_right_column']" position="replace"> | ||
<div name="footer_right_column" class="col-4 text-right"> | ||
<div t-if="o.book_id.autoprinted and o.book_id.l10n_ar_cai"> | ||
CAI: <span t-field="o.book_id.l10n_ar_cai"/> | ||
</div> | ||
<div t-if="o.book_id.autoprinted and o.book_id.l10n_ar_cai_due"> | ||
CAI Due Date: <span t-field="o.book_id.l10n_ar_cai_due"/> | ||
</div> | ||
<div name="pager" t-if="report_type == 'pdf'"> | ||
Page: <span class="page"/> | ||
/ <span class="topage"/> | ||
</div> | ||
</div> | ||
</xpath> | ||
</template> | ||
</odoo> |
Oops, something went wrong.