Skip to content

Commit

Permalink
[MIG] contract: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wpichler authored and pedrobaeza committed Mar 15, 2023
1 parent c72ead9 commit 10e9287
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 341 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.

6 changes: 5 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 Expand Up @@ -80,3 +82,5 @@ def _compute_journal_id(self):
journal = AccountJournal.search(domain, limit=1)
if journal:
contract.journal_id = journal.id
else:
contract.journal_id = None
40 changes: 24 additions & 16 deletions contract/models/abstract_contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ class ContractAbstractContractLine(models.AbstractModel):
"applying the pricelist to the product. If not, you will be "
"able to introduce a manual price",
)
specific_price = fields.Float()
price_unit = fields.Float(
# Just to have a currency_id here - will get overwriten in contract.line
# model with the related currency from the contract
currency_id = fields.Many2one("res.currency")
specific_price = fields.Monetary()
price_unit = fields.Monetary(
string="Unit Price",
compute="_compute_price_unit",
inverse="_inverse_price_unit",
)
price_subtotal = fields.Float(
price_subtotal = fields.Monetary(
compute="_compute_price_subtotal",
digits="Account",
string="Sub Total",
)
discount = fields.Float(
Expand Down Expand Up @@ -191,7 +193,7 @@ def _compute_price_unit(self):
from the pricelist otherwise.
"""
for line in self:
if line.automatic_price:
if line.automatic_price and line.product_id:
pricelist = (
line.contract_id.pricelist_id
or line.contract_id.partner_id.with_company(
Expand All @@ -209,7 +211,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 @@ -248,14 +250,20 @@ def _onchange_product_id(self):

date = self.recurring_next_date or fields.Date.context_today(self)
partner = self.contract_id.partner_id or self.env.user.partner_id
product = self.product_id.with_context(
lang=partner.lang,
partner=partner.id,
quantity=self.quantity,
date=date,
pricelist=self.contract_id.pricelist_id.id,
uom=self.uom_id.id,
)
vals["name"] = self.product_id.get_product_multiline_description_sale()
vals["price_unit"] = product.price
if self.product_id:
product = self.product_id.with_context(
lang=partner.lang,
partner=partner.id,
quantity=self.quantity,
date=date,
pricelist=self.contract_id.pricelist_id.id,
uom=self.uom_id.id,
)
vals["name"] = self.product_id.get_product_multiline_description_sale()
if self.contract_id.pricelist_id:
vals["price_unit"] = self.contract_id.pricelist_id._get_product_price(
product, quantity=1
)
else:
vals["price_unit"] = 0.0
self.update(vals)
Loading

0 comments on commit 10e9287

Please sign in to comment.