[IMP] base_comment_template: black, isort, prettier

This commit is contained in:
Pierre Verkest
2021-01-07 22:37:54 +01:00
parent cfcac1d83e
commit 85e13a0bf7
12 changed files with 74 additions and 71 deletions

View File

@@ -14,13 +14,13 @@ Base Comments Templates
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoice--reporting-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoice--reporting-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoice-reporting/tree/12.0/base_comment_template :target: https://github.com/OCA/account-invoice-reporting/tree/14.0/base_comment_template
:alt: OCA/account-invoice-reporting :alt: OCA/account-invoice-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoice-reporting-12-0/account-invoice-reporting-12-0-base_comment_template :target: https://translation.odoo-community.org/projects/account-invoice-reporting-12-0/account-invoice-reporting-12-0-base_comment_template
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/94/12.0 :target: https://runbot.odoo-community.org/runbot/94/14.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -50,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoice-reporting/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoice-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-invoice-reporting/issues/new?body=module:%20base_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/account-invoice-reporting/issues/new?body=module:%20base_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. Do not contact contributors directly about support or help with technical issues.
@@ -93,6 +93,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/account-invoice-reporting <https://github.com/OCA/account-invoice-reporting/tree/12.0/base_comment_template>`_ project on GitHub. This module is part of the `OCA/account-invoice-reporting <https://github.com/OCA/account-invoice-reporting/tree/14.0/base_comment_template>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,15 +4,13 @@
{ {
"name": "Base Comments Templates", "name": "Base Comments Templates",
"summary": "Comments templates on documents", "summary": "Comments templates on documents",
"version": "12.0.3.0.0", "version": "14.0.1.0.0",
"category": "Sale", "category": "Sale",
"website": "https://github.com/OCA/account-invoice-reporting", "website": "https://github.com/OCA/account-invoice-reporting",
"author": "Camptocamp, Odoo Community Association (OCA)", "author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"installable": True, "installable": True,
"depends": [ "depends": ["base"],
"base"
],
"data": [ "data": [
"security/ir.model.access.csv", "security/ir.model.access.csv",
"security/security.xml", "security/security.xml",

View File

@@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"

View File

@@ -1,13 +0,0 @@
# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
cr = env.cr
table = 'res_partner'
old_column = 'comment_template_id'
new_column = 'property_comment_template_id'
if openupgrade.column_exists(cr, table, old_column):
openupgrade.rename_columns(cr, {table: [(old_column, new_column)]})

View File

@@ -2,7 +2,7 @@
# Copyright 2013-2014 Nicolas Bessi (Camptocamp SA) # Copyright 2013-2014 Nicolas Bessi (Camptocamp SA)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api from odoo import fields, models
class BaseCommentTemplate(models.Model): class BaseCommentTemplate(models.Model):
@@ -12,38 +12,37 @@ class BaseCommentTemplate(models.Model):
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
name = fields.Char( name = fields.Char(
string='Comment summary', string="Comment summary",
required=True, required=True,
) )
position = fields.Selection( position = fields.Selection(
selection=[ selection=[
('before_lines', 'Before lines'), ("before_lines", "Before lines"),
('after_lines', 'After lines'), ("after_lines", "After lines"),
], ],
required=True, required=True,
default='before_lines', default="before_lines",
help="Position on document", help="Position on document",
) )
text = fields.Html( text = fields.Html(
string='Comment', string="Comment",
translate=True, translate=True,
required=True, required=True,
) )
company_id = fields.Many2one( company_id = fields.Many2one(
'res.company', "res.company",
string='Company', string="Company",
help="If set, it'll only be available for this company", help="If set, it'll only be available for this company",
ondelete='cascade', ondelete="cascade",
index=True, index=True,
) )
@api.multi
def get_value(self, partner_id=False): def get_value(self, partner_id=False):
self.ensure_one() self.ensure_one()
lang = None lang = None
if partner_id: if partner_id:
lang = self.env['res.partner'].browse(partner_id).lang lang = self.env["res.partner"].browse(partner_id).lang
return self.with_context({'lang': lang}).text return self.with_context({"lang": lang}).text

View File

@@ -7,13 +7,13 @@ class ResPartner(models.Model):
_inherit = "res.partner" _inherit = "res.partner"
property_comment_template_id = fields.Many2one( property_comment_template_id = fields.Many2one(
comodel_name='base.comment.template', comodel_name="base.comment.template",
string='Conditions template', string="Conditions template",
company_dependent=True, company_dependent=True,
) )
@api.model @api.model
def _commercial_fields(self): def _commercial_fields(self):
res = super(ResPartner, self)._commercial_fields() res = super(ResPartner, self)._commercial_fields()
res += ['property_comment_template_id'] res += ["property_comment_template_id"]
return res return res

2
base_comment_template/readme/CONTRIBUTORS.rst Executable file → Normal file
View File

@@ -11,4 +11,4 @@
* `Druidoo <https://www.druidoo.io>`_: * `Druidoo <https://www.druidoo.io>`_:
* Iván Todorovich <ivan.todorovich@druidoo.io> * Iván Todorovich <ivan.todorovich@druidoo.io>
* Pierre Verkest <pierreverkest84@gmail.com>

View File

@@ -10,4 +10,3 @@ This module is the base module for following modules:
* sale_comment_template * sale_comment_template
* purchase_comment_template * purchase_comment_template
* invoice_comment_template * invoice_comment_template

View File

@@ -5,7 +5,9 @@
<field name="name">Base comment multi-company</field> <field name="name">Base comment multi-company</field>
<field name="model_id" ref="model_base_comment_template" /> <field name="model_id" ref="model_base_comment_template" />
<field name="global" eval="True" /> <field name="global" eval="True" />
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> <field
name="domain_force"
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record> </record>
</odoo> </odoo>

View File

@@ -3,20 +3,20 @@ from odoo.tests.common import TransactionCase
class TestResPartner(TransactionCase): class TestResPartner(TransactionCase):
def setUp(self): def setUp(self):
super(TestResPartner, self).setUp() super(TestResPartner, self).setUp()
self.template_id = self.env['base.comment.template'].create({ self.template_id = self.env["base.comment.template"].create(
'name': 'Comment before lines', {
'position': 'before_lines', "name": "Comment before lines",
'text': 'Text before lines', "position": "before_lines",
}) "text": "Text before lines",
}
)
def test_commercial_partner_fields(self): def test_commercial_partner_fields(self):
# Azure Interior # Azure Interior
partner_id = self.env.ref('base.res_partner_12') partner_id = self.env.ref("base.res_partner_12")
partner_id.property_comment_template_id = self.template_id.id partner_id.property_comment_template_id = self.template_id.id
# Test childs propagation of commercial partner field # Test childs propagation of commercial partner field
for child_id in partner_id.child_ids: for child_id in partner_id.child_ids:
self.assertEqual( self.assertEqual(child_id.property_comment_template_id, self.template_id)
child_id.property_comment_template_id, self.template_id)

View File

@@ -20,8 +20,17 @@
<form string="Comment Templates"> <form string="Comment Templates">
<sheet> <sheet>
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive"> <button
<field name="active" widget="boolean_button" options="{&quot;terminology&quot;: &quot;archive&quot;}"/> name="toggle_active"
type="object"
class="oe_stat_button"
icon="fa-archive"
>
<field
name="active"
widget="boolean_button"
options="{&quot;terminology&quot;: &quot;archive&quot;}"
/>
</button> </button>
</div> </div>
<div class="oe_title"> <div class="oe_title">
@@ -31,10 +40,17 @@
</div> </div>
<group> <group>
<group> <group>
<field name="position" widget="radio" invisible="context.get('default_position')"/> <field
name="position"
widget="radio"
invisible="context.get('default_position')"
/>
</group> </group>
<group> <group>
<field name="company_id" groups="base.group_multi_company"/> <field
name="company_id"
groups="base.group_multi_company"
/>
</group> </group>
</group> </group>
<notebook> <notebook>
@@ -64,7 +80,6 @@
<field name="name">Comment Templates</field> <field name="name">Comment Templates</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">base.comment.template</field> <field name="res_model">base.comment.template</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="view_id" ref="view_base_comment_template_tree" /> <field name="view_id" ref="view_base_comment_template_tree" />
</record> </record>

View File

@@ -6,7 +6,10 @@
<field name="priority" eval="2" /> <field name="priority" eval="2" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<group name="sale" position="inside"> <group name="sale" position="inside">
<field name="property_comment_template_id" attrs="{'invisible': ['|',('customer', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"/> <field
name="property_comment_template_id"
attrs="{'invisible': [('parent_id', '!=', False)]}"
/>
</group> </group>
</field> </field>
</record> </record>