[MIG] stock_picking_comment_template: Migration to 14.0

This commit is contained in:
Alfredo Zamora
2021-05-31 12:58:20 +02:00
parent 8b855e6d02
commit fd006d845a
16 changed files with 113 additions and 163 deletions

View File

@@ -1 +1,2 @@
# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt
reporting-engine

View File

@@ -14,25 +14,19 @@ Picking Comments
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_picking_comment_template
:target: https://github.com/OCA/stock-logistics-reporting/tree/14.0/stock_picking_comment_template
:alt: OCA/stock-logistics-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-reporting-12-0/stock-logistics-reporting-12-0-stock_picking_comment_template
:target: https://translation.odoo-community.org/projects/stock-logistics-reporting-14-0/stock-logistics-reporting-14-0-stock_picking_comment_template
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/151/12.0
:target: https://runbot.odoo-community.org/runbot/151/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
Adds comments on stock picking.
The comments can be edited directly on the stock picking or loaded from
templates.
Two positions are available for the comments:
- above stock picking lines
- below stock picking lines
The comments can be added/edited from Inventory -> Configuration -> Document Comments
**Table of contents**
@@ -45,7 +39,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-reporting/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 <https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_picking_comment_template%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_picking_comment_template%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -64,6 +58,10 @@ Contributors
* Eduardo Magdalena <emagdalena@c2i.es>
* `NextERP Romania <https://www.nexterp.ro>`_:
* Fekete Mihai <feketemihai@nexterp.ro>
Do not contact contributors directly about support or help with technical issues.
Maintainers
@@ -79,6 +77,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/stock-logistics-reporting <https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_picking_comment_template>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-reporting <https://github.com/OCA/stock-logistics-reporting/tree/14.0/stock_picking_comment_template>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,20 +4,16 @@
{
"name": "Picking Comments",
"summary": "Comments texts templates on Picking documents",
"version": "12.0.1.0.0",
"version": "14.0.1.0.0",
"category": "Warehouse Management",
"website": "https://github.com/OCA/stock-logistics-reporting",
"author": "C2i Change 2 improve," "Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"stock",
"sale",
"base_comment_template",
],
"depends": ["stock", "base_comment_template"],
"data": [
"views/base_comment_template_view.xml",
"views/report_picking.xml",
"views/report_delivery_document.xml",
"views/report_picking.xml",
"views/stock_picking_view.xml",
"security/ir.model.access.csv",
],

View File

@@ -1,4 +1 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import stock_picking
from . import res_partner

View File

@@ -1,13 +0,0 @@
# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena <emagdalena@c2i.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
comment_template_id = fields.Many2one(
comodel_name="base.comment.template",
string="Picking conditions template",
)

View File

@@ -1,39 +1,9 @@
# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena <emagdalena@c2i.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
from odoo import models
class StockPicking(models.Model):
"""Add text comment"""
_inherit = "stock.picking"
comment_template1_id = fields.Many2one(
"base.comment.template", string="Top Comment Template"
)
comment_template2_id = fields.Many2one(
"base.comment.template", string="Bottom Comment Template"
)
note1 = fields.Html("Top Comment")
note2 = fields.Html("Bottom Comment")
@api.onchange("comment_template1_id")
def _set_note1(self):
comment = self.comment_template1_id
if comment:
self.note1 = comment.get_value(self.partner_id.id)
@api.onchange("comment_template2_id")
def _set_note2(self):
comment = self.comment_template2_id
if comment:
self.note2 = comment.get_value(self.partner_id.id)
@api.onchange("partner_id")
def _onchange_partner_id(self):
comment_template = self.partner_id.comment_template_id
if comment_template.position == "before_lines":
self.comment_template1_id = comment_template
elif comment_template.position == "after_lines":
self.comment_template2_id = comment_template
_inherit = ["stock.picking", "comment.template"]
_name = "stock.picking"

View File

@@ -2,4 +2,8 @@
* Eduardo Magdalena <emagdalena@c2i.es>
* `NextERP Romania <https://www.nexterp.ro>`_:
* Fekete Mihai <feketemihai@nexterp.ro>
Do not contact contributors directly about support or help with technical issues.

View File

@@ -1,8 +1,2 @@
Adds comments on stock picking.
The comments can be edited directly on the stock picking or loaded from
templates.
Two positions are available for the comments:
- above stock picking lines
- below stock picking lines
The comments can be added/edited from Inventory -> Configuration -> Document Comments

View File

@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_base_comment_template_account_user,access_base_comment_template user,base_comment_template.model_base_comment_template,account.group_account_user,1,0,0,0
access_base_comment_template_account_manager,access_base_comment_template manager,base_comment_template.model_base_comment_template,account.group_account_manager,1,1,1,1
access_base_comment_template_stock_user,access_base_comment_template stock_user,base_comment_template.model_base_comment_template,stock.group_stock_user,1,0,0,0
access_base_comment_template_stock_manager,access_base_comment_template stock_manager,base_comment_template.model_base_comment_template,stock.group_stock_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_base_comment_template_account_user access_base_comment_template_stock_user access_base_comment_template user access_base_comment_template stock_user base_comment_template.model_base_comment_template account.group_account_user stock.group_stock_user 1 0 0 0
3 access_base_comment_template_account_manager access_base_comment_template_stock_manager access_base_comment_template manager access_base_comment_template stock_manager base_comment_template.model_base_comment_template account.group_account_manager stock.group_stock_manager 1 1 1 1

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Picking Comments</title>
<style type="text/css">
@@ -367,15 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_picking_comment_template"><img alt="OCA/stock-logistics-reporting" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-reporting-12-0/stock-logistics-reporting-12-0-stock_picking_comment_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/151/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/14.0/stock_picking_comment_template"><img alt="OCA/stock-logistics-reporting" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-reporting-14-0/stock-logistics-reporting-14-0-stock_picking_comment_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/151/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Adds comments on stock picking.
The comments can be edited directly on the stock picking or loaded from
templates.</p>
<p>Two positions are available for the comments:</p>
<ul class="simple">
<li>above stock picking lines</li>
<li>below stock picking lines</li>
</ul>
The comments can be added/edited from Inventory -&gt; Configuration -&gt; Document Comments</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
@@ -393,7 +387,7 @@ templates.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_picking_comment_template%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/issues/new?body=module:%20stock_picking_comment_template%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -411,6 +405,10 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Eduardo Magdalena &lt;<a class="reference external" href="mailto:emagdalena&#64;c2i.es">emagdalena&#64;c2i.es</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.nexterp.ro">NextERP Romania</a>:<ul>
<li>Fekete Mihai &lt;<a class="reference external" href="mailto:feketemihai&#64;nexterp.ro">feketemihai&#64;nexterp.ro</a>&gt;</li>
</ul>
</li>
</ul>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
@@ -421,7 +419,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/12.0/stock_picking_comment_template">OCA/stock-logistics-reporting</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-reporting/tree/14.0/stock_picking_comment_template">OCA/stock-logistics-reporting</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -1,4 +1,3 @@
# Copyright 2019 C2i Change 2 improve - Eduardo Magdalena <emagdalena@c2i.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_stock_picking_report

View File

@@ -5,15 +5,20 @@ from odoo.tests.common import TransactionCase
class TestStockPickingReport(TransactionCase):
at_install = False
post_install = True
def setUp(self):
super(TestStockPickingReport, self).setUp()
super().setUp()
self.company = self.env.ref("base.main_company")
self.base_comment_model = self.env["base.comment.template"]
self.before_comment = self._create_comment("before_lines")
self.after_comment = self._create_comment("after_lines")
# Create comment related to sale model
self.picking_obj = self.env.ref("stock.model_stock_picking")
self.before_comment = self._create_comment(self.picking_obj, "before_lines")
self.after_comment = self._create_comment(self.picking_obj, "after_lines")
# Create partner
self.partner = self.env["res.partner"].create({"name": "Partner Test"})
self.partner.base_comment_template_ids = [
(4, self.before_comment.id),
(4, self.after_comment.id),
]
self.picking_model = self.env["stock.picking"]
self.picking = self.picking_model.create(
{
@@ -21,41 +26,34 @@ class TestStockPickingReport(TransactionCase):
"location_id": self.ref("stock.stock_location_stock"),
"location_dest_id": self.ref("stock.stock_location_customers"),
"picking_type_id": self.ref("stock.picking_type_out"),
"comment_template1_id": self.before_comment.id,
"comment_template2_id": self.after_comment.id,
}
)
self.picking._set_note1()
self.picking._set_note2()
def _create_comment(self, position):
def _create_comment(self, model, position):
return self.base_comment_model.create(
{
"name": "Comment " + position,
"company_id": self.company.id,
"position": position,
"text": "Text " + position,
"model_ids": [(6, 0, model.ids)],
}
)
def test_comments_in_picking(self):
def test_comments_in_deliveryslip(self):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_deliveryslip")
._render_qweb_html(self.picking.ids)
)
self.assertRegex(str(res[0]), self.before_comment.text)
self.assertRegex(str(res[0]), self.after_comment.text)
def test_comments_in_report_picking(self):
res = (
self.env["ir.actions.report"]
._get_report_from_name("stock.report_picking")
.render_qweb_html(self.picking.ids)
._render_qweb_html(self.picking.ids)
)
self.assertRegexpMatches(str(res[0]), self.before_comment.text)
self.assertRegexpMatches(str(res[0]), self.after_comment.text)
def test_onchange_partner_id(self):
self.partner.comment_template_id = self.after_comment.id
new_picking = self.env["stock.picking"].new(
{
"partner_id": self.partner.id,
}
)
new_picking._onchange_partner_id()
self.assertEqual(new_picking.comment_template2_id, self.after_comment)
self.partner.comment_template_id = self.before_comment.id
new_picking._onchange_partner_id()
self.assertEqual(new_picking.comment_template1_id, self.before_comment)
self.assertRegex(str(res[0]), self.before_comment.text)
self.assertRegex(str(res[0]), self.after_comment.text)

View File

@@ -1,10 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.actions.act_window" id="action_stock_picking_comment_template">
<field name="name">Stock Picking Comment Templates</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.comment.template</field>
<field name="view_mode">tree,form</field>
<field
name="domain"
eval="[('model_ids', 'in', [ref('stock.model_stock_picking')])]"
/>
<field
name="view_id"
ref="base_comment_template.view_base_comment_template_tree"
/>
</record>
<menuitem
name="Document Comments"
id="menu_base_comment_template_picking"
action="base_comment_template.action_base_comment_template"
action="stock_picking_comment_template.action_stock_picking_comment_template"
parent="stock.menu_stock_config_settings"
/>

View File

@@ -6,14 +6,20 @@
inherit_id="stock.report_delivery_document"
>
<xpath expr="//table[hasclass('table-sm')]" position="before">
<p t-if="o.note1">
<span t-field="o.note1" />
</p>
<t
t-foreach="o.comment_template_ids.filtered(lambda x: x.position == 'before_lines')"
t-as="comment_template_top"
>
<div t-raw="comment_template_top.text" />
</t>
</xpath>
<xpath expr="(//p)[position()=last()]" position="after">
<p t-if="o.note2">
<span t-field="o.note2" />
</p>
<xpath expr="//div[hasclass('page')]" position="inside">
<t
t-foreach="o.comment_template_ids.filtered(lambda x: x.position == 'after_lines')"
t-as="comment_template_bottom"
>
<div t-raw="comment_template_bottom.text" />
</t>
</xpath>
</template>

View File

@@ -3,14 +3,20 @@
<template id="report_picking_document_comments" inherit_id="stock.report_picking">
<xpath expr="//table[hasclass('table-sm')]" position="before">
<p t-if="o.note1">
<span t-field="o.note1" />
</p>
<t
t-foreach="o.comment_template_ids.filtered(lambda x: x.position == 'before_lines')"
t-as="comment_template_top"
>
<div t-raw="comment_template_top.text" />
</t>
</xpath>
<xpath expr="//p[@t-field='o.note']" position="after">
<p t-if="o.note2">
<span t-field="o.note2" />
</p>
<t
t-foreach="o.comment_template_ids.filtered(lambda x: x.position == 'after_lines')"
t-as="comment_template_bottom"
>
<div t-raw="comment_template_bottom.text" />
</t>
</xpath>
</template>

View File

@@ -1,33 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="stock_picking_form_add_comment">
<field name="name">stock.picking.form.comment</field>
<field name="name">comment_template.stock.picking.form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Comments" name="comments">
<p
style="margin-top: 10px;"
>The comments will be displayed on the printed document. You can load a predefined template, write your own text or load a template and then modify it only for this document.</p>
<group string="Top Comments">
<field
name="comment_template1_id"
string="Load a template"
domain="[('position','=','before_lines')]"
context="{'default_position': 'before_lines'}"
/>
<field name="note1" nolabel="1" colspan="2" />
</group>
<group string="Bottom Comments">
<field
name="comment_template2_id"
string="Load a template"
context="{'default_position': 'after_lines'}"
domain="[('position','=','after_lines')]"
/>
<field name="note2" nolabel="1" colspan="2" />
</group>
<field name="comment_template_ids" />
</page>
</xpath>
</field>