Browse Source

[IMP] base_comment_template: black, isort, prettier

myc-14.0-py3o
Pierre Verkest 4 years ago
parent
commit
85e13a0bf7
  1. 8
      base_comment_template/README.rst
  2. 6
      base_comment_template/__manifest__.py
  3. 2
      base_comment_template/i18n/base_comment_template.pot
  4. 13
      base_comment_template/migrations/12.0.2.0.0/pre-migration.py
  5. 23
      base_comment_template/models/comment.py
  6. 6
      base_comment_template/models/res_partner.py
  7. 2
      base_comment_template/readme/CONTRIBUTORS.rst
  8. 1
      base_comment_template/readme/DESCRIPTION.rst
  9. 10
      base_comment_template/security/security.xml
  10. 18
      base_comment_template/tests/test_base_comment_template.py
  11. 47
      base_comment_template/views/comment_view.xml
  12. 9
      base_comment_template/views/res_partner.xml

8
base_comment_template/README.rst

@ -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.

6
base_comment_template/__manifest__.py

@ -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": [
"base"
],
"depends": ["base"],
"data": [ "data": [
"security/ir.model.access.csv", "security/ir.model.access.csv",
"security/security.xml", "security/security.xml",

2
base_comment_template/i18n/base_comment_template.pot

@ -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"

13
base_comment_template/migrations/12.0.2.0.0/pre-migration.py

@ -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)]})

23
base_comment_template/models/comment.py

@ -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'),
('after_lines', 'After lines'),
("before_lines", "Before 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',
string='Company',
"res.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
return self.with_context({'lang': lang}).text
lang = self.env["res.partner"].browse(partner_id).lang
return self.with_context({"lang": lang}).text

6
base_comment_template/models/res_partner.py

@ -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',
string='Conditions template',
comodel_name="base.comment.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

@ -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>

1
base_comment_template/readme/DESCRIPTION.rst

@ -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

10
base_comment_template/security/security.xml

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<record model="ir.rule" id="rule_multicompany"> <record model="ir.rule" id="rule_multicompany">
<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="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="model_id" ref="model_base_comment_template" />
<field name="global" eval="True" />
<field
name="domain_force"
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record> </record>
</odoo> </odoo>

18
base_comment_template/tests/test_base_comment_template.py

@ -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({
'name': 'Comment before lines',
'position': 'before_lines',
'text': 'Text before lines',
})
self.template_id = self.env["base.comment.template"].create(
{
"name": "Comment 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(
child_id.property_comment_template_id, self.template_id)
self.assertEqual(child_id.property_comment_template_id, self.template_id)

47
base_comment_template/views/comment_view.xml

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<record model="ir.ui.view" id="view_base_comment_template_search"> <record model="ir.ui.view" id="view_base_comment_template_search">
@ -6,9 +6,9 @@
<field name="model">base.comment.template</field> <field name="model">base.comment.template</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Comment Templates"> <search string="Comment Templates">
<field name="name"/>
<field name="position"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="name" />
<field name="position" />
<field name="company_id" groups="base.group_multi_company" />
</search> </search>
</field> </field>
</record> </record>
@ -20,26 +20,42 @@
<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">
<field name="active" widget="boolean_button" options="{&quot;terminology&quot;: &quot;archive&quot;}"/>
<button
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">
<h1> <h1>
<field name="name" placeholder="Name"/>
<field name="name" placeholder="Name" />
</h1> </h1>
</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>
<page name="text" string="Comment"> <page name="text" string="Comment">
<field name="text"/>
<field name="text" />
</page> </page>
</notebook> </notebook>
</sheet> </sheet>
@ -50,12 +66,12 @@
<record model="ir.ui.view" id="view_base_comment_template_tree"> <record model="ir.ui.view" id="view_base_comment_template_tree">
<field name="name">account.comment.template.list</field> <field name="name">account.comment.template.list</field>
<field name="model">base.comment.template</field> <field name="model">base.comment.template</field>
<field name="priority" eval="6"/>
<field name="priority" eval="6" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree> <tree>
<field name="name"/>
<field name="position"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="name" />
<field name="position" />
<field name="company_id" groups="base.group_multi_company" />
</tree> </tree>
</field> </field>
</record> </record>
@ -64,9 +80,8 @@
<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>
</odoo> </odoo>

9
base_comment_template/views/res_partner.xml

@ -2,11 +2,14 @@
<record id="view_partner_form" model="ir.ui.view"> <record id="view_partner_form" model="ir.ui.view">
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority" eval="2"/>
<field name="inherit_id" ref="base.view_partner_form" />
<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>

Loading…
Cancel
Save