odoo-addon-contract 18.0.2.0.8__py3-none-any.whl → 18.0.2.0.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ Recurring - Contracts Management
11
11
  !! This file is generated by oca-gen-addon-readme !!
12
12
  !! changes will be overwritten. !!
13
13
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
- !! source digest: sha256:a643d8e9740ea79099b147dcd5310757734569ef271a9790c8a5a58bfb8f1cec
14
+ !! source digest: sha256:4f24d5a0544622601f21bd74ba692382ebb4a1c14375972bbea81e8fc86c1b71
15
15
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16
16
 
17
17
  .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
@@ -11,7 +11,7 @@
11
11
 
12
12
  {
13
13
  "name": "Recurring - Contracts Management",
14
- "version": "18.0.2.0.8",
14
+ "version": "18.0.2.0.10",
15
15
  "category": "Contract Management",
16
16
  "license": "AGPL-3",
17
17
  "author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)",
@@ -42,6 +42,9 @@ class ContractContract(models.Model):
42
42
  group_id = fields.Many2one(
43
43
  string="Group",
44
44
  comodel_name="account.analytic.account",
45
+ compute="_compute_group_id",
46
+ store=True,
47
+ readonly=False,
45
48
  ondelete="restrict",
46
49
  )
47
50
  tag_ids = fields.Many2many(comodel_name="contract.tag", string="Tags")
@@ -215,6 +218,32 @@ class ContractContract(models.Model):
215
218
  "invoice"
216
219
  ]
217
220
 
221
+ @api.depends(
222
+ "contract_line_ids",
223
+ "contract_line_ids.analytic_distribution",
224
+ "contract_line_fixed_ids",
225
+ "contract_line_fixed_ids.analytic_distribution",
226
+ )
227
+ def _compute_group_id(self):
228
+ """Compute the group_id based on the analytic_distribution
229
+ in the contract lines.
230
+ If all contract lines have the same analytic account, set it as group_id.
231
+ Otherwise, set group_id to False.
232
+ """
233
+ for record in self:
234
+ record.group_id = False
235
+ all_analytic_accounts = []
236
+ contract_lines = record.contract_line_ids | record.contract_line_fixed_ids
237
+ for line in contract_lines:
238
+ if line.analytic_distribution:
239
+ all_analytic_accounts.extend(
240
+ int(acc_id)
241
+ for account_ids in line.analytic_distribution.keys()
242
+ for acc_id in account_ids.split(",")
243
+ )
244
+ if len(set(all_analytic_accounts)) == 1:
245
+ record.group_id = all_analytic_accounts[0]
246
+
218
247
  # === Onchange Methods ===
219
248
 
220
249
  @api.onchange("contract_template_id")
@@ -539,14 +568,6 @@ class ContractContract(models.Model):
539
568
  """
540
569
  self.ensure_one()
541
570
 
542
- def can_be_invoiced(contract_line):
543
- return (
544
- not contract_line.is_canceled
545
- and contract_line.recurring_next_date
546
- and contract_line.recurring_next_date <= date_ref
547
- and contract_line.next_period_date_start
548
- )
549
-
550
571
  lines2invoice = previous = self.env["contract.line"]
551
572
  current_section = current_note = False
552
573
  for line in self.contract_line_ids:
@@ -560,7 +581,7 @@ class ContractContract(models.Model):
560
581
  elif line.note_invoicing_mode == "with_next_line":
561
582
  current_note = line
562
583
  elif line.is_recurring_note or not line.display_type:
563
- if can_be_invoiced(line):
584
+ if line._can_be_invoiced(date_ref):
564
585
  if current_section:
565
586
  lines2invoice |= current_section
566
587
  current_section = False
@@ -261,6 +261,15 @@ class ContractLine(models.Model):
261
261
  }
262
262
  )
263
263
 
264
+ def _can_be_invoiced(self, date_ref):
265
+ self.ensure_one()
266
+ return (
267
+ not self.is_canceled
268
+ and self.recurring_next_date
269
+ and self.recurring_next_date <= date_ref
270
+ and self.next_period_date_start
271
+ )
272
+
264
273
  @api.model
265
274
  def get_view(self, view_id=None, view_type="form", **options):
266
275
  default_contract_type = self.env.context.get("default_contract_type")
@@ -372,7 +372,7 @@ ul.auto-toc {
372
372
  !! This file is generated by oca-gen-addon-readme !!
373
373
  !! changes will be overwritten. !!
374
374
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375
- !! source digest: sha256:a643d8e9740ea79099b147dcd5310757734569ef271a9790c8a5a58bfb8f1cec
375
+ !! source digest: sha256:4f24d5a0544622601f21bd74ba692382ebb4a1c14375972bbea81e8fc86c1b71
376
376
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377
377
  <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/18.0/contract"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-18-0/contract-18-0-contract"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378
378
  <p>This module enables contracts management with recurring invoicing
@@ -1557,3 +1557,39 @@ class TestContract(TestContractBase):
1557
1557
  self.contract3.contract_line_ids.recurring_next_date = fields.Date.today()
1558
1558
  invoice_id = self.contract3.recurring_create_invoice()
1559
1559
  self.assertEqual(invoice_id.invoice_line_ids[0].name, "Header for May Services")
1560
+
1561
+ def test_analytic_account(self):
1562
+ """Tests the automatic setting of the analytic account on the contract
1563
+ depending on the analytic accounts set on the contract lines.
1564
+ # Case 1: only one contract line with one analytic account
1565
+ => the analytic account is set on the contract
1566
+ # Case 2: only one contract line with two analytic accounts
1567
+ => the analytic account is not set on the contract
1568
+ # Case 3: two contract lines, with the same analytic account
1569
+ => the analytic account is set on the contract
1570
+ # Case 4: two contract lines, each one with one analytic account
1571
+ => the analytic account is not set on the contract
1572
+ """
1573
+ plan = self.env["account.analytic.plan"].create({"name": "Test plan contract"})
1574
+ self.analytic_account_1 = self.env["account.analytic.account"].create(
1575
+ {"name": "Test account contract 1", "plan_id": plan.id}
1576
+ )
1577
+ self.analytic_account_2 = self.env["account.analytic.account"].create(
1578
+ {"name": "Test account contract 2", "plan_id": plan.id}
1579
+ )
1580
+ # Case 1: only one contract line with one analytic account
1581
+ self.acct_line.analytic_distribution = {self.analytic_account_1.id: 100}
1582
+ self.assertEqual(self.contract.group_id, self.analytic_account_1)
1583
+ # Case 2: only one contract line with two analytic accounts
1584
+ self.acct_line.analytic_distribution = {
1585
+ self.analytic_account_1.id: 50,
1586
+ self.analytic_account_2.id: 50,
1587
+ }
1588
+ self.assertFalse(self.contract.group_id)
1589
+ # Case 3: two contract lines, with the same analytic account
1590
+ self.acct_line.analytic_distribution = {self.analytic_account_1.id: 100}
1591
+ new_contract_line = self.acct_line.copy()
1592
+ self.assertEqual(self.contract.group_id, self.analytic_account_1)
1593
+ # Case 4: two contract lines, each one with one analytic account
1594
+ new_contract_line.analytic_distribution = {self.analytic_account_2.id: 100}
1595
+ self.assertFalse(self.contract.group_id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: odoo-addon-contract
3
- Version: 18.0.2.0.8
3
+ Version: 18.0.2.0.10
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: odoo==18.0.*
6
6
  Summary: Recurring - Contracts Management
@@ -28,7 +28,7 @@ Recurring - Contracts Management
28
28
  !! This file is generated by oca-gen-addon-readme !!
29
29
  !! changes will be overwritten. !!
30
30
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31
- !! source digest: sha256:a643d8e9740ea79099b147dcd5310757734569ef271a9790c8a5a58bfb8f1cec
31
+ !! source digest: sha256:4f24d5a0544622601f21bd74ba692382ebb4a1c14375972bbea81e8fc86c1b71
32
32
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33
33
 
34
34
  .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
@@ -1,6 +1,6 @@
1
- odoo/addons/contract/README.rst,sha256=jQYvFaIUKbbTboFzrm4FJ-LNWFlwRuIJZxedz6iLmBU,6176
1
+ odoo/addons/contract/README.rst,sha256=mpqqvQFM9JraBvXe75rdPztk9aGufsNVsG5gZIIQP4I,6176
2
2
  odoo/addons/contract/__init__.py,sha256=dnUeA_K1torbiMNF3tt2dtECdk-FkWm01DByr9MBMIA,69
3
- odoo/addons/contract/__manifest__.py,sha256=0TcJi1M7IT-9Gr2299RwSd_TFqANxrHojhtvwT9dASQ,1777
3
+ odoo/addons/contract/__manifest__.py,sha256=IllRPyWiCQo3F-Wt247jLZPu3KVUBYGHXWeI71kXRhU,1778
4
4
  odoo/addons/contract/controllers/__init__.py,sha256=ZAYSY9pxyJjumL2QVLuxqtBzjLwKPiQsVXMBAWvNGGY,85
5
5
  odoo/addons/contract/controllers/main.py,sha256=5C-WzZ6zPWeea-Kb0U01a1yNCtcn29iZeoc9hjkODa4,3676
6
6
  odoo/addons/contract/data/contract_cron.xml,sha256=yYTdn4fmIU5zsfFEgx-H_55M9nwc0WfJ3Q6ufxQKPt8,549
@@ -84,8 +84,8 @@ odoo/addons/contract/migrations/18.0.2.0.0/pre-migrate.py,sha256=ywaZcxy-bxj2MRi
84
84
  odoo/addons/contract/models/__init__.py,sha256=n3UpKXb_Oi-2ebHho6pWrd6kw_cMK6GG1E3fl7ey_zc,372
85
85
  odoo/addons/contract/models/account_move.py,sha256=QdSF_E5cifIgOiPiZ1PKXxuA5y9y4PC-kkUurDdGKo4,387
86
86
  odoo/addons/contract/models/account_move_line.py,sha256=X-GJ66Q_6BySwImRLMpFxgIqfhsOaEUb6xLSQveB0uc,396
87
- odoo/addons/contract/models/contract.py,sha256=KJtdPswD9RjOUPVhnkH08Peml3niWKWvHswseyqkKoc,25646
88
- odoo/addons/contract/models/contract_line.py,sha256=0vuK44zs8jByFnYFI0nZ9IYz8lsbv7nPdhaDLpYIYIA,10298
87
+ odoo/addons/contract/models/contract.py,sha256=2zUJmp8-4ZhOxVJ4sLE9q1dotjXbeXsolA8PZx2LxGc,26533
88
+ odoo/addons/contract/models/contract_line.py,sha256=UgCJI5S0ttfRuWeqbNNhylFeZR7El2P-QVQ0p7aW1Yk,10565
89
89
  odoo/addons/contract/models/contract_modification.py,sha256=d0tv2Zn6_WrR633pmzwAavzC2I3sLYmGokOKtMn7AYY,1147
90
90
  odoo/addons/contract/models/contract_recurring_mixin.py,sha256=KE4sMLd241v1RgTtdPGHbak-RD2sJmSLYsKNPWaQ8Mg,9278
91
91
  odoo/addons/contract/models/contract_tag.py,sha256=h5Up3F6ijIhQbYSB6xCqZVVUtyLYxfj4MsAIKv2Q5-Q,434
@@ -103,7 +103,7 @@ odoo/addons/contract/security/contract_security.xml,sha256=HZuxPZMX-EMf8QtXdwbnL
103
103
  odoo/addons/contract/security/contract_tag.xml,sha256=cetorNv2M6tHKHcnfwUeX85EZyT3tpoBLF8W-XZ7sK8,890
104
104
  odoo/addons/contract/security/ir.model.access.csv,sha256=icelaOGF35WgUrxB2l18IVfcUNlPuJnzy4LG676_zt0,1569
105
105
  odoo/addons/contract/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
106
- odoo/addons/contract/static/description/index.html,sha256=cjMizvgrvI_vJh0ihAyGedCVdWZ3hSDoS1QXyXNPvx0,17445
106
+ odoo/addons/contract/static/description/index.html,sha256=nA68f9bjvyKCK_ody-ruXve5veu_Nr2iEIDAPWfJDa8,17445
107
107
  odoo/addons/contract/static/src/img/contract_icon.svg,sha256=2IFs70Oy9WtE9of2SO4Vj08mwzcw-I5s_LL3UvtKlus,9643
108
108
  odoo/addons/contract/static/src/js/contract_portal_tour.esm.js,sha256=ULRzpiiKOhvKx0P-SBoMVBJzGtOQfi70yf2-1djxFuk,589
109
109
  odoo/addons/contract/static/src/screenshots/portal-detail.png,sha256=8pMCU4nqwnSM-rbWZd3iJxXdYLBiYzuWNvT_NKslcoo,113399
@@ -111,7 +111,7 @@ odoo/addons/contract/static/src/screenshots/portal-list.png,sha256=gWSW4rlncFZem
111
111
  odoo/addons/contract/static/src/screenshots/portal-my.png,sha256=YrtvTDjoc839Eka5zSZ8FQhtzoMEeW4FrXGrYAwAkS4,22985
112
112
  odoo/addons/contract/static/src/scss/frontend.scss,sha256=LilfXNOwW8D2eXOMY0ZgrEv8hU5Vn1u9inCEIJp8D0g,1863
113
113
  odoo/addons/contract/tests/__init__.py,sha256=iive8lH1QtzKmbhBBzzU4AQgSAgWxdJF1mMLEFOiA4c,138
114
- odoo/addons/contract/tests/test_contract.py,sha256=zUsuGNECeIhtkFJ_LmKUA8m5uzurFSLx34oN_C48siI,66532
114
+ odoo/addons/contract/tests/test_contract.py,sha256=SbfNbmuVT6mSL8avthQLUsqWdz1JVtKlyMMB62TR9vM,68620
115
115
  odoo/addons/contract/tests/test_contract_manually_create_invoice.py,sha256=GfA-hDaI4mSztE-2zQgFE_bQM-nsKzFhQRybi8EGeLo,2541
116
116
  odoo/addons/contract/tests/test_multicompany.py,sha256=0CPfv0-JSFsXRInazugzzYrogSZFa6lrdNwuBLbaTX8,4552
117
117
  odoo/addons/contract/tests/test_portal.py,sha256=pyhXyzB5o-jdzJW6x10tF7pRuIUQWLQXTSUsB7nUB2k,1298
@@ -126,7 +126,7 @@ odoo/addons/contract/views/res_partner_view.xml,sha256=v7RAxXm0japPQeOsf2zLgieZH
126
126
  odoo/addons/contract/wizards/__init__.py,sha256=ZSirPz2XSS6FGPESnPJHqIJamHdHrdL7j2oYu_kglTs,47
127
127
  odoo/addons/contract/wizards/contract_manually_create_invoice.py,sha256=LIOStLcchRqOeRbHCPnEmrEj1c9_8BSW6HixsBmU57Y,2986
128
128
  odoo/addons/contract/wizards/contract_manually_create_invoice.xml,sha256=JPgtH9mDP74PhTgsJ0lZ1zmn8P3WWRRKp9QUWn38W-4,3730
129
- odoo_addon_contract-18.0.2.0.8.dist-info/METADATA,sha256=950v-qckT1BwKDTaBPWNPzU8c3vs4s1akeLG4_kL6qc,6785
130
- odoo_addon_contract-18.0.2.0.8.dist-info/WHEEL,sha256=ZhOvUsYhy81Dx67gN3TV0RchQWBIIzutDZaJODDg2Vo,81
131
- odoo_addon_contract-18.0.2.0.8.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
132
- odoo_addon_contract-18.0.2.0.8.dist-info/RECORD,,
129
+ odoo_addon_contract-18.0.2.0.10.dist-info/METADATA,sha256=6VCxOlmpWavMCVSRfUnN_eGMWXa8S2IDST2V2otX1sU,6786
130
+ odoo_addon_contract-18.0.2.0.10.dist-info/WHEEL,sha256=ZhOvUsYhy81Dx67gN3TV0RchQWBIIzutDZaJODDg2Vo,81
131
+ odoo_addon_contract-18.0.2.0.10.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
132
+ odoo_addon_contract-18.0.2.0.10.dist-info/RECORD,,