Skip to content

Commit

Permalink
[MIG] agreement: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Tran committed Dec 12, 2024
1 parent 4053a8e commit 933cea7
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 36 deletions.
10 changes: 10 additions & 0 deletions agreement/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ Contributors

- Maxime Franco

- `Trobz <https://www.trobz.com/>`__:

- Nhan Tran <[email protected]>

Other credits
-------------

The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion agreement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Agreement",
"summary": "Adds an agreement object",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Contract",
"author": "Akretion, "
"Yves Goldberg (Ygol Internetwork), "
Expand Down
20 changes: 7 additions & 13 deletions agreement/models/agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import _, api, fields, models
from odoo import api, fields, models


class Agreement(models.Model):
Expand All @@ -26,7 +26,6 @@ class Agreement(models.Model):
)
is_template = fields.Boolean(
string="Is a Template?",
default=False,
copy=False,
help="Set if the agreement is a template. "
"Template agreements don't require a partner.",
Expand All @@ -51,8 +50,8 @@ class Agreement(models.Model):
@api.model
def _domain_selection(self):
return [
("sale", _("Sale")),
("purchase", _("Purchase")),
("sale", self.env._("Sale")),
("purchase", self.env._("Purchase")),
]

@api.depends("agreement_type_id")
Expand All @@ -63,14 +62,9 @@ def _compute_domain(self):
else:
rec.domain = "sale"

def name_get(self):
res = []
for agr in self:
name = agr.name
if agr.code:
name = f"[{agr.code}] {agr.name}"
res.append((agr.id, name))
return res
def _compute_display_name(self):
for rec in self:
rec.display_name = f"[{rec.code}] {rec.name}"

_sql_constraints = [
(
Expand All @@ -85,5 +79,5 @@ def copy(self, default=None):
default = dict(default or {})
if default.get("code", False):
return super().copy(default)
default.setdefault("code", _("%(code)s (copy)", code=self.code))
default.setdefault("code", self.env._("%(code)s (copy)", code=self.code))
return super().copy(default)
3 changes: 3 additions & 0 deletions agreement/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
- [Acsone](https://www.acsone.eu/):

- Maxime Franco
- [Trobz](https://www.trobz.com/):

- Nhan Tran \<<[email protected]>\>
2 changes: 2 additions & 0 deletions agreement/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.
15 changes: 13 additions & 2 deletions agreement/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ <h1 class="title">Agreement</h1>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -434,10 +435,20 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Maxime Franco</li>
</ul>
</li>
<li><p class="first"><a class="reference external" href="https://www.trobz.com/">Trobz</a>:</p>
<ul class="simple">
<li>Nhan Tran &lt;<a class="reference external" href="mailto:nhant&#64;trobz.com">nhant&#64;trobz.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<p>The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
9 changes: 4 additions & 5 deletions agreement/tests/test_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ def test_agreement_type_change(self):
self.agreement.write({"agreement_type_id": self.agreement_type.id})
self.assertEqual(self.agreement.domain, self.agreement_type.domain)

def test_name_get(self):
res = self.agreement.name_get()
self.assertEqual(res[0][0], self.agreement.id)
self.assertEqual(res[0][1], f"[{self.agreement.code}] {self.agreement.name}")
def test_compute_display_name(self):
display_name = self.agreement.display_name
self.assertEqual(display_name, f"[{self.agreement.code}] {self.agreement.name}")

def test_copy(self):
agreement1 = self.agreement.copy(default={"code": "Test Code"})
agreement2 = self.agreement.copy()
self.assertEqual(agreement1.code, "Test Code")
self.assertEqual(agreement2.code, "%s (copy)" % (self.agreement.code))
self.assertEqual(agreement2.code, f"{self.agreement.code} (copy)")
16 changes: 5 additions & 11 deletions agreement/views/agreement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
bg_color="bg-danger"
invisible="active"
/>
<field name="active" invisible="1" />
<div class="oe_title">
<label
for="name"
Expand All @@ -31,7 +30,6 @@
<group name="main">
<group name="left">
<field name="code" />
<field name="is_template" invisible="1" />
<field name="partner_id" required="not is_template" />
<field
name="agreement_type_id"
Expand All @@ -57,19 +55,15 @@
<page name="config" string="Configuration" invisible="True" />
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="activity_ids" widget="mail_activity" />
<field name="message_ids" widget="mail_thread" />
</div>
<chatter />
</form>
</field>
</record>
<record id="agreement_tree" model="ir.ui.view">
<field name="name">agreement.tree</field>
<field name="name">agreement.list</field>
<field name="model">agreement</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="partner_id" />
<field name="code" />
<field name="name" />
Expand All @@ -78,7 +72,7 @@
<field name="end_date" />
<field name="domain" />
<field name="company_id" groups="base.group_multi_company" />
</tree>
</list>
</field>
</record>
<record id="agreement_search" model="ir.ui.view">
Expand Down Expand Up @@ -128,6 +122,6 @@
<record id="agreement_action" model="ir.actions.act_window">
<field name="name">Agreements</field>
<field name="res_model">agreement</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
7 changes: 3 additions & 4 deletions agreement/views/agreement_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<field name="name">Agreement Type List</field>
<field name="model">agreement.type</field>
<field name="arch" type="xml">
<tree default_order="name">
<list default_order="name">
<field name="name" string="Type Name" />
<field name="domain" />
</tree>
</list>
</field>
</record>
<!-- Agreement Type Form View -->
Expand All @@ -25,7 +25,6 @@
bg_color="bg-danger"
invisible="active"
/>
<field name="active" invisible="1" />
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
Expand Down Expand Up @@ -72,6 +71,6 @@
<record id="agreement_type_action" model="ir.actions.act_window">
<field name="name">Agreement Types</field>
<field name="res_model">agreement.type</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>
</odoo>

0 comments on commit 933cea7

Please sign in to comment.