Skip to content

Commit

Permalink
[MIG] Migrated contract module to v. 16.0. No real changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wpichler committed Oct 24, 2022
1 parent 49bc702 commit 9b9f136
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 221 deletions.
2 changes: 1 addition & 1 deletion contract/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

{
"name": "Recurring - Contracts Management",
"version": "15.0.1.5.2",
"version": "16.0.1.0.0",
"category": "Contract Management",
"license": "AGPL-3",
"author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)",
Expand Down
19 changes: 0 additions & 19 deletions contract/data/template_mail_notification.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
<?xml version="1.0" ?>
<odoo>
<template
id="mail_notification_contract"
inherit_id="mail.mail_notification_paynow"
primary="True"
>
<xpath expr="//t[@t-out='message.body']" position="after">
<t t-raw="0" />
<t t-if="record._name == 'contract.contract'">
<t
t-set="share_url"
t-value="record._get_share_url(redirect=True, signup_partner=True, share_token=True)"
/>
<t
t-set="access_url"
t-value="is_online and share_url and base_url + share_url or ''"
/>
</t>
</xpath>
</template>
<template id="template_contract_modification" name="Contract Modification">
<t t-call="contract.mail_notification_contract">
<table border="1" align="center">
Expand Down
141 changes: 0 additions & 141 deletions contract/migrations/15.0.1.0.0/noupdate_changes.xml

This file was deleted.

17 changes: 0 additions & 17 deletions contract/migrations/15.0.1.0.0/post-migration.py

This file was deleted.

4 changes: 3 additions & 1 deletion contract/models/abstract_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ContractAbstractContract(models.AbstractModel):
_inherit = "contract.recurrency.basic.mixin"
_name = "contract.abstract.contract"
_description = "Abstract Recurring Contract"
_check_company_auto = True

# These fields will not be synced to the contract
NO_SYNC = ["name", "partner_id", "company_id"]
Expand All @@ -31,11 +32,12 @@ class ContractAbstractContract(models.AbstractModel):
journal_id = fields.Many2one(
comodel_name="account.journal",
string="Journal",
domain="[('type', '=', contract_type)," "('company_id', '=', company_id)]",
domain="[('type', '=', contract_type)]",
compute="_compute_journal_id",
store=True,
readonly=False,
index=True,
check_company=True,
)
company_id = fields.Many2one(
"res.company",
Expand Down
4 changes: 2 additions & 2 deletions contract/models/abstract_contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _compute_price_unit(self):
"old_date", fields.Date.context_today(line)
),
)
line.price_unit = product.price
line.price_unit = pricelist._get_product_price(product, quantity=1)
else:
line.price_unit = line.specific_price

Expand Down Expand Up @@ -257,5 +257,5 @@ def _onchange_product_id(self):
uom=self.uom_id.id,
)
vals["name"] = self.product_id.get_product_multiline_description_sale()
vals["price_unit"] = product.price
vals["price_unit"] = self.contract_id.pricelist_id._get_product_price(product, quantity=1)
self.update(vals)
4 changes: 2 additions & 2 deletions contract/models/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def _onchange_partner_id(self):
self.pricelist_id = partner.property_product_pricelist.id
self.fiscal_position_id = partner.env[
"account.fiscal.position"
].get_fiscal_position(partner.id)
]._get_fiscal_position(partner.id)
if self.contract_type == "purchase":
self.payment_term_id = partner.property_supplier_payment_term_id
else:
Expand Down Expand Up @@ -563,7 +563,7 @@ def _prepare_recurring_invoices_values(self, date_ref=False):
invoice_vals["invoice_line_ids"].append((0, 0, invoice_line_vals))
invoices_values.append(invoice_vals)
# Force the recomputation of journal items
del invoice_vals["line_ids"]
# del invoice_vals["line_ids"] # TODO: Check why line_ids is missing here
contract_lines._update_recurring_next_date()
return invoices_values

Expand Down
10 changes: 3 additions & 7 deletions contract/models/contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class ContractLine(models.Model):
string="Analytic account",
comodel_name="account.analytic.account",
)
analytic_tag_ids = fields.Many2many(
comodel_name="account.analytic.tag",
string="Analytic Tags",
)
date_start = fields.Date(required=True)
date_end = fields.Date(compute="_compute_date_end", store=True, readonly=False)
termination_notice_date = fields.Date(
Expand Down Expand Up @@ -548,10 +544,11 @@ def _prepare_invoice_line(self, move_form):
self.last_date_invoiced, self.recurring_next_date
)
line_form = move_form.invoice_line_ids.new()
line_form.display_type = self.display_type
line_form.display_type = self.display_type or 'product'
line_form.product_id = self.product_id
invoice_line_vals = line_form._values_to_save(all_fields=True)
name = self._insert_markers(dates[0], dates[1])
# TODO: We lost the analytic_account_id on invoice line vals - need to check what to use now
invoice_line_vals.update(
{
"account_id": invoice_line_vals["account_id"]
Expand All @@ -563,9 +560,8 @@ def _prepare_invoice_line(self, move_form):
"contract_line_id": self.id,
"sequence": self.sequence,
"name": name,
"analytic_account_id": self.analytic_account_id.id,
"analytic_tag_ids": [(6, 0, self.analytic_tag_ids.ids)],
"price_unit": self.price_unit,
"display_type": self.display_type or "product",
}
)
return invoice_line_vals
Expand Down
10 changes: 5 additions & 5 deletions contract/tests/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ def test_automatic_price(self):
self.assertEqual(self.acct_line.price_unit, 1100)
# Try to write other price
self.acct_line.price_unit = 10
self.acct_line.refresh()
self.acct_line.invalidate_model()
self.assertEqual(self.acct_line.price_unit, 1100)
# Now disable automatic price
self.acct_line.automatic_price = False
self.acct_line.price_unit = 10
self.acct_line.refresh()
self.acct_line.invalidate_model()
self.assertEqual(self.acct_line.price_unit, 10)

def test_contract(self):
Expand All @@ -266,7 +266,7 @@ def test_contract(self):

def test_contract_level_recurrence(self):
self.contract3.recurring_create_invoice()
self.contract3.flush()
self.contract3.flush_recordset()

def test_contract_daily(self):
recurring_next_date = to_date("2018-02-23")
Expand Down Expand Up @@ -608,7 +608,7 @@ def test_contract_count(self):
self.contract.copy()
purchase_count = self.partner.purchase_contract_count + 1
self.contract2.copy()
self.partner.refresh()
self.partner.invalidate_model()
self.assertEqual(self.partner.sale_contract_count, sale_count)
self.assertEqual(self.partner.purchase_contract_count, purchase_count)

Expand Down Expand Up @@ -2045,7 +2045,7 @@ def test_contract_line_state(self):
]
self.assertEqual(set(lines.mapped("state")), set(states))
# Test search method
lines.flush() # Needed for computed stored fields like termination_notice_date
lines.flush_recordset() # Needed for computed stored fields like termination_notice_date
for state in states:
lines = self.env["contract.line"].search([("state", "=", state)])
self.assertTrue(lines, state)
Expand Down
14 changes: 2 additions & 12 deletions contract/views/contract.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@
name="analytic_account_id"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
groups="analytic.group_analytic_tags"
/>
<field name="quantity" />
<field name="uom_id" />
<field
Expand Down Expand Up @@ -322,11 +317,6 @@
name="analytic_account_id"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
groups="analytic.group_analytic_tags"
/>
<field name="quantity" />
<field name="uom_id" />
<field
Expand Down Expand Up @@ -504,7 +494,7 @@
<field name="journal_id" position="attributes">
<attribute
name="domain"
>[('type', '=', 'sale'),('company_id', '=', company_id)]</attribute>
>[('type', '=', 'sale')]</attribute>
</field>
</field>
</record>
Expand All @@ -525,7 +515,7 @@
<field name="journal_id" position="attributes">
<attribute
name="domain"
>[('type', '=', 'purchase'),('company_id', '=', company_id)]</attribute>
>[('type', '=', 'purchase')]</attribute>
</field>
</field>
</record>
Expand Down
Loading

0 comments on commit 9b9f136

Please sign in to comment.