Skip to content

Commit

Permalink
[MIG] product_contract: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Rad0van committed Jun 8, 2023
1 parent cb47543 commit 54fad5f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion product_contract/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Recurring - Product Contract",
"version": "14.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Contract Management",
"license": "AGPL-3",
"author": "LasLabs, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
Expand Down
4 changes: 2 additions & 2 deletions product_contract/models/contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ContractLine(models.Model):
copy=False,
)

def _prepare_invoice_line(self, move_form):
res = super(ContractLine, self)._prepare_invoice_line(move_form)
def _prepare_invoice_line(self):
res = super(ContractLine, self)._prepare_invoice_line()
if self.sale_order_line_id and res:
res["sale_line_ids"] = [(6, 0, [self.sale_order_line_id.id])]
return res
Expand Down
2 changes: 1 addition & 1 deletion product_contract/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def write(self, vals):
self.with_company(company).write(
{"property_contract_template_id": False}
)
super().write(vals)
return super().write(vals)

@api.constrains("is_contract", "type")
def _check_contract_product_type(self):
Expand Down
16 changes: 5 additions & 11 deletions product_contract/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class SaleOrderLine(models.Model):
help="Specify if process date is 'from' or 'to' invoicing date",
copy=False,
)
date_start = fields.Date(string="Date Start")
date_end = fields.Date(string="Date End")
date_start = fields.Date()
date_end = fields.Date()

contract_line_id = fields.Many2one(
comodel_name="contract.line",
Expand Down Expand Up @@ -269,17 +269,11 @@ def invoice_line_create(self, invoice_id, qty):
SaleOrderLine, self.filtered(lambda l: not l.contract_id)
).invoice_line_create(invoice_id, qty)

@api.depends(
"qty_invoiced",
"qty_delivered",
"product_uom_qty",
"order_id.state",
"product_id.is_contract",
)
def _get_to_invoice_qty(self):
@api.depends("qty_invoiced", "qty_delivered", "product_uom_qty", "state")
def _compute_qty_to_invoice(self):
"""
sale line linked to contracts must not be invoiced from sale order
"""
res = super()._get_to_invoice_qty()
res = super()._compute_qty_to_invoice()
self.filtered("product_id.is_contract").update({"qty_to_invoice": 0.0})
return res
4 changes: 2 additions & 2 deletions product_contract/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.exceptions import ValidationError
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase


class TestProductTemplate(SavepointCase):
class TestProductTemplate(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
6 changes: 3 additions & 3 deletions product_contract/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

from odoo.exceptions import UserError, ValidationError
from odoo.fields import Date
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase


class TestSaleOrder(SavepointCase):
class TestSaleOrder(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_check_contact_is_not_terminated_1(self):
self.order_line1.contract_id = self.contract
self.sale.action_confirm()
self.contract.is_terminated = True
self.sale.action_cancel()
self.sale._action_cancel()
with self.assertRaises(ValidationError):
self.sale.action_draft()
self.contract.is_terminated = False
Expand Down

0 comments on commit 54fad5f

Please sign in to comment.