-
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 v17
closes #549 Signed-off-by: Juan Carreras <[email protected]>
- Loading branch information
Showing
11 changed files
with
400 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,72 @@ | ||
.. |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 adds stock voucher report on stock picking to generate a voucher for each Customers pickings. | ||
#. Also adds parameters in stock picking type to set declared value and number_package in the pickings. | ||
|
||
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,44 @@ | ||
############################################################################## | ||
# | ||
# 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': "17.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', | ||
], | ||
'data': [ | ||
'views/stock_book_views.xml', | ||
'views/stock_picking_views.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,15 @@ | ||
<odoo> | ||
<record id="view_stock_book_form_ux" model="ir.ui.view"> | ||
<field name="name">stock.book.form.ux</field> | ||
<field name="model">stock.book</field> | ||
<field name="inherit_id" ref="stock_voucher.view_stock_book_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='lines_per_voucher']" position="after"> | ||
<field name="autoprinted" widget="boolean_toggle"/> | ||
</xpath> | ||
<xpath expr="//field[@name='lines_per_voucher']" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
Oops, something went wrong.